|
Last change
on this file since 1538 was 2, checked in by Yuri Dario, 15 years ago |
|
Initial import for vendor code.
|
-
Property svn:eol-style
set to
native
|
|
File size:
664 bytes
|
| Line | |
|---|
| 1 | #! /usr/bin/env python
|
|---|
| 2 |
|
|---|
| 3 | # Copy one file's atime and mtime to another
|
|---|
| 4 |
|
|---|
| 5 | import sys
|
|---|
| 6 | import os
|
|---|
| 7 | from stat import ST_ATIME, ST_MTIME # Really constants 7 and 8
|
|---|
| 8 |
|
|---|
| 9 | def main():
|
|---|
| 10 | if len(sys.argv) <> 3:
|
|---|
| 11 | sys.stderr.write('usage: copytime source destination\n')
|
|---|
| 12 | sys.exit(2)
|
|---|
| 13 | file1, file2 = sys.argv[1], sys.argv[2]
|
|---|
| 14 | try:
|
|---|
| 15 | stat1 = os.stat(file1)
|
|---|
| 16 | except os.error:
|
|---|
| 17 | sys.stderr.write(file1 + ': cannot stat\n')
|
|---|
| 18 | sys.exit(1)
|
|---|
| 19 | try:
|
|---|
| 20 | os.utime(file2, (stat1[ST_ATIME], stat1[ST_MTIME]))
|
|---|
| 21 | except os.error:
|
|---|
| 22 | sys.stderr.write(file2 + ': cannot change time\n')
|
|---|
| 23 | sys.exit(2)
|
|---|
| 24 |
|
|---|
| 25 | if __name__ == '__main__':
|
|---|
| 26 | main()
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.