Skip to content

Commit

Permalink
Use the action-scoped tmpdir for temporary files
Browse files Browse the repository at this point in the history
This is both the correct thing to do, and also makes it much more obvious when
the Assets.car file and Info.plist file are being written to different
directories for reasons of actool being crazy.

--
MOS_MIGRATED_REVID=88853163
  • Loading branch information
illicitonion authored and kchodorow committed Mar 18, 2015
1 parent 5f67445 commit 4b3bf40
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
Expand All @@ -38,14 +39,16 @@ private Wrappers() {
*/
public static void execute(String[] argsArray, Wrapper wrapper)
throws IOException, InterruptedException {
FileSystem filesystem = FileSystems.getDefault();
ArgumentsParsing argsParsing = ArgumentsParsing.parse(
FileSystems.getDefault(), argsArray, wrapper.name(), wrapper.subtoolName());
filesystem, argsArray, wrapper.name(), wrapper.subtoolName());
for (String error : argsParsing.error().asSet()) {
System.err.printf(error);
System.exit(1);
}
Path tempDir = getTempDir(filesystem);
for (Arguments args : argsParsing.arguments().asSet()) {
Path outputDir = Files.createTempDirectory("ZippingOutput");
Path outputDir = Files.createTempDirectory(tempDir, "ZippingOutput");
Path rootedOutputDir = outputDir.resolve(args.bundleRoot());
Files.createDirectories(
wrapper.outputDirectoryMustExist() ? rootedOutputDir : rootedOutputDir.getParent());
Expand All @@ -64,4 +67,12 @@ public static void execute(String[] argsArray, Wrapper wrapper)
}
}
}

private static Path getTempDir(FileSystem filesystem) {
String tempDir = System.getenv("TMPDIR");
if (tempDir == null) {
tempDir = "/tmp";
}
return filesystem.getPath(tempDir);
}
}

0 comments on commit 4b3bf40

Please sign in to comment.