@@ -64,7 +64,7 @@ enum TrashOptions : int
64
64
checkStickyBit = 8 ,
65
65
66
66
/**
67
- *
67
+ * All flags set.
68
68
*/
69
69
all = (TrashOptions.fallbackToUserDir | TrashOptions.fallbackToHomeDir | TrashOptions.checkStickyBit | TrashOptions.useTopDirs)
70
70
}
@@ -101,6 +101,7 @@ private:
101
101
import core.sys.posix.sys.types ;
102
102
import core.sys.posix.sys.stat ;
103
103
import core.sys.posix.unistd ;
104
+ import core.sys.posix.fcntl ;
104
105
105
106
@trusted string topDir(string path)
106
107
in {
@@ -247,8 +248,6 @@ private:
247
248
}
248
249
}
249
250
} else version (OSX ) {
250
- import std.exception ;
251
-
252
251
void * handle = dlopen(" CoreServices.framework/Versions/A/CoreServices" , RTLD_NOW | RTLD_LOCAL );
253
252
if (handle ! is null ) {
254
253
scope (exit) dlclose (handle);
@@ -329,10 +328,18 @@ private:
329
328
}
330
329
331
330
import std.datetime ;
331
+ import std.conv : octal;
332
+
332
333
auto currentTime = Clock .currTime;
333
334
currentTime.fracSecs = Duration.zero;
334
- string contents = format(" [Trash Info]\n Path=%s\n DeletionDate=%s\n " , path.escapeValue(), currentTime.toISOExtString());
335
- write(trashInfoPath, contents);
335
+ string timeString = currentTime.toISOExtString();
336
+ string contents = format(" [Trash Info]\n Path=%s\n DeletionDate=%s\n " , path.escapeValue(), timeString);
337
+
338
+ auto mode = O_CREAT | O_WRONLY | O_EXCL ;
339
+ auto fd = open(toStringz(trashInfoPath), mode, octal! 666 );
340
+ errnoEnforce(fd != 0 );
341
+ errnoEnforce(write(fd, contents.ptr, contents.length) == contents.length);
342
+
336
343
path.rename(trashFilePath);
337
344
} else {
338
345
static assert (" Unsupported platform" );
0 commit comments