public ToolAbstractAsyncExecScript(Map<String,?> props) { super(props); stdoutPath = Os.mergePathsUnix(scriptDir, scriptNameWithoutExtension + ".stdout"); stderrPath = Os.mergePathsUnix(scriptDir, scriptNameWithoutExtension + ".stderr"); exitStatusPath = Os.mergePathsUnix(scriptDir, scriptNameWithoutExtension + ".exitstatus"); pidPath = Os.mergePathsUnix(scriptDir, scriptNameWithoutExtension + ".pid"); }
public Builder resetGlobalFiles() { defaultLocationMetadataUrl = "classpath://brooklyn/location-metadata.properties"; globalLocationMetadataFile = Os.mergePaths(Os.home(), ".brooklyn", "location-metadata.properties"); globalPropertiesFile = Os.mergePaths(Os.home(), ".brooklyn", "brooklyn.properties"); return this; }
/** like {@link #deleteOnExitRecursively(File)} followed by {@link #deleteOnExitEmptyParentsUpTo(File, File)} */ public static void deleteOnExitRecursivelyAndEmptyParentsUpTo(File directoryToCleanOrFile, File highestAncestorToDelete) { deleteOnExitRecursively(directoryToCleanOrFile); deleteOnExitEmptyParentsUpTo(directoryToCleanOrFile, highestAncestorToDelete); }
@Test public void testDeleteRecursivelyNonExistantDir() throws Exception { DeletionResult result = Os.deleteRecursively(Os.mergePaths(Os.tmp(), Identifiers.makeRandomId(8))); assertTrue(result.wasSuccessful()); }
public static void deleteCompletely(File d) { DeletionResult result = Os.deleteRecursively(d); if (!result.wasSuccessful()) log.warn("Unable to delete persistence dir "+d); } }
@Override @AfterMethod(alwaysRun=true) public void tearDown() throws Exception { super.tearDown(); dir = Os.deleteRecursively(dir).asNullOrThrowing(); } }
public ShellAbstractTool(File localTempDir) { if (localTempDir == null) { localTempDir = new File(Os.tmp(), "tmpssh-"+Os.user()); if (!localTempDir.exists()) localTempDir.mkdir(); Os.deleteOnExitEmptyParentsUpTo(localTempDir, new File(Os.tmp())); } this.localTempDir = localTempDir; }
/** * @see {@link #deleteRecursively(File)} */ @Beta public static DeletionResult deleteRecursively(String dir) { if (dir==null) return new DeletionResult(null, true, null); return deleteRecursively(new File(dir)); }
public synchronized void close() { Os.deleteRecursively(tmpRoot); }
protected File writeTempFile(InputStream contents) { File tempFile = Os.writeToTempFile(contents, localTempDir, "sshcopy", "data"); tempFile.setReadable(false, false); tempFile.setReadable(true, true); tempFile.setWritable(false); tempFile.setExecutable(false); return tempFile; }
/** deletes the given file or empty directory on exit * <p> * similar to {@link File#deleteOnExit()} except it is smart about trying to delete longer filenames first * (and the shutdown hook order does not use proprietary java hooks) * <p> * note this does not delete non-empty directories; see {@link #deleteOnExitRecursively(File)} for that */ public static void deleteOnExit(File directoryToDeleteIfEmptyOrFile) { addShutdownFileDeletionHook(directoryToDeleteIfEmptyOrFile.getAbsolutePath(), new FileDeletionHook(directoryToDeleteIfEmptyOrFile, false)); }
private List<String> getTestCommand() { if(Os.isMicrosoftWindows()) { return Arrays.asList("cmd", "/c", "echo", "hello", "world"); } else { return Arrays.asList("echo", "hello", "world"); } }
public <T> T asNullOrThrowing() { throwIfFailed(); return null; } }
public Builder resetGlobalFiles() { defaultLocationMetadataUrl = "classpath://brooklyn/location-metadata.properties"; globalLocationMetadataFile = Os.mergePaths(Os.home(), ".brooklyn", "location-metadata.properties"); globalPropertiesFile = Os.mergePaths(Os.home(), ".brooklyn", "brooklyn.properties"); return this; }
@Override protected String getDeploySubdir() { return Os.mergePathsUnix("server", SERVER_TYPE, "deploy"); } // FIXME what is this in as6?
@Override public Boolean call() { deletionResult.set(Os.deleteRecursively(osgiFrameworkCacheDir)); return deletionResult.get().wasSuccessful(); }}) .limitTimeTo(Duration.ONE_SECOND)
@Override @AfterMethod(alwaysRun=true) public void tearDown() throws Exception { super.tearDown(); mementoDir = Os.deleteRecursively(mementoDir).asNullOrThrowing(); }
/** deletes the given file or directory and, in the case of directories, any contents; * similar to apache commons FileUtils.cleanDirectoryOnExit but corrects a bug in that implementation * which causes it to fail if content is added to that directory after the hook is registered */ public static void deleteOnExitRecursively(File directoryToCleanOrFile) { addShutdownFileDeletionHook(directoryToCleanOrFile.getAbsolutePath(), new FileDeletionHook(directoryToCleanOrFile, true)); }
@Override protected String getDeploySubdir() { return Os.mergePathsUnix(SERVER_TYPE, "deployments"); }
public String getPidFile() { // TODO see note in VanillaSoftwareProcess about PID_FILE as a config key // if (getEntity().getConfigRaw(PID_FILE, includeInherited)) ... return Os.mergePathsUnix(getRunDir(), PID_FILENAME); }