except AttributeError as e:
_bup_lutimes = False
+assert sys.version_info[0] < 3 \
+ or not (_bup_utimensat or _bup_utimes or _bup_lutimes)
-def timespec_to_nsecs((ts_s, ts_ns)):
+
+def timespec_to_nsecs(ts):
+ ts_s, ts_ns = ts
return ts_s * 10**9 + ts_ns
"""Return (s, ns) where ns is always non-negative
and t = s + ns / 10e8""" # metadata record rep
ns = int(ns)
- return (ns / 10**9, ns % 10**9)
+ return (ns // 10**9, ns % 10**9)
def nsecs_to_timeval(ns):
"""Return (s, us) where ns is always non-negative
and t = s + us / 10e5"""
ns = int(ns)
- return (ns / 10**9, (ns % 10**9) / 1000)
+ return (ns // 10**9, (ns % 10**9) // 1000)
def fstime_floor_secs(ns):
"""Return largest integer not greater than ns / 10e8."""
- return int(ns) / 10**9;
+ return int(ns) // 10**9;
def fstime_to_timespec(ns):
return nsecs_to_timespec(ns)
-def fstime_to_sec_str(fstime):
+def fstime_to_sec_bytes(fstime):
(s, ns) = fstime_to_timespec(fstime)
if(s < 0):
s += 1
if ns == 0:
- return '%d' % s
+ return b'%d' % s
else:
- return '%d.%09d' % (s, ns)
-
+ return b'%d.%09d' % (s, ns)
-if _bup_utimensat:
+if sys.version_info[0] > 2:
+ def utime(path, times):
+ """Times must be provided as (atime_ns, mtime_ns)."""
+ os.utime(path, ns=times)
+ def lutime(path, times):
+ """Times must be provided as (atime_ns, mtime_ns)."""
+ os.utime(path, ns=times, follow_symlinks=False)
+elif _bup_utimensat:
def utime(path, times):
"""Times must be provided as (atime_ns, mtime_ns)."""
atime = nsecs_to_timespec(times[0])
class stat_result:
+ __slots__ = ('st_mode', 'st_ino', 'st_dev', 'st_nlink', 'st_uid', 'st_gid',
+ 'st_rdev', 'st_size', 'st_atime', 'st_mtime', 'st_ctime')
@staticmethod
def from_xstat_rep(st):
global _cygwin_sys