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

The following examples show how to use java.nio.file.Files#isHidden() . These examples are extracted from open source projects. 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
@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 Project: JavaRushTasks   File: Solution.java    License: 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 Project: netbeans   File: NbMavenProjectImpl.java    License: 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 Project: Bytecoder   File: ModulePath.java    License: 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 5
/**
 * 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 6
/**
 * 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 7
/**
 * 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 8
@Override
public Boolean isHidden() {
	if (Files.exists(path)) {
		try {
			return Files.isHidden(path);
		} catch (IOException ioe) {}
	}
	return null;
}
 
Example 9
@Override
public boolean isHidden(Path file) throws IOException {
    triggerEx(file, "isHidden");
    return Files.isHidden(unwrap(file));
}
 
Example 10
@Override
public boolean isHidden(Path file) throws IOException {
    triggerEx(file, "isHidden");
    return Files.isHidden(unwrap(file));
}
 
Example 11
@Override
public boolean isHidden(Path file) throws IOException {
    triggerEx(file, "isHidden");
    return Files.isHidden(unwrap(file));
}
 
Example 12
@Override
public boolean isHidden(Path file) throws IOException {
	return Files.isHidden(EncryptedFileSystem.dismantle(file));
}
 
Example 13
@Override
public boolean isHidden(Path file) throws IOException {
    triggerEx(file, "isHidden");
    return Files.isHidden(unwrap(file));
}
 
Example 14
@Override
public boolean isHidden(Path file) throws IOException {
	return Files.isHidden(EncryptedFileSystem.dismantle(file));
}
 
Example 15
@Override
public boolean isHidden(Path file) throws IOException {
    triggerEx(file, "isHidden");
    return Files.isHidden(unwrap(file));
}
 
Example 16
@Override
public boolean isHidden(Path file) throws IOException {
    triggerEx(file, "isHidden");
    return Files.isHidden(unwrap(file));
}
 
Example 17
@Override
public boolean isHidden(Path file) throws IOException {
    triggerEx(file, "isHidden");
    return Files.isHidden(unwrap(file));
}
 
Example 18
@NotNull
static DirectoryStream.Filter<Path> getHiddenFilesFilter() {
    return entry -> !Files.isHidden(entry);
}
 
Example 19
Source Project: kanzi   File: Kanzi.java    License: 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 20
@Override
public boolean isHidden(Path file) throws IOException {
    triggerEx(file, "isHidden");
    return Files.isHidden(unwrap(file));
}