private static void setAttributeHidden(Path path) { try { Files.setAttribute(path, "dos:hidden", true); } catch (final IOException | UnsupportedOperationException e) { // Ignore. Maybe this is Linux or MacOS } }
private static Path initWorkingDir(ProjectDefinition module) { File workingDirAsFile = module.getWorkDir(); Path workingDir = workingDirAsFile.getAbsoluteFile().toPath().normalize(); if (SystemUtils.IS_OS_WINDOWS) { try { Files.setAttribute(workingDir, "dos:hidden", true, LinkOption.NOFOLLOW_LINKS); } catch (IOException e) { LOGGER.warn("Failed to set working directory hidden: {}", e.getMessage()); } } return workingDir; }
protected File createAppDirs(File localDir) throws IOException { if (localDir == null) { throw new RuntimeException("Unable to create app dir, local dir is null."); } File appDir = new File(localDir, Config.DIR_APPLICATION); File logDir = new File(appDir, Config.DIR_LOG); File cacheDir = new File(appDir, Config.DIR_CACHE); File databaseDir = new File(appDir, Config.DIR_DATABASE); File stateDir = new File(appDir, Config.DIR_STATE); appDir.mkdir(); logDir.mkdir(); cacheDir.mkdir(); databaseDir.mkdir(); stateDir.mkdir(); if (EnvironmentUtil.isWindows()) { Files.setAttribute(Paths.get(appDir.getAbsolutePath()), "dos:hidden", true); } return appDir; }
Files.setAttribute(filePath, "dos:readonly", dosAttrs.isReadOnly()); Files.setAttribute(filePath, "dos:hidden", dosAttrs.isHidden()); Files.setAttribute(filePath, "dos:archive", dosAttrs.isArchive()); Files.setAttribute(filePath, "dos:system", dosAttrs.isSystem());
Files.setAttribute(bFilePath, "dos:readonly", true);
FileStore store = Files.getFileStore(file2.toPath()); if (store.supportsFileAttributeView("dos")) { Files.setAttribute(file2.toPath(), "dos:hidden", true);
/** * Set a file hidden (on Windows) * * @param file * a {@link java.io.File} object. * @param hidden * a boolean. * @throws java.io.IOException * @since 4.1 */ public static void setHidden(File file, boolean hidden) throws IOException { Files.setAttribute(toPath(file), "dos:hidden", Boolean.valueOf(hidden), //$NON-NLS-1$ LinkOption.NOFOLLOW_LINKS); }
Files.setAttribute(currentTestResourceDir.resolve("second.txt"), "lastAccessTime", fileTime); Files.setAttribute(currentTestResourceDir.resolve("second.txt"), "lastModifiedTime", fileTime); logger.info(" ---> Creating a new file third.txt"); Files.write(currentTestResourceDir.resolve("third.txt"), "This is a third file".getBytes());
@Override public void setFileMode(Path path, int mode, LinkOption... linkOption) throws IOException { Files.setAttribute(path, "unix:mode", mode, linkOption); }
private static void setAttributeHidden(Path path) { try { Files.setAttribute(path, "dos:hidden", true); } catch (final IOException | UnsupportedOperationException e) { // Ignore. Maybe this is Linux or MacOS } }
@Override public boolean setReadable(final String fileName, final boolean readable, final boolean ownerOnly) { try { Path path = Paths.get(fileName); Files.setAttribute(path, "dos:readonly", readable); } catch (IOException e) { return false; } return true; }
/** * @param file * @param hidden * @throws IOException * @since 4.1 */ public static void setHidden(File file, boolean hidden) throws IOException { Files.setAttribute(file.toPath(), "dos:hidden", Boolean.valueOf(hidden), //$NON-NLS-1$ LinkOption.NOFOLLOW_LINKS); }
public static void setHidden(File path, boolean hidden) throws IOException { Path nioPath = path.toPath(); Files.setAttribute(nioPath, "dos:hidden", Boolean.valueOf(hidden), //$NON-NLS-1$ LinkOption.NOFOLLOW_LINKS); }
public void setMode(int mode, boolean propigateEvent) throws IOException { this.mode = mode; this.dirty = true; Path p = Paths.get(this.path); Files.setAttribute(p, "unix:mode", Integer.valueOf(mode), LinkOption.NOFOLLOW_LINKS); }
public void setLastModifiedTime(Path path, long mtime, LinkOption... linkOption) throws IOException { Files.setAttribute(path, "basic:lastModifiedTime", FileTime.from(mtime, TimeUnit.SECONDS), linkOption); }
protected void setFileTime(Path file, String view, String attribute, FileTime value, LinkOption... options) throws IOException { if (value == null) { return; } if (log.isDebugEnabled()) { log.debug("setFileTime({})[{}] {}:{}={}", getServerSession(), file, view, attribute, value); } Files.setAttribute(file, view + ":" + attribute, value, options); }
@Override public void setFileMode(Path path, int mode, LinkOption... linkOption) throws IOException { //i.e. (mode & 07000) != 0; boolean requiresUnix = (mode & (FileOps.S_ISUID | FileOps.S_ISGID | FileOps.S_ISVTX)) != 0; if (requiresUnix) { throw new IOException("unsupported operation"); } Set<PosixFilePermission> perms = modeToPosixFilePermissions(mode); Files.setAttribute(path, "posix:permissions", perms, linkOption); }
private static Path initWorkingDir(ProjectDefinition module) { File workingDirAsFile = module.getWorkDir(); Path workingDir = workingDirAsFile.getAbsoluteFile().toPath().normalize(); if (SystemUtils.IS_OS_WINDOWS) { try { Files.setAttribute(workingDir, "dos:hidden", true, LinkOption.NOFOLLOW_LINKS); } catch (IOException e) { LOGGER.warn("Failed to set working directory hidden: {}", e.getMessage()); } } return workingDir; }
@Test @Category( { Windows.class, DosAttributesT.class, Writable.class } ) public void testWindowsIsHidden() throws IOException { assertThat( Files.isHidden( fileTA() ) ).isFalse(); Files.getFileAttributeView( absTA(), DosFileAttributeView.class ).setHidden( true ); assertThat( Files.isHidden( fileTA() ) ).isTrue(); Files.setAttribute( absTA(), "dos:hidden", false ); assertThat( Files.isHidden( fileTA() ) ).isFalse(); }
@Override public void setGroup(Path path, Group group, LinkOption... linkOption) throws IOException { GroupPrincipal principal = getGroupPrincipalFrom(group.name()); if (principal == null) { setGroupId(path, group.id(), linkOption); } Files.setAttribute(path, "unix:group", principal, linkOption); }