Set modification time via os.utime

Hopefully quicker on Windows
This commit is contained in:
Thom Wiggers 2019-03-05 15:45:09 +01:00
parent fe1ba0e615
commit e450cd6042
No known key found for this signature in database
GPG Key ID: 001BB0A7CE26E363

View File

@ -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):