Java Code Examples for java.nio.file.Files#isHidden()

The following examples show how to use java.nio.file.Files#isHidden() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SExprFileAttribute.java    From skUtilities with GNU General Public License v3.0 6 votes vote down vote up
@Override
@Nullable
protected Boolean[] get(Event e) {
  Path pth = Paths.get(skUtilities.getDefaultPath(path.getSingle(e)));
  try {
    if (ty == 0) {
      return new Boolean[]{Files.isReadable(pth)};
    } else if (ty == 1) {
      return new Boolean[]{Files.isWritable(pth)};
    } else {
      return new Boolean[]{Files.isHidden(pth)};
    }
  } catch (Exception x) {
    skUtilities.prSysE("File: '" + pth + "' doesn't exist, or is not readable!", getClass().getSimpleName(), x);
  }
  return null;
}
 
Example 2
Source File: Solution.java    From JavaRushTasks with MIT License 5 votes vote down vote up
public Solution(String pathToFile) {

        try {
            Path filePath = Paths.get(pathToFile);
            fileData = new ConcreteFileData(Files.isHidden(filePath), Files.isExecutable(filePath),
                    Files.isDirectory(filePath), Files.isWritable(filePath));

        } catch (Exception e) {
            fileData = new NullFileData (e);
        }
    }
 
Example 3
Source File: NbMavenProjectImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private boolean isOtherRoot(Path dir) throws IOException {
    if (!dir.toFile().isDirectory() || Files.isHidden(dir)) {
        return false;
    }

    // Walk through the other roots and check if a parent of this dir is
    // already available in other roots to avoid folder duplication
    for (Path path : otherRoots) {
        if (dir.startsWith(path)) {
            return false;
        }
    }
    return true;
}
 
Example 4
Source File: PathInfo.java    From CloverETL-Engine with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public Boolean isHidden() {
	if (Files.exists(path)) {
		try {
			return Files.isHidden(path);
		} catch (IOException ioe) {}
	}
	return null;
}
 
Example 5
Source File: ModulePath.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * Returns true if the given file exists and is a hidden file
 */
private boolean isHidden(Path file) {
    try {
        return Files.isHidden(file);
    } catch (IOException ioe) {
        return false;
    }
}
 
Example 6
Source File: OpenAPI2MarkupConverter.java    From swagger2markup with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a OpenAPI2MarkupConverter.Builder using a local Path.
 *
 * @param swaggerPath the local Path
 * @return a OpenAPI2MarkupConverter
 */
public static Builder from(Path swaggerPath) {
    Validate.notNull(swaggerPath, "swaggerPath must not be null");
    if (Files.notExists(swaggerPath)) {
        throw new IllegalArgumentException(String.format("swaggerPath does not exist: %s", swaggerPath));
    }
    try {
        if (Files.isHidden(swaggerPath)) {
            throw new IllegalArgumentException("swaggerPath must not be a hidden file");
        }
    } catch (IOException e) {
        throw new RuntimeException("Failed to check if swaggerPath is a hidden file", e);
    }
    return new Builder(swaggerPath);
}
 
Example 7
Source File: ModulePatcher.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns true if the given file exists and is a hidden file
 */
private boolean isHidden(Path file) {
    try {
        return Files.isHidden(file);
    } catch (IOException ioe) {
        return false;
    }
}
 
Example 8
Source File: Swagger2MarkupConverter.java    From swagger2markup with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a Swagger2MarkupConverter.Builder using a local Path.
 *
 * @param swaggerPath the local Path
 * @return a Swagger2MarkupConverter
 */
public static Builder from(Path swaggerPath) {
    Validate.notNull(swaggerPath, "swaggerPath must not be null");
    if (Files.notExists(swaggerPath)) {
        throw new IllegalArgumentException(String.format("swaggerPath does not exist: %s", swaggerPath));
    }
    try {
        if (Files.isHidden(swaggerPath)) {
            throw new IllegalArgumentException("swaggerPath must not be a hidden file");
        }
    } catch (IOException e) {
        throw new RuntimeException("Failed to check if swaggerPath is a hidden file", e);
    }
    return new Builder(swaggerPath);
}
 
Example 9
Source File: FaultyFileSystem.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean isHidden(Path file) throws IOException {
    triggerEx(file, "isHidden");
    return Files.isHidden(unwrap(file));
}
 
Example 10
Source File: FaultyFileSystem.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean isHidden(Path file) throws IOException {
    triggerEx(file, "isHidden");
    return Files.isHidden(unwrap(file));
}
 
Example 11
Source File: Kanzi.java    From kanzi with Apache License 2.0 4 votes vote down vote up
public static void createFileList(String target, List<Path> files) throws IOException
{
   if (target == null)
      return;
   
   Path root = Paths.get(target);
   
   if (Files.exists(root) == false) 
      throw new IOException("Cannot access input file '"+root+"'");
   
   if ((Files.isRegularFile(root) == true) && (Files.isHidden(root) == true))
      throw new IOException("Cannot access input file '"+root+"'");
   
   if (Files.isRegularFile(root) == true)
   {
      if (target.charAt(0) != '.')
         files.add(root);
      
      return;
   }       
    
   // If not a regular file and not a directory (a link ?), fail 
   if (Files.isDirectory(root) == false)
      throw new IOException("Invalid file type '"+root+"'");
   
   String suffix = File.separator + ".";
   String strRoot = root.toString();
   boolean isRecursive = !strRoot.endsWith(suffix); 
   
   if (isRecursive == true)
   {
      if (strRoot.endsWith(File.separator) == false)
         root = Paths.get(strRoot+File.separator);
   }
   else
   {
      // Remove suffix
      root = Paths.get(strRoot.substring(0, strRoot.length()-1));
   }
   
   try (DirectoryStream<Path> stream = Files.newDirectoryStream(root)) 
   {
      for (Path entry: stream) 
      {
         if ((Files.exists(entry) == false) || (Files.isHidden(entry) == true))
            continue;

         if ((Files.isRegularFile(entry) == true) && (String.valueOf(entry.getFileName()).startsWith(".") == false))
            files.add(entry);
         else if ((isRecursive == true) && (Files.isDirectory(entry) == true))
            createFileList(entry.toString(), files);
      }
   } 
   catch (DirectoryIteratorException e) 
   {
     throw e.getCause();
   }
}
 
Example 12
Source File: FolderChecker.java    From hmftools with GNU General Public License v3.0 4 votes vote down vote up
@NotNull
static DirectoryStream.Filter<Path> getHiddenFilesFilter() {
    return entry -> !Files.isHidden(entry);
}
 
Example 13
Source File: FaultyFileSystem.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean isHidden(Path file) throws IOException {
    triggerEx(file, "isHidden");
    return Files.isHidden(unwrap(file));
}
 
Example 14
Source File: FaultyFileSystem.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean isHidden(Path file) throws IOException {
    triggerEx(file, "isHidden");
    return Files.isHidden(unwrap(file));
}
 
Example 15
Source File: FaultyFileSystem.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean isHidden(Path file) throws IOException {
    triggerEx(file, "isHidden");
    return Files.isHidden(unwrap(file));
}
 
Example 16
Source File: EncryptedFileSystemProvider.java    From encfs4j with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isHidden(Path file) throws IOException {
	return Files.isHidden(EncryptedFileSystem.dismantle(file));
}
 
Example 17
Source File: FaultyFileSystem.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean isHidden(Path file) throws IOException {
    triggerEx(file, "isHidden");
    return Files.isHidden(unwrap(file));
}
 
Example 18
Source File: EncryptedFileSystemProvider.java    From encfs4j with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isHidden(Path file) throws IOException {
	return Files.isHidden(EncryptedFileSystem.dismantle(file));
}
 
Example 19
Source File: FaultyFileSystem.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean isHidden(Path file) throws IOException {
    triggerEx(file, "isHidden");
    return Files.isHidden(unwrap(file));
}
 
Example 20
Source File: FaultyFileSystem.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean isHidden(Path file) throws IOException {
    triggerEx(file, "isHidden");
    return Files.isHidden(unwrap(file));
}