1566 """Change file stat of specified path to avoid ambiguity |
1566 """Change file stat of specified path to avoid ambiguity |
1567 |
1567 |
1568 'old' should be previous filestat of 'path'. |
1568 'old' should be previous filestat of 'path'. |
1569 |
1569 |
1570 This skips avoiding ambiguity, if a process doesn't have |
1570 This skips avoiding ambiguity, if a process doesn't have |
1571 appropriate privileges for 'path'. |
1571 appropriate privileges for 'path'. This returns False in this |
|
1572 case. |
|
1573 |
|
1574 Otherwise, this returns True, as "ambiguity is avoided". |
1572 """ |
1575 """ |
1573 advanced = (old.stat.st_mtime + 1) & 0x7fffffff |
1576 advanced = (old.stat.st_mtime + 1) & 0x7fffffff |
1574 try: |
1577 try: |
1575 os.utime(path, (advanced, advanced)) |
1578 os.utime(path, (advanced, advanced)) |
1576 except OSError as inst: |
1579 except OSError as inst: |
1577 if inst.errno == errno.EPERM: |
1580 if inst.errno == errno.EPERM: |
1578 # utime() on the file created by another user causes EPERM, |
1581 # utime() on the file created by another user causes EPERM, |
1579 # if a process doesn't have appropriate privileges |
1582 # if a process doesn't have appropriate privileges |
1580 return |
1583 return False |
1581 raise |
1584 raise |
|
1585 return True |
1582 |
1586 |
1583 def __ne__(self, other): |
1587 def __ne__(self, other): |
1584 return not self == other |
1588 return not self == other |
1585 |
1589 |
1586 class atomictempfile(object): |
1590 class atomictempfile(object): |