Skip to content

Commit 6b3c77c

Browse files
committed
fix #136 and fix #144
1 parent bedb1f4 commit 6b3c77c

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

bin/gpth.dart

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,16 @@ void main(List<String> arguments) async {
347347
final c = args['copy']
348348
? await m.file.copy(freeFile.path)
349349
: await m.file.rename(freeFile.path);
350-
await c.setLastModified(m.dateTaken ?? DateTime.now());
350+
var time = m.dateTaken ?? DateTime.now();
351+
if (Platform.isWindows && time.isBefore(DateTime(1970))) {
352+
print('WARNING: ${m.file.path} has date $time, which is before 1970 '
353+
'(not supported on Windows) - will be set to 1970-01-01');
354+
time = DateTime(1970);
355+
}
356+
await c.setLastModified(time);
357+
// on windows, there is also file creation - but it's not supported by dart
358+
// i tried this, and kinda works, but is extra slow :(
359+
// await Process.run('Powershell.exe', ['-command', '(Get-Item "${c.path}").CreationTime=("${time.toLocal().toIso8601String()}")']);
351360
barCopy.increment();
352361
}
353362
print('');

0 commit comments

Comments
 (0)