Example usage for java.io File setExecutable

List of usage examples for java.io File setExecutable

Introduction

In this page you can find the example usage for java.io File setExecutable.

Prototype

public boolean setExecutable(boolean executable) 

Source Link

Document

A convenience method to set the owner's execute permission for this abstract pathname.

Usage

From source file:io.fabric8.maven.plugin.mojo.infra.AbstractInstallMojo.java

private void moveFile(File tempFile, File destFile, String fileName) throws MojoExecutionException {
    if (!tempFile.renameTo(destFile)) {
        // lets try copy it instead as this could be an odd linux issue with renaming files
        try {//from w  w w . j a  va2  s.  c  om
            IOHelpers.copy(new FileInputStream(tempFile), new FileOutputStream(destFile));
            log.info("Downloaded %s to %s", fileName, destFile);
        } catch (IOException e) {
            throw new MojoExecutionException(
                    "Failed to copy temporary file " + tempFile + " to " + destFile + ": " + e, e);
        }
    }
    if (!destFile.setExecutable(true)) {
        throw new MojoExecutionException("Cannot make " + destFile + " executable");
    }
}

From source file:brut.androlib.res.AndrolibResources.java

public void aaptPackage(File apkFile, File manifest, File resDir, File rawDir, File assetDir, File[] include)
        throws AndrolibException {

    boolean customAapt = false;
    String aaptPath = apkOptions.aaptPath;
    List<String> cmd = new ArrayList<String>();

    // path for aapt binary
    if (!aaptPath.isEmpty()) {
        File aaptFile = new File(aaptPath);
        if (aaptFile.canRead() && aaptFile.exists()) {
            aaptFile.setExecutable(true);
            cmd.add(aaptFile.getPath());
            customAapt = true;/*ww  w. j ava2 s  . c om*/

            if (apkOptions.verbose) {
                LOGGER.info(aaptFile.getPath() + " being used as aapt location.");
            }
        } else {
            LOGGER.warning("aapt location could not be found. Defaulting back to default");

            try {
                cmd.add(getAaptBinaryFile().getAbsolutePath());
            } catch (BrutException ignored) {
                cmd.add("aapt");
            }
        }
    } else {
        try {
            cmd.add(getAaptBinaryFile().getAbsolutePath());
        } catch (BrutException ignored) {
            cmd.add("aapt");
        }
    }

    cmd.add("p");

    if (apkOptions.verbose) { // output aapt verbose
        cmd.add("-v");
    }
    if (apkOptions.updateFiles) {
        cmd.add("-u");
    }
    if (apkOptions.debugMode) { // inject debuggable="true" into manifest
        cmd.add("--debug-mode");
    }

    // force package id so that some frameworks build with correct id
    // disable if user adds own aapt (can't know if they have this feature)
    if (mPackageId != null && !customAapt && !mSharedLibrary) {
        cmd.add("--forced-package-id");
        cmd.add(mPackageId);
    }
    if (mSharedLibrary) {
        cmd.add("--shared-lib");
    }
    if (mMinSdkVersion != null) {
        cmd.add("--min-sdk-version");
        cmd.add(mMinSdkVersion);
    }
    if (mTargetSdkVersion != null) {
        cmd.add("--target-sdk-version");
        cmd.add(mTargetSdkVersion);
    }
    if (mMaxSdkVersion != null) {
        cmd.add("--max-sdk-version");
        cmd.add(mMaxSdkVersion);

        // if we have max sdk version, set --max-res-version
        // so we can ignore anything over that during build.
        cmd.add("--max-res-version");
        cmd.add(mMaxSdkVersion);
    }
    if (mPackageRenamed != null) {
        cmd.add("--rename-manifest-package");
        cmd.add(mPackageRenamed);
    }
    if (mVersionCode != null) {
        cmd.add("--version-code");
        cmd.add(mVersionCode);
    }
    if (mVersionName != null) {
        cmd.add("--version-name");
        cmd.add(mVersionName);
    }
    cmd.add("-F");
    cmd.add(apkFile.getAbsolutePath());

    if (apkOptions.isFramework) {
        cmd.add("-x");
    }

    if (apkOptions.doNotCompress != null) {
        for (String file : apkOptions.doNotCompress) {
            cmd.add("-0");
            cmd.add(file);
        }
    }
    if (!apkOptions.resourcesAreCompressed) {
        cmd.add("-0");
        cmd.add("arsc");
    }

    if (include != null) {
        for (File file : include) {
            cmd.add("-I");
            cmd.add(file.getPath());
        }
    }
    if (resDir != null) {
        cmd.add("-S");
        cmd.add(resDir.getAbsolutePath());
    }
    if (manifest != null) {
        cmd.add("-M");
        cmd.add(manifest.getAbsolutePath());
    }
    if (assetDir != null) {
        cmd.add("-A");
        cmd.add(assetDir.getAbsolutePath());
    }
    if (rawDir != null) {
        cmd.add(rawDir.getAbsolutePath());
    }
    try {
        OS.exec(cmd.toArray(new String[0]));
        if (apkOptions.verbose) {
            LOGGER.info("command ran: ");
            LOGGER.info(cmd.toString());
        }
    } catch (BrutException ex) {
        throw new AndrolibException(ex);
    }
}

From source file:com.codesourcery.installer.Installer.java

/**
 * Initializes the install platform.//from  w  w  w.j  a  v  a 2  s  .c o  m
 * 
 * @throws CoreException on failure
 */
private void initializeInstallPlatform() throws CoreException {
    try {
        Bundle bundle = Platform.getBundle(Installer.ID);
        String os = Platform.getOS();
        String arch = Platform.getOSArch();

        // Temporary directory
        String tempDirValue = System.getProperty("java.io.tmpdir");
        if (tempDirValue == null)
            fail("No temporary directory available, aborting.");
        IPath tempPath = new Path(tempDirValue);
        File tempDir = tempPath.toFile();
        if (!tempDir.exists())
            fail("Temporary directory does not exist, aborting.");

        // Install monitor prefix
        final String monPrefix = MessageFormat.format("{0}-{1}-{2}",
                new Object[] { IInstallConstants.INSTALL_MONITOR_NAME, os, arch });
        // Install monitor filename
        String monSrcName = monPrefix;
        if (isWindows()) {
            monSrcName += "." + IInstallConstants.EXTENSION_EXE;
        }

        // Install monitor included with installer
        URL url = FileLocator.find(bundle, new Path("/exe/" + monSrcName), null); //$NON-NLS-1$
        url = FileLocator.resolve(url);
        File monSrcFile = new File(url.getFile());
        // Install monitor temporary path
        IPath monTempPath = tempPath.append(monPrefix + "-" + UUID.randomUUID().toString()
                + (isWindows() ? "." + IInstallConstants.EXTENSION_EXE : ""));
        File monTempFile = monTempPath.toFile();

        // Copy install monitor
        FileUtils.copyFile(monSrcFile, monTempFile);
        // Set execute attribute
        monTempFile.setExecutable(true);

        // Get the installer PID (only works for a SUN JVM)
        String runtimeName = ManagementFactory.getRuntimeMXBean().getName();
        int seperator = runtimeName.indexOf('@');
        String pid = runtimeName.substring(0, seperator);

        // Redistributables directory (if available)
        String redistPath = null;
        File redistDir = getInstallFile(IInstallConstants.REDIST_DIRECTORY);
        if ((redistDir != null) && redistDir.exists())
            redistPath = redistDir.getAbsolutePath();

        IPath monitorLogPath = getLogPath().append(IInstallConstants.INSTALL_MONITOR_NAME + ".log");
        // Create the install monitor
        installPlatform = new InstallPlatform(monTempFile.getAbsolutePath(), redistPath, pid,
                monitorLogPath.toOSString());
    } catch (Exception e) {
        fail(InstallMessages.Error_FailedInstallMonitor, e);
    }
}

From source file:edu.kit.dama.dataworkflow.impl.LocalExecutionHandler.java

/**
 * Execute the user application. This method will start a new process running
 * the prepared user application locally. The method will return as soon as
 * the application has terminated. An asnychronous monitoring task my check
 * whether the process is still running or not via {@link #getTaskStatus(edu.kit.dama.mdm.dataworkflow.DataWorkflowTask)
 * } This method will check the runningIndicator file '.RUNNING', which only
 * exists as long as the application is running.
 *
 * @param pTask The task whose application should be executed.
 *
 * @throws DataWorkflowProcessingException If either the startup or the
 * processing fails for any reason, or if the user application returns an exit
 * code != 0.//  w w w. java 2  s . c o m
 */
@Override
public void startUserApplication(DataWorkflowTask pTask) throws DataWorkflowProcessingException {
    //simply start the process...monitoring will be connected later
    File runningIndicator = getRunningIndicator(pTask);
    FileOutputStream fout = null;
    FileOutputStream ferr = null;
    File executablePath;

    try {
        executablePath = DataWorkflowHelper.getTaskMainExecutable(pTask);
        File executionBasePath = DataWorkflowHelper.getExecutionBasePath(pTask);
        File workingDirectory = DataWorkflowHelper.getTaskWorkingDirectory(executionBasePath);
        File tempDirectory = DataWorkflowHelper.getTaskTempDirectory(executionBasePath);
        File inputDirectory = DataWorkflowHelper.getTaskInputDirectory(executionBasePath);
        File outputDirectory = DataWorkflowHelper.getTaskOutputDirectory(executionBasePath);

        if (!executablePath.canExecute()) {
            LOGGER.debug("Executable at location {} seems not to be executable. Taking care of this...");
            if (executablePath.setExecutable(true)) {
                LOGGER.debug("Executable was successfully set to be executable.");
            } else {
                LOGGER.warn("Failed to set executable to be executable. Trying to continue.");
            }
        }

        String cmdLineString = executablePath.getAbsolutePath() + " "
                + pTask.getConfiguration().getApplicationArguments() + " " + pTask.getApplicationArguments();
        LOGGER.debug("Building up command array from string '{}'", cmdLineString);

        CommandLine cmdLine = CommandLine.parse(cmdLineString);
        DefaultExecutor executor = new DefaultExecutor();
        executor.setExitValue(0);
        Map<String, String> env = new HashMap<>();
        env.put("WORKING_DIR", workingDirectory.getAbsolutePath());
        env.put("TEMP_DIR", tempDirectory.getAbsolutePath());
        env.put("INPUT_DIR", inputDirectory.getAbsolutePath());
        env.put("OUTPUT_DIR", outputDirectory.getAbsolutePath());

        fout = new FileOutputStream(new File(tempDirectory, "stdout.log"));
        ferr = new FileOutputStream(new File(tempDirectory, "stderr.log"));
        LOGGER.debug("Setting stream handler for stdout and stderr.");
        executor.setStreamHandler(new PumpStreamHandler(fout, ferr));
        LOGGER.debug("Creating .RUNNING file for monitoring.");
        FileUtils.touch(runningIndicator);
        LOGGER.debug("Executing process.");
        int exitCode = executor.execute(cmdLine);
        if (exitCode != 0) {
            throw new DataWorkflowProcessingException(
                    "Execution returned exit code " + exitCode + ". See logfiles for details.");
        } else {
            LOGGER.debug("Process successfully finished with exit code {}", exitCode);
        }
    } catch (IOException | UnsupportedOperatingSystemException e) {
        throw new DataWorkflowProcessingException("Failed to start executable for task " + pTask.getId(), e);
    } finally {
        LOGGER.debug("Removing running indicator file {}", runningIndicator);
        FileUtils.deleteQuietly(runningIndicator);
        if (fout != null) {
            try {
                fout.close();
            } catch (IOException ex) {
            }
        }

        if (ferr != null) {
            try {
                ferr.close();
            } catch (IOException ex) {
            }
        }
    }
}

From source file:display.containers.FileManager.java

public static boolean copyFile(File from, File to) throws IOException {

    boolean created = to.createNewFile();

    if (created) {
        FileChannel fromChannel = null;
        FileChannel toChannel = null;
        try {/*  w  ww. ja  va2  s  . c o  m*/
            fromChannel = new FileInputStream(from).getChannel();
            toChannel = new FileOutputStream(to).getChannel();

            toChannel.transferFrom(fromChannel, 0, fromChannel.size());

            // set the flags of the to the same as the from
            to.setReadable(from.canRead());
            to.setWritable(from.canWrite());
            to.setExecutable(from.canExecute());
        } finally {
            if (fromChannel != null) {
                fromChannel.close();
            }
            if (toChannel != null) {
                toChannel.close();
            }
            return false;
        }
    }
    return created;
}

From source file:sh.tak.appbundler.CreateApplicationBundleMojo.java

/**
 * Bundle project as a Mac OS X application bundle.
 *
 * @throws MojoExecutionException If an unexpected error occurs during
 * packaging of the bundle.//from   w w  w.  j ava2s .  com
 */
public void execute() throws MojoExecutionException {

    // 1. Create and set up directories
    getLog().info("Creating and setting up the bundle directories");
    buildDirectory.mkdirs();

    File bundleDir = new File(buildDirectory, bundleName + ".app");
    bundleDir.mkdirs();

    File contentsDir = new File(bundleDir, "Contents");
    contentsDir.mkdirs();

    File resourcesDir = new File(contentsDir, "Resources");
    resourcesDir.mkdirs();

    File javaDirectory = new File(contentsDir, "Java");
    javaDirectory.mkdirs();

    File macOSDirectory = new File(contentsDir, "MacOS");
    macOSDirectory.mkdirs();

    // 2. Copy in the native java application stub
    getLog().info("Copying the native Java Application Stub");
    File launcher = new File(macOSDirectory, javaLauncherName);
    launcher.setExecutable(true);

    FileOutputStream launcherStream = null;
    try {
        launcherStream = new FileOutputStream(launcher);
    } catch (FileNotFoundException ex) {
        throw new MojoExecutionException("Could not copy file to directory " + launcher, ex);
    }

    InputStream launcherResourceStream = this.getClass().getResourceAsStream(javaLauncherName);
    try {
        IOUtil.copy(launcherResourceStream, launcherStream);
    } catch (IOException ex) {
        throw new MojoExecutionException(
                "Could not copy file " + javaLauncherName + " to directory " + macOSDirectory, ex);
    }

    // 3.Copy icon file to the bundle if specified
    if (iconFile != null) {
        File f = searchFile(iconFile);

        if (f != null && f.exists() && f.isFile()) {
            getLog().info("Copying the Icon File");
            try {
                FileUtils.copyFileToDirectory(f, resourcesDir);
            } catch (IOException ex) {
                throw new MojoExecutionException("Error copying file " + iconFile + " to " + resourcesDir, ex);
            }
        }
    }

    // 4. Resolve and copy in all dependencies from the pom
    getLog().info("Copying dependencies");
    List<String> files = copyDependencies(javaDirectory);
    if (additionalBundledClasspathResources != null && !additionalBundledClasspathResources.isEmpty()) {
        files.addAll(copyAdditionalBundledClasspathResources(javaDirectory, "lib",
                additionalBundledClasspathResources));
    }

    // 5. Check if JRE should be embedded. Check JRE path. Copy JRE
    if (jrePath != null) {
        File f = new File(jrePath);
        if (f.exists() && f.isDirectory()) {
            // Check if the source folder is a jdk-home
            File pluginsDirectory = new File(contentsDir, "PlugIns/JRE/Contents/Home/jre");
            pluginsDirectory.mkdirs();

            File sourceFolder = new File(jrePath, "Contents/Home");
            if (new File(jrePath, "Contents/Home/jre").exists()) {
                sourceFolder = new File(jrePath, "Contents/Home/jre");
            }

            try {
                getLog().info("Copying the JRE Folder from : [" + sourceFolder + "] to PlugIn folder: ["
                        + pluginsDirectory + "]");
                FileUtils.copyDirectoryStructure(sourceFolder, pluginsDirectory);
                File binFolder = new File(pluginsDirectory, "bin");
                //Setting execute permissions on executables in JRE
                for (String filename : binFolder.list()) {
                    new File(binFolder, filename).setExecutable(true, false);
                }

                new File(pluginsDirectory, "lib/jspawnhelper").setExecutable(true, false);
                embeddJre = true;
            } catch (IOException ex) {
                throw new MojoExecutionException("Error copying folder " + f + " to " + pluginsDirectory, ex);
            }
        } else {
            getLog().warn("JRE not found check jrePath setting in pom.xml");
        }
    }

    // 6. Create and write the Info.plist file
    getLog().info("Writing the Info.plist file");
    File infoPlist = new File(bundleDir, "Contents" + File.separator + "Info.plist");
    this.writeInfoPlist(infoPlist, files);

    // 7. Copy specified additional resources into the top level directory
    getLog().info("Copying additional resources");
    if (additionalResources != null && !additionalResources.isEmpty()) {
        this.copyResources(buildDirectory, additionalResources);
    }

    // 7. Make the stub executable
    if (!SystemUtils.IS_OS_WINDOWS) {
        getLog().info("Making stub executable");
        Commandline chmod = new Commandline();
        try {
            chmod.setExecutable("chmod");
            chmod.createArgument().setValue("755");
            chmod.createArgument().setValue(launcher.getAbsolutePath());

            chmod.execute();
        } catch (CommandLineException e) {
            throw new MojoExecutionException("Error executing " + chmod + " ", e);
        }
    } else {
        getLog().warn("The stub was created without executable file permissions for UNIX systems");
    }

    // 8. Create the DMG file
    if (generateDiskImageFile) {
        if (SystemUtils.IS_OS_MAC_OSX) {
            getLog().info("Generating the Disk Image file");
            Commandline dmg = new Commandline();
            try {
                // user wants /Applications symlink in the resulting disk image
                if (includeApplicationsSymlink) {
                    createApplicationsSymlink();
                }
                dmg.setExecutable("hdiutil");
                dmg.createArgument().setValue("create");
                dmg.createArgument().setValue("-srcfolder");
                dmg.createArgument().setValue(buildDirectory.getAbsolutePath());
                dmg.createArgument().setValue(diskImageFile.getAbsolutePath());

                try {
                    dmg.execute().waitFor();
                } catch (InterruptedException ex) {
                    throw new MojoExecutionException(
                            "Thread was interrupted while creating DMG " + diskImageFile, ex);
                } finally {
                    if (includeApplicationsSymlink) {
                        removeApplicationsSymlink();
                    }
                }
            } catch (CommandLineException ex) {
                throw new MojoExecutionException("Error creating disk image " + diskImageFile, ex);
            }

            if (diskImageInternetEnable) {
                getLog().info("Enabling the Disk Image file for internet");
                try {
                    Commandline internetEnableCommand = new Commandline();

                    internetEnableCommand.setExecutable("hdiutil");
                    internetEnableCommand.createArgument().setValue("internet-enable");
                    internetEnableCommand.createArgument().setValue("-yes");
                    internetEnableCommand.createArgument().setValue(diskImageFile.getAbsolutePath());

                    internetEnableCommand.execute();
                } catch (CommandLineException ex) {
                    throw new MojoExecutionException("Error internet enabling disk image: " + diskImageFile,
                            ex);
                }
            }
            projectHelper.attachArtifact(project, "dmg", null, diskImageFile);
        }
        if (SystemUtils.IS_OS_LINUX) {
            getLog().info("Generating the Disk Image file");
            Commandline linux_dmg = new Commandline();
            try {
                linux_dmg.setExecutable("genisoimage");
                linux_dmg.createArgument().setValue("-V");
                linux_dmg.createArgument().setValue(bundleName);
                linux_dmg.createArgument().setValue("-D");
                linux_dmg.createArgument().setValue("-R");
                linux_dmg.createArgument().setValue("-apple");
                linux_dmg.createArgument().setValue("-no-pad");
                linux_dmg.createArgument().setValue("-o");
                linux_dmg.createArgument().setValue(diskImageFile.getAbsolutePath());
                linux_dmg.createArgument().setValue(buildDirectory.getAbsolutePath());

                try {
                    linux_dmg.execute().waitFor();
                } catch (InterruptedException ex) {
                    throw new MojoExecutionException(
                            "Thread was interrupted while creating DMG " + diskImageFile, ex);
                }
            } catch (CommandLineException ex) {
                throw new MojoExecutionException(
                        "Error creating disk image " + diskImageFile + " genisoimage probably missing", ex);
            }
            projectHelper.attachArtifact(project, "dmg", null, diskImageFile);

        } else {
            getLog().warn("Disk Image file cannot be generated in non Mac OS X and Linux environments");
        }
    }

    getLog().info("App Bundle generation finished");
}

From source file:de.flapdoodle.embedmongo.extract.ZipExtractor.java

@Override
public void extract(RuntimeConfig runtime, File source, File destination, Pattern file) throws IOException {
    IProgressListener progressListener = runtime.getProgressListener();
    String progressLabel = "Extract " + source;
    progressListener.start(progressLabel);

    FileInputStream fin = new FileInputStream(source);
    BufferedInputStream in = new BufferedInputStream(fin);

    ZipArchiveInputStream zipIn = new ZipArchiveInputStream(in);
    try {/*from   w  w  w.  j a va  2 s.c o m*/
        ZipArchiveEntry entry;
        while ((entry = zipIn.getNextZipEntry()) != null) {
            if (file.matcher(entry.getName()).matches()) {
                //               System.out.println("File: " + entry.getName());
                if (zipIn.canReadEntryData(entry)) {
                    //                  System.out.println("Can Read: " + entry.getName());
                    long size = entry.getSize();
                    Files.write(zipIn, size, destination);
                    destination.setExecutable(true);
                    //                  System.out.println("DONE");
                    progressListener.done(progressLabel);
                }
                break;

            } else {
                //               System.out.println("SKIP File: " + entry.getName());
            }
        }

    } finally {
        zipIn.close();
    }

}

From source file:it.drwolf.ridire.index.sketch.AsyncSketchCreator.java

private void executeCQPQuery(File queryFile, boolean inverse) throws ExecuteException, IOException {
    Executor executor = new DefaultExecutor();
    File tempSh = File.createTempFile("ridireSH", ".sh");
    StringBuffer stringBuffer = new StringBuffer();
    stringBuffer.append("export LC_ALL=C\n");
    String corpusName = this.cqpCorpusName;
    if (inverse) {
        corpusName += "INV";
    }/*  w w w. ja  v  a2 s .c om*/
    stringBuffer.append(this.cqpExecutable + " -f " + queryFile.getAbsolutePath() + " -D " + corpusName + " -r "
            + this.cqpRegistry + "\n");
    FileUtils.writeStringToFile(tempSh, stringBuffer.toString());
    tempSh.setExecutable(true);
    CommandLine commandLine = new CommandLine(tempSh.getAbsolutePath());
    executor.execute(commandLine);
    FileUtils.deleteQuietly(tempSh);
}

From source file:autoupdater.FileDAO.java

/**
 * Untars a .tar./*  www.  java 2 s  . c  om*/
 *
 * @param fileToUntar
 * @return true if successful
 * @throws FileNotFoundException
 * @throws IOException
 */
private boolean untar(File fileToUntar) throws FileNotFoundException, IOException {
    boolean fileUntarred = false;
    String untarLocation = fileToUntar.getParentFile().getAbsolutePath();
    TarArchiveInputStream tarStream = null;
    try {
        tarStream = new TarArchiveInputStream(new FileInputStream(fileToUntar));
        BufferedReader bufferedTarReader = null;
        try {
            bufferedTarReader = new BufferedReader(new InputStreamReader(tarStream));
            ArchiveEntry entry;
            while ((entry = tarStream.getNextEntry()) != null) {
                byte[] buffer = new byte[8 * 1024];
                File tempFile = new File(String.format("%s/%s", untarLocation, entry.getName()));
                if (entry.isDirectory()) {
                    if (!tempFile.exists()) {
                        tempFile.mkdir();
                    }
                } else {
                    OutputStream output = new FileOutputStream(tempFile);
                    try {
                        int bytesRead;
                        while ((bytesRead = tarStream.read(buffer)) != -1) {
                            output.write(buffer, 0, bytesRead);
                        }
                    } finally {
                        output.close();
                    }
                    tempFile.setExecutable(true); // make sure the binary files can be executed
                }
            }
        } finally {
            if (bufferedTarReader != null) {
                bufferedTarReader.close();
            }
        }
    } finally {
        if (tarStream != null) {
            tarStream.close();
        }
    }
    return fileUntarred;
}

From source file:org.rapidbeans.rapidenv.Unpacker.java

private void setOutFileMode(final File file, final FileMode fileMode) {
    switch (PlatformHelper.getOsfamily()) {
    case linux:/*from   w  w w .j av a 2s.c  o  m*/
        final String smode = fileMode.toChmodStringFull();
        final SystemCommand cmd = new SystemCommand();
        cmd.setExecutable("chmod");
        cmd.addArgument(new Argument(smode));
        cmd.addArgument(new Argument(file.getAbsolutePath()));
        cmd.setSilent(true);
        final CommandExecutionResult result = cmd.execute();
        if (result.getReturncode() != 0) {
            throw new RapidEnvException(
                    "Error while trying to set mode \"" + smode + "\" for file: " + file.getAbsolutePath());
        }
        break;
    default:
        file.setReadable(fileMode.isUr() || fileMode.isGr() || fileMode.isOr());
        file.setWritable(fileMode.isUw() || fileMode.isGw() || fileMode.isOw());
        file.setExecutable(fileMode.isUx() || fileMode.isGx() || fileMode.isOx());
        break;
    }
}