Skip to content

Commit

Permalink
move mkdtemp to common.d
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinNowak committed Jan 26, 2014
1 parent 544b7df commit 8e446f0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
12 changes: 1 addition & 11 deletions create_dmd_release/build_all.d
Expand Up @@ -6,6 +6,7 @@ Install Vagrant (https://learnchef.opscode.com/screencasts/install-vagrant/)
Install VirtualBox (https://learnchef.opscode.com/screencasts/install-virtual-box/)
+/
import std.conv, std.exception, std.file, std.path, std.process, std.stdio, std.string, std.net.curl;
import common;
pragma(lib, "curl");

version (Posix) {} else { static assert(0, "This must be run on a Posix machine."); }
Expand Down Expand Up @@ -185,17 +186,6 @@ void close(ProcessPipes pipes)
enforce(wait(pipes.pid) == 0);
}

extern(C) char* mkdtemp(char* template_);

string mkdtemp()
{
import core.stdc.string : strlen;

auto tmp = buildPath(tempDir(), "tmp.XXXXXX\0").dup;
auto dir = mkdtemp(tmp.ptr);
return dir[0 .. strlen(dir)].idup;
}

// builds a dmd.VERSION.OS.MODEL.zip on the vanilla VirtualBox image
void runBuild(Box box, string gitTag)
{
Expand Down
19 changes: 19 additions & 0 deletions create_dmd_release/common.d
@@ -1,6 +1,25 @@
// Zip tools
import std.file, std.path, std.zip;

// should be in core.stdc.stdlib
version (Posix) extern(C) char* mkdtemp(char* template_);

string mkdtemp()
{
version (Posix)
{
import core.stdc.string : strlen;
auto tmp = buildPath(tempDir(), "tmp.XXXXXX\0").dup;
auto dir = mkdtemp(tmp.ptr);
return dir[0 .. strlen(dir)].idup;
}
else
{
import std.format, std.random;
return buildPath(tempDir(), format("tmp.%06X\0", uniform(0, 0xFFFFFF)));
}
}

void extractZip(string archive, string outputDir)
{
import std.array : replace;
Expand Down

0 comments on commit 8e446f0

Please sign in to comment.