aboutsummaryrefslogtreecommitdiff
path: root/toys/truncate.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2012-08-25 14:25:22 -0500
committerRob Landley <rob@landley.net>2012-08-25 14:25:22 -0500
commit3a9241add947cb6d24b5de7a8927517426a78795 (patch)
treed122ab6570439cd6b17c7d73ed8d4e085e0b8a95 /toys/truncate.c
parent689f095bc976417bf50810fe59a3b3ac32b21105 (diff)
downloadtoybox-3a9241add947cb6d24b5de7a8927517426a78795.tar.gz
Move commands into "posix", "lsb", and "other" menus/directories.
Diffstat (limited to 'toys/truncate.c')
-rw-r--r--toys/truncate.c47
1 files changed, 0 insertions, 47 deletions
diff --git a/toys/truncate.c b/toys/truncate.c
deleted file mode 100644
index dccd3215..00000000
--- a/toys/truncate.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/* vi: set sw=4 ts=4:
- *
- * truncate.c - set file length, extending sparsely if necessary
- *
- * Copyright 2011 Rob Landley <rob@landley.net>
- *
- * Not in SUSv4
-
-USE_TRUNCATE(NEWTOY(truncate, "<1s#|c", TOYFLAG_BIN))
-
-config TRUNCATE
- bool "truncate"
- default y
- help
- usage: truncate [-c] -s file...
- Set length of file(s), extending sparsely if necessary.
-
- -c Don't create file if it doesn't exist.
- -s New size
-*/
-
-#include "toys.h"
-
-DEFINE_GLOBALS(
- long size;
-)
-
-#define TT this.truncate
-
-static void do_truncate(int fd, char *name)
-{
- if (fd<0) return;
- if (ftruncate(fd, TT.size)) {
- perror_msg("failed to set '%s' to '%ld'", name, TT.size);
- toys.exitval = EXIT_FAILURE;
- }
-}
-
-void truncate_main(void)
-{
- int cr = !(toys.optflags&1);
-
- // Create files with mask rwrwrw.
- // Nonexistent files are only an error if we're supposed to create them.
- loopfiles_rw(toys.optargs, O_WRONLY|(cr ? O_CREAT : 0), 0666, cr,
- do_truncate);
-}