Refine search
public static String getAaptExecutionCommand(String aaptPath, File aapt) throws BrutException { if (! aaptPath.isEmpty()) { File aaptFile = new File(aaptPath); if (aaptFile.canRead() && aaptFile.exists()) { aaptFile.setExecutable(true); return aaptFile.getPath(); } else { throw new BrutException("binary could not be read: " + aaptFile.getAbsolutePath()); } } else { return aapt.getAbsolutePath(); } }
public static void setPathExecutableRecursively(String path) { File file = new File(path); if (!file.exists()) { LOG.warn("Path " + path + " does not exist!"); return; } if (!file.setExecutable(true)) { LOG.error("Failed to set executable for " + path); } if (file.isDirectory()) { File[] files = file.listFiles(); if (null != files && files.length > 0) { setPathExecutableRecursively(file.getAbsolutePath()); } } }
private void initBundled() throws IOException { File tmpDir = new File(System.getProperty("java.io.tmpdir"), "solc"); tmpDir.mkdirs(); InputStream is = getClass().getResourceAsStream("/native/" + getOS() + "/solc/file.list"); try (Scanner scanner = new Scanner(is)) { while (scanner.hasNext()) { String s = scanner.next(); File targetFile = new File(tmpDir, s); InputStream fis = getClass().getResourceAsStream("/native/" + getOS() + "/solc/" + s); Files.copy(fis, targetFile.toPath(), StandardCopyOption.REPLACE_EXISTING); if (solc == null) { // first file in the list denotes executable solc = targetFile; solc.setExecutable(true); } targetFile.deleteOnExit(); } } }
/** * check if the cSploit user can create executable files inside a directory. * @param dir directory to check * @return true if can execute files into {@code dir}, false otherwise */ private boolean user(String dir) { String tmpname; File tmpfile = null; if(dir==null) return false; tmpfile = new File(dir); try { if(!tmpfile.exists()) tmpfile.mkdirs(); do { tmpname = UUID.randomUUID().toString(); } while((tmpfile = new File(dir, tmpname)).exists()); tmpfile.createNewFile(); return (tmpfile.canExecute() || tmpfile.setExecutable(true, false)); } catch (IOException e) { Logger.warning(String.format("cannot create files over '%s'",dir)); } finally { if(tmpfile!=null && tmpfile.exists()) tmpfile.delete(); } return false; }
private void copyExecutable(String name, File target) throws IOException { byte[] bytes = toByteArray(Resources.getResource(getClass(), name)); Path path = target.toPath().resolve(new File(name).getName()); Files.write(path, bytes); if (!path.toFile().setExecutable(true)) { throw new IOException("failed to make executable: " + path); } } }
private static void internalCopyFile(Path sourcePath, Path targetPath, boolean executable, FileSystem sFS, FileSystem tFS) throws IOException { try (FSDataOutputStream lfsOutput = tFS.create(targetPath, FileSystem.WriteMode.NO_OVERWRITE); FSDataInputStream fsInput = sFS.open(sourcePath)) { IOUtils.copyBytes(fsInput, lfsOutput); //noinspection ResultOfMethodCallIgnored new File(targetPath.toString()).setExecutable(executable); } }
File extractedLibFile = new File(targetFolder, extractedLibFileName); extractedLibFile.setExecutable(true); if (!success) { return new File(targetFolder, extractedLibFileName);
sh = new File( "/bin/bash" ); if ( !sh.exists() ) sh = new File( "/usr/bin/bash" ); sh = new File( "/bin/sh" ); file.setExecutable( true ); return filename;
File file = new File( filename ); PrintWriter writer = null; try file.setExecutable( true ); return filename;
void handleUrlAndFinish(final String url) { final File urlOpenerProgramFile = new File(URL_OPENER_PROGRAM); if (!urlOpenerProgramFile.isFile()) { showErrorDialogAndQuit("The following file does not exist:\n$HOME/bin/termux-url-opener\n\n" + "Create this file as a script or a symlink - it will be called with the shared URL as only argument."); return; } // Do this for the user if necessary: //noinspection ResultOfMethodCallIgnored urlOpenerProgramFile.setExecutable(true); final Uri urlOpenerProgramUri = new Uri.Builder().scheme("file").path(URL_OPENER_PROGRAM).build(); Intent executeIntent = new Intent(TermuxService.ACTION_EXECUTE, urlOpenerProgramUri); executeIntent.setClass(TermuxFileReceiverActivity.this, TermuxService.class); executeIntent.putExtra(TermuxService.EXTRA_ARGUMENTS, new String[]{url}); startService(executeIntent); finish(); }
@BeforeClass public static void setupContent() throws FileNotFoundException { contentFolder.mkdir(); contentFolder.setReadable(true, false); contentFolder.setWritable(true, false); contentFolder.setExecutable(true, false); File indexFile = new File(contentFolder, "index.html"); indexFile.setReadable(true, false); indexFile.setWritable(true, false); indexFile.setExecutable(true, false); @Cleanup PrintStream printStream = new PrintStream(new FileOutputStream(indexFile)); printStream.println("<html><body>This worked</body></html>"); }
ZipEntry entry = entries.nextElement(); File newFile = new File(maryBase + "/" + entry.getName()); if (entry.isDirectory()) { System.err.println("Extracting directory: " + entry.getName()); if (newFile.setExecutable(true, false)) { System.err.println("Setting executable bit on file: " + entry.getName());
File generate(final File outputDir) throws IOException { File outputFile = new File(outputDir, generator.getScriptName()); try (BufferedWriter writer = Files.newBufferedWriter(outputFile.toPath())) { writePreamble(writer); writeAbout(writer); writeExistenceTest(writer); writeRestoreData(writer, outputDir.toPath()); writeIncrementalData(writer); generator.writeExit(writer); } outputFile.setExecutable(true, true); return outputFile; }
File nodeModulesDirectory = new File(installDirectory, "node_modules"); File oldNpmDirectory = new File(installDirectory, "npm"); File npmDirectory = new File(nodeModulesDirectory, "npm"); try { if (oldNpmDirectory.isDirectory()) { File copy = new File(installDirectory, script); FileUtils.copyFile(scriptFile, copy); copy.setExecutable(true);
@SuppressWarnings({"Duplicates", "ResultOfMethodCallIgnored"}) @BeforeClass public static void setupContent() throws FileNotFoundException { contentFolder.mkdir(); contentFolder.setReadable(true, false); contentFolder.setWritable(true, false); contentFolder.setExecutable(true, false); File indexFile = new File(contentFolder, "index.html"); indexFile.setReadable(true, false); indexFile.setWritable(true, false); indexFile.setExecutable(true, false); @Cleanup PrintStream printStream = new PrintStream(new FileOutputStream(indexFile)); printStream.println("<html><body>This worked</body></html>"); }
/** * Copy the standard scripts from source location to the mock distribution * directory. */ private void copyScripts(File sourceDir) throws IOException { File binDir = new File(testDrillHome, "bin"); for (String script : ScriptUtils.scripts) { File source = new File(sourceDir, script); File dest = new File(binDir, script); copyFile(source, dest); dest.setExecutable(true); } // Create the "magic" wrapper script that simulates the Drillbit and // captures the output we need for testing. String wrapper = "wrapper.sh"; File dest = new File(binDir, wrapper); try (InputStream is = getClass().getResourceAsStream("/" + wrapper)) { Files.copy(is, dest.toPath(), StandardCopyOption.REPLACE_EXISTING); } dest.setExecutable(true); }
File groovyStarterConf = new File(groovyHome, "groovy-starter.conf"); FileUtil.copyResourceToProject("groovy/conf/groovy-starter.conf", groovyStarterConf); File groovyc = new File(groovyHome, "groovyc"); new Groovyc().groovyVersion(groovyVersion).render(groovyc); groovyc.setExecutable(true); File startGroovy = new File(groovyHome, "startGroovy"); new StartGroovy().groovyVersion(groovyVersion).render(startGroovy); startGroovy.setExecutable(true);
@Override public void extract(String archive, String destinationDirectory) throws ArchiveExtractionException { final File archiveFile = new File(archive); while (entries.hasMoreElements()) { ZipEntry entry = entries.nextElement(); final File destPath = new File(destinationDirectory + File.separator + entry.getName()); prepDestination(destPath, entry.isDirectory()); if(!entry.isDirectory()){ while (tarEntry != null) { final File destPath = new File(destinationDirectory + File.separator + tarEntry.getName()); prepDestination(destPath, tarEntry.isDirectory()); if (!destPath.getCanonicalPath().startsWith(destinationDirectory)) { destPath.createNewFile(); boolean isExecutable = (tarEntry.getMode() & 0100) > 0; destPath.setExecutable(isExecutable);
new File(outputDir, "gradlew").setExecutable(true); Executor.execute(new File(outputDir), "gradlew.bat", "gradlew", "clean" + parseGradleArgs(builder.modules, gradleArgs), callback);
@Override public void runTest(TestRun run) throws IOException { try { File inputFile = new File(run.getBaseDirectory(), run.getFileName()); String exeName = run.getFileName(); if (exeName.endsWith(".c")) { File outputFile = new File(run.getBaseDirectory(), exeName); List<String> compilerOutput = new ArrayList<>(); boolean compilerSuccess = runCompiler(inputFile, outputFile, compilerOutput); outputFile.setExecutable(true); runProcess(new ProcessBuilder(outputFile.getPath()).start(), runtimeOutput); if (!runtimeOutput.isEmpty() && runtimeOutput.get(runtimeOutput.size() - 1).equals("SUCCESS")) {