Skip to content
Snippets Groups Projects
Commit b7a04efb authored by Andreia Gaita's avatar Andreia Gaita
Browse files

Create temp files in the temp directory

Fixes #228
parent deab3f14
No related branches found
No related tags found
No related merge requests found
......@@ -697,6 +697,18 @@ GitHub.Unity
}
}
public static NPath GetTempFilename(string myprefix = "")
{
var random = new Random();
var prefix = FileSystem.GetTempPath() + "/" + (String.IsNullOrEmpty(myprefix) ? "" : myprefix + "_");
while (true)
{
var candidate = new NPath(prefix + random.Next());
if (!candidate.Exists())
return candidate;
}
}
public NPath Move(string dest)
{
return Move(new NPath(dest));
......
......@@ -76,7 +76,8 @@ namespace GitHub.Unity
{
// we need to create a temp bash script to set up the environment properly, because
// osx terminal app doesn't inherit the PATH env var and there's no way to pass it in
var envVarFile = environment.FileSystem.GetRandomFileName();
var envVarFile = NPath.GetTempFilename();
environment.FileSystem.WriteAllLines(envVarFile, new string[] { "cd $GHU_WORKINGDIR", "PATH=$GHU_FULLPATH:$PATH /bin/bash" });
Mono.Unix.Native.Syscall.chmod(envVarFile, (Mono.Unix.Native.FilePermissions)493); // -rwxr-xr-x mode (0755)
startInfo.FileName = "open";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment