Rev 4937: Initial implementation of the linux version. in http://bazaar.launchpad.net/~jameinel/bzr/2.1.0rc1-set-mtime
John Arbash Meinel
john at arbash-meinel.com
Tue Jan 5 21:29:14 GMT 2010
At http://bazaar.launchpad.net/~jameinel/bzr/2.1.0rc1-set-mtime
------------------------------------------------------------
revno: 4937
revision-id: john at arbash-meinel.com-20100105212855-xgsy8aziw1ag9377
parent: john at arbash-meinel.com-20100105211522-s3vpbckrs9uvt11u
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.1.0rc1-set-mtime
timestamp: Tue 2010-01-05 15:28:55 -0600
message:
Initial implementation of the linux version.
-------------- next part --------------
=== modified file 'bzrlib/_readdir_pyx.pyx'
--- a/bzrlib/_readdir_pyx.pyx 2009-12-23 02:19:04 +0000
+++ b/bzrlib/_readdir_pyx.pyx 2010-01-05 21:28:55 +0000
@@ -62,6 +62,7 @@
ino_t st_ino
int st_mtime
int st_ctime
+ int fstat(int fd, stat *buf)
int lstat(char *path, stat *buf)
int S_ISDIR(int mode)
int S_ISCHR(int mode)
@@ -77,6 +78,14 @@
int open(char *pathname, int flags, mode_t mode)
+cdef extern from "sys/time.h":
+ struct timeval:
+ long tv_sec
+ long tv_usec
+ # atime, mtime
+ int futimes(int fd, timeval tv[2])
+
+
cdef extern from 'Python.h':
int PyErr_CheckSignals() except -1
char * PyString_AS_STRING(object)
@@ -380,4 +389,25 @@
return result
+def fset_mtime(fileno, mtime):
+ """See osutils.fset_mtime."""
+ cdef int fd
+ cdef int retval
+ cdef double d_mtime
+ cdef timeval tv[2]
+ cdef stat st
+
+ fd = fileno
+ d_mtime = mtime
+ tv[1].tv_sec = <int>(d_mtime)
+ tv[1].tv_usec = <int>((d_mtime - tv[1].tv_sec) * 1000000.0)
+ retval = fstat(fd, &st)
+ if retval != 0:
+ raise OSError('Failed to fstat()')
+ tv[0].tv_sec = st.st_atime
+ tv[0].tv_usec = 0
+ retval = futimes(fd, tv)
+ if retval != 0:
+ raise OSError('Failed to futimes()')
+
# vim: tw=79 ai expandtab sw=4 sts=4
More information about the bazaar-commits
mailing list