/** * Translates a relative path to a local system path. * * @param destination the path to translate * @param variables used to replaces variables in the path * @return the translated path */ public static String translatePath(String destination, Variables variables) { destination = variables.replace(destination); return translatePath(destination); }
/** * Creates a temp file with delete on exit rule. The extension is extracted from the template if * possible, else the default extension is used. The contents of template will be copied into * the temporary file. * * @param template file path to copy from and define file extension * @param defaultExtension file extension if no is contained in template * @return newly created and filled temporary file * @throws IOException if an I/O error occurred */ public static File copyToTempFile(String template, String defaultExtension) throws IOException { return copyToTempFile(new File(template), defaultExtension); }
@Override public String resolve() { return IoHelper.getenv(variable); }
private long getAvaiableBytes() { return IoHelper.getFreeSpace(IoHelper.existingParent( new File(this.installData.getInstallPath())).getAbsolutePath()); } /**
@Override public void showFreeSpace() { if (IoHelper.supported("getFreeSpace") && freeSpaceLabel != null) { String msg; freeBytes = IoHelper.getFreeSpace(IoHelper.existingParent( new File(this.installData.getInstallPath())).getAbsolutePath()); if (freeBytes < 0) { msg = getString("PacksPanel.notAscertainable"); } else { msg = Pack.toByteUnitsString(freeBytes); } freeSpaceLabel.setText(msg); } }
File existParent = IoHelper.existingParent(new File(_pathSelectionPanel.getPath())); if (existParent == null)
private void copyFileToJar(File fileToCopy, ZipOutputStream outputStream) throws IOException { if (fileToCopy.isDirectory()) { File[] files = fileToCopy.listFiles(); if (files != null) { for (File file : files) { copyFileToJar(file, outputStream); } } } else { String entryName = resolveName(fileToCopy, this.destination); List<String> mergeList = getMergeList(outputStream); if (mergeList.contains(entryName)) { return; } mergeList.add(entryName); FileInputStream inputStream = new FileInputStream(fileToCopy); IoHelper.copyStreamToJar(inputStream, outputStream, entryName, fileToCopy.lastModified()); inputStream.close(); } }
FileExecutor fe = new FileExecutor(); fe.executeCommand(params, output); ret = extractLong(output[0], -3); FileExecutor fe = new FileExecutor(); fe.executeCommand(params, output); ret = extractLong(output[0], -3) * 1024; FileExecutor fe = new FileExecutor(); fe.executeCommand(params, output); ret = extractLong(output[0], -3) * 1024; FileExecutor fe = new FileExecutor(); fe.executeCommand(params, output); ret = extractLong(output[0], -3) * 1024;
File existParent = IoHelper.existingParent(path); if (existParent != null)
IoHelper.copyStreamToJar(inputStream, (java.util.zip.ZipOutputStream) outputStream, dest.toString().replaceAll("//", "/"), jarEntry.getTime());
if (uninstallerPath != null && uninstallerPath.startsWith(INSTALL_PATH)) uninstallerPath = IoHelper.translatePath(uninstallerPath); uninstallerPath = uninstallerPath.substring(INSTALL_PATH.length()); if (result.endsWith(uninstallerPath))
@Override public String resolve(VariableSubstitutor... substitutors) throws Exception { String _variable_ = variable; for (VariableSubstitutor substitutor : substitutors) { _variable_ = substitutor.substitute(_variable_); } return IoHelper.getenv(_variable_); }
try tmpFile = IoHelper.copyToTempFile(action.getBuildFile(), ".xml"); try propFile = IoHelper.copyToTempFile(propName, ".properties"); newProps.add(propFile.getCanonicalPath());
File parent = IoHelper.existingParent(dir); if (parent != null)
logfile = IoHelper.translatePath(logfile, installData.getVariables()); File outFile = new File(logfile); if (!outFile.getParentFile().exists())
/** * Get the default path for Windows (i.e Program Files/...). * Windows has a Setting for this in the environment and in the registry. * Just try to use the setting in the environment. If it fails for whatever reason, we take the former solution (buildWindowsDefaultPathFromProps). * * @param resources the resources * @return The Windows default installation path for applications. */ private String buildWindowsDefaultPath(Resources resources) { try { //get value from environment... String prgFilesPath = IoHelper.getenv("ProgramFiles"); if (prgFilesPath != null && prgFilesPath.length() > 0) { return prgFilesPath + File.separatorChar; } else { return buildWindowsDefaultPathFromProps(resources); } } catch (Exception exception) { logger.log(Level.WARNING, exception.getMessage(), exception); return buildWindowsDefaultPathFromProps(resources); } }
if (!executableFile.hasCondition() || isConditionTrue(executableFile.getCondition())) executableFile.path = IoHelper.translatePath(executableFile.path, variables); if (null != executableFile.argList && !executableFile.argList.isEmpty()) arg = IoHelper.translatePath(arg, variables); executableFile.argList.set(j, arg);
&& (name.lastIndexOf(']') == name.length() - 1)) varValue = IoHelper.getenv(name.substring(4, name.length() - 1)); if (varValue == null)
String tempFolder = IoHelper.translatePath(installData.getInfo().getUninstallerPath() + WEB_TEMP_SUB_PATH, installData.getVariables()); File tempDir = new File(tempFolder);
/** * Creates the uninstaller jar file. * * @throws IOException for any I/O error */ private void createOutputJar() throws IOException { // Create the uninstaller directory String dirPath = IoHelper.translatePath(installData.getInfo().getUninstallerPath(), installData.getVariables()); String jarPath = dirPath + File.separator + installData.getInfo().getUninstallerName(); File dir = new File(dirPath); if (!dir.exists() && !dir.mkdirs()) { throw new IOException("Failed to create output path: " + dir); } // Log the uninstaller deletion information uninstallData.setUninstallerJarFilename(jarPath); uninstallData.setUninstallerPath(dirPath); // Create the jar file jarStream = new FileOutputStream(jarPath); jar = new JarOutputStream(new BufferedOutputStream(jarStream)); jar.setLevel(9); uninstallData.addFile(jarPath, true); }