Skip to content

Commit

Permalink
Attempt to debug random failure on Mac OS X.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmdavis committed Oct 19, 2017
1 parent 1863b09 commit f299c01
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions std/file.d
Original file line number Diff line number Diff line change
Expand Up @@ -775,17 +775,48 @@ string createTempFile(const(char)[] prefix, const(char)[] suffix, const void[] b
{
// O_EXCL does not support symbolic links.
if (filename.dirName.isSymlink)
{
import std.stdio;
writeln("-------symlink-------");
writeln(tempDir);
writeln(filename);
filename = buildPath(filename.dirName.readLink(), filename.baseName);
writeln(filename);
writeln("---------------------");
}

auto fd = open(tempCString!FSChar(filename), O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
if (fd == -1)
{
immutable errno = .errno;
if (errno == EEXIST)
{
import std.stdio;
writeln("-------EEXIST-------");
writeln(tempDir);
writeln(filename);
writeln("---------------------");
continue;
}
else
{
// try to debug problem on Mac
import std.exception, std.stdio;
writeln("-------FAILURE-------");
writeln(tempDir);
writeln(filename);
writeln(errno);
writeln(errnoString(errno));
writeln("---------------------");

throw new FileException("Failed to create a temporary file", errno);
}
}
import std.stdio;
writeln("-------SUCCESS-------");
writeln(tempDir);
writeln(filename);
writeln("---------------------");
}
else version(Windows)
{
Expand Down

0 comments on commit f299c01

Please sign in to comment.