Set modification time via os.utime
Hopefully quicker on Windows
This commit is contained in:
parent
fe1ba0e615
commit
e450cd6042
@ -24,20 +24,9 @@ def test_makefile_dependencies():
|
|||||||
|
|
||||||
|
|
||||||
def touch(time, *files):
|
def touch(time, *files):
|
||||||
if not files:
|
for path in files:
|
||||||
raise Exception("Please specify the files to update")
|
times = (time.timestamp(), time.timestamp())
|
||||||
if os.name == 'nt':
|
os.utime(path, times)
|
||||||
formatstring = "Get-Date -year %Y -month %m -day %d -hour %H -minute %M -second %S"
|
|
||||||
time = time.strftime(formatstring)
|
|
||||||
commands = []
|
|
||||||
for file in files:
|
|
||||||
commands.append('(ls {}).LastWriteTime = {}'.format(file, time))
|
|
||||||
|
|
||||||
helpers.run_subprocess(['powershell', '; '.join(commands)])
|
|
||||||
else:
|
|
||||||
formatstring = "%Y%m%d%H%M.%S"
|
|
||||||
time = time.strftime(formatstring)
|
|
||||||
helpers.run_subprocess(['touch', '-t', time, *files])
|
|
||||||
|
|
||||||
|
|
||||||
def make_check(path, expect_error=False):
|
def make_check(path, expect_error=False):
|
||||||
|
Loading…
Reference in New Issue
Block a user