mirror of
https://github.com/troglobit/libite.git
synced 2026-10-24 11:44:37 +00:00
Add erasef(), formatted version of erase()
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 parent
098a020843
commit
d4b554ccdc
5 files changed
+85
-3
No files matched your search
+10
-1
@@ -1,3 +1,4 @@
|
||||
/* test of touch(), touchf(), erase(), and erasef() */
|
||||
#include <err.h>
|
||||
#include <paths.h>
|
||||
#include <signal.h>
|
||||
@@ -53,7 +54,15 @@ static int formatted(char *file)
|
||||
errx(1, "touchf() does not detect failure to create file " FMT, file);
|
||||
|
||||
PRINT("File " FMT " really does exist!\n", file);
|
||||
erase(vrfy);
|
||||
|
||||
erasef(FMT, file);
|
||||
if (fexist(vrfy)) {
|
||||
int saved = errno;
|
||||
|
||||
erase(vrfy);
|
||||
errno = saved;
|
||||
errx(1, "erasef() failed removing the created file " FMT, file);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user