diff options
author | Rob Landley <rob@landley.net> | 2011-11-13 20:02:47 -0600 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2011-11-13 20:02:47 -0600 |
commit | 43c2e62d74f1cf1e8b20b87bacac5b7b3e454f99 (patch) | |
tree | 35ef2f9ec71489e515de2512f2d65df17b8d2379 /toys/touch.c | |
parent | 234f42adc016e8056a4a9f4466adea9072f0a7f6 (diff) | |
download | toybox-43c2e62d74f1cf1e8b20b87bacac5b7b3e454f99.tar.gz |
Prepare for license switch by (regrettably) removing Charlie Shepherd's code, at least until I can get in touch with him to to get permission to relicense it.
Charlie's @gentoo address bounces, and he hasn't replied to his @gmail address.
I welcome him as a contributor but can't _find_ him, so I can't ship his
basename, dirname, mkfifo, touch, and tty command code under a non-GPL license.
This essentially reverts the following commits:
147: implement touch
157: implement mkfifo
160: tweak touch
161: touch bugfix
162: touch -l
176: implement basename, dirname
179: implement tty
I also looked at these commits, which Charlie contributed to but which
don't need to be reverted. (Mostly whitespace changes and typo fixes,
plus some minor changes to build infrastructure that don't affect the
resulting code.)
*149: add null pointer check
*154: add .hgignore
*155: whitespace
*156: whitespace (the rest is by me)
*158: add toys/help.h to makefile dependencies
*159: fix typo in description
*164: typo in df (dereference pointer)
*180: .hgignore
*182: whitespace in error messages
*183: add headers to make dependencies
*244: comment and whitespace cleanups
*247: build tweak: error checking
*248: typo in comment
*249: .hgignore
*250: wrong word in comment
*251: whitespace
*252: whitespace
Several files in the "scripts" directory are still GPLv2 (kconfig,
bloat-o-meter, Robert Foglietta's bash version of config2help.sh), but
they're just build infrastructure that doesn't wind up in the resulting
binary. I plan to address this later on general principles, but it's
"mere aggregation" and not an immediate priority.)
Diffstat (limited to 'toys/touch.c')
-rw-r--r-- | toys/touch.c | 108 |
1 files changed, 0 insertions, 108 deletions
diff --git a/toys/touch.c b/toys/touch.c deleted file mode 100644 index bead28fb..00000000 --- a/toys/touch.c +++ /dev/null @@ -1,108 +0,0 @@ -/* vi: set sw=4 ts=4: - * - * touch.c - Modify a file's timestamps. - * - * Copyright (C) 2007 Charlie Shepherd <masterdriverz@gentoo.org> - * - * See http://www.opengroup.org/onlinepubs/009695399/utilities/touch.html - -USE_TOUCH(NEWTOY(touch, "l#t:r:mca", TOYFLAG_BIN|TOYFLAG_UMASK)) - -config TOUCH - bool "touch" - default y - help - usage: touch [-acm] [-r FILE] [-t MMDDhhmm] [-l bytes] FILE... - - Change file timestamps, ensure file existance and change file length. - - -a Only change the access time. - -c Do not create the file if it doesn't exist. - -l Length to truncate (or sparsely extend) file to. - -m Only change the modification time. - -r Reference file to take timestamps from. - -t Time to change {a,m}time to. -*/ - -#include "toys.h" - -DEFINE_GLOBALS( - char *ref_file; - char *time; - long length; -) - -#define TT this.touch - -#define OPT_MTIME 0x01 -#define OPT_NOCREATE 0x02 -#define OPT_ATIME 0x04 -#define OPT_REFERENCE 0x08 -#define OPT_TIME 0x10 -#define OPT_LENGTH 0x20 - -void touch_main(void) -{ - char *arg; - int i, set_a, set_m; - time_t curr_a, curr_m; - - set_a = !!(toys.optflags & OPT_ATIME); - set_m = !!(toys.optflags & OPT_MTIME); - - // Use timestamp on a file - if (toys.optflags & OPT_REFERENCE) { - struct stat sb; - - if (toys.optflags & OPT_TIME) - error_exit("Redundant time source"); - xstat(TT.ref_file, &sb); - curr_m = sb.st_mtime; - curr_a = sb.st_atime; - - // Use time specified on command line. - } else if (toys.optflags & OPT_TIME) { - struct tm t; - time_t curr; - char *c; - - curr = time(NULL); - if (localtime_r(&curr, &t) - || !(c = strptime(TT.time, "%m%d%H%M", &t)) - || *c || -1==(curr_a = curr_m = mktime(&t))) - { - error_exit("Unknown time %s", TT.time); - } - - // use current time - } else curr_m = curr_a = time(NULL); - - for (i = 0; (arg = toys.optargs[i]); i++) { - struct utimbuf buf; - struct stat sb; - - buf.modtime = curr_m; - buf.actime = curr_a; - - if (stat(arg, &sb)) { - if (!(toys.optflags & OPT_NOCREATE)) { - xcreate(arg, O_CREAT, 0644); - if (stat(arg, &sb)) - goto error; - } - } - - if ((set_a+set_m) == 1) { - /* We've been asked to only change one */ - if (set_a) buf.modtime = sb.st_mtime; - else if (set_m) buf.actime = sb.st_atime; - } - - if (toys.optflags & OPT_LENGTH) - if (truncate(arg, TT.length)) - goto error; - if (utime(arg, &buf)) -error: - perror_exit(arg); - } -} |