diff options
author | cinap_lenrek <cinap_lenrek@localhost> | 2011-05-03 11:25:13 +0000 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@localhost> | 2011-05-03 11:25:13 +0000 |
commit | 458120dd40db6b4df55a4e96b650e16798ef06a0 (patch) | |
tree | 8f82685be24fef97e715c6f5ca4c68d34d5074ee /sys/src/cmd/python/Tools/scripts/copytime.py | |
parent | 3a742c699f6806c1145aea5149bf15de15a0afd7 (diff) |
add hg and python
Diffstat (limited to 'sys/src/cmd/python/Tools/scripts/copytime.py')
-rwxr-xr-x | sys/src/cmd/python/Tools/scripts/copytime.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/sys/src/cmd/python/Tools/scripts/copytime.py b/sys/src/cmd/python/Tools/scripts/copytime.py new file mode 100755 index 000000000..209c4924d --- /dev/null +++ b/sys/src/cmd/python/Tools/scripts/copytime.py @@ -0,0 +1,26 @@ +#! /usr/bin/env python + +# Copy one file's atime and mtime to another + +import sys +import os +from stat import ST_ATIME, ST_MTIME # Really constants 7 and 8 + +def main(): + if len(sys.argv) <> 3: + sys.stderr.write('usage: copytime source destination\n') + sys.exit(2) + file1, file2 = sys.argv[1], sys.argv[2] + try: + stat1 = os.stat(file1) + except os.error: + sys.stderr.write(file1 + ': cannot stat\n') + sys.exit(1) + try: + os.utime(file2, (stat1[ST_ATIME], stat1[ST_MTIME])) + except os.error: + sys.stderr.write(file2 + ': cannot change time\n') + sys.exit(2) + +if __name__ == '__main__': + main() |