/*
(non-Javadoc)

@see
net.jawr.web.resource.handler.reader.ResourceBrowser#isDirectory(java.
lang.String)
182212
@Override
	public boolean isDirectory(String dirPath) {
		String path = dirPath.replace('/', File.separatorChar);
		return new File(baseDir, path).isDirectory();
	}
399142
private void checkWorkingDir(File dir) {
        if (dir != null) {
            if (!dir.exists()) {
                throw new CommandLineException("Working directory \"" + dir.getAbsolutePath() + "\" does not exist!");
            } else if (!dir.isDirectory()) {
                throw new CommandLineException("Path \"" + dir.getAbsolutePath() + "\" does not specify a "
                        + "directory.");
            }
        }
    }
1182136
public boolean containsDirectoryOfType(Class<? extends Directory> type)
    {
        for (Directory dir : _directories) {
            if (type.isAssignableFrom(dir.getClass()))
                return true;
        }
        return false;
    }
526121
def _CheckIsDirectory(self, file_entry):
    
    if definitions.FILE_ENTRY_TYPE_DIRECTORY not in self._file_entry_types:
      return False
    return file_entry.IsDirectory()
1208899
@Override
  public boolean isDirectory(final Path f) throws IOException {
    if (stocatorPath.isTemporaryPath(f)) {
      return false;
    }
    final Path path = storageClient.qualify(f);
    try {
      FileStatus fileStatus = getFileStatus(path);
      LOG.debug("is directory: {} : {}", path.toString(), fileStatus.isDirectory());
      return fileStatus.isDirectory();
    } catch (FileNotFoundException e) {
      return false;
    }
  }
305357
@Override
    public void scanDirectoryNoResults(
            File directory, FileFilter fileFilter, Function<Resource, ?> fileProcessor) {
        this.scanDirectory(directory, null, fileFilter, fileProcessor);
    }
1052042
void createDirectory(Path path) throws IOException {
		if (Files.exists(path) && Files.isDirectory(path)) {
			return;
		}

		if (this.readOnly) {
			throw new FileNotFoundException(
					"The requested directory \""
							+ path.toString()
							+ "\" does not exist and we are in read-only mode, so it cannot be created.");
		}

		Files.createDirectory(path);
	}
802257
protected function isADirectory()
    {
        if (file_exists($this->path) && !is_dir($this->path)) {
            throw new  LocationIsADirectory(
                $this->getPath() .' already exists but is not a directory!',
                self::WRITABLE_IS_NOT_A_DIR_ERROR
            );
        }
        return true;
    }
485310
private void checkDirectory(File d, String dtype) {

        if (!d.isAbsolute()) {
            throw new IllegalArgumentException(dtype
                    + " directory must be an absolute path (" + d.getPath() + ")");
        }
        if (!d.exists()) {
            throw new IllegalArgumentException(dtype
                    + " directory does not exist (" + d.getPath() + ")");
        }
        if (!d.isDirectory()) {
            throw new IllegalArgumentException(dtype
                    + " directory value is not a directory (" + d.getPath() + ")");
        }

    }
58216
private boolean isDirectoryTraverse(StringBuffer path)
	{
			
		boolean directoryTraverse = false;
			
		String matchString = path.toString();
			
		//PM82876 Start
		if (WCCustomProperties.ALLOW_DOTS_IN_NAME) {
		    // The fileName can have .. , check for the failing conditions only.
		    if (matchString.indexOf("..") > -1) {
		        if( (matchString.indexOf("/../") > -1) || (matchString.indexOf("\\..\\") > -1) || 
		                        matchString.startsWith("../") || matchString.endsWith("/..") || 
		                        matchString.startsWith("..\\")|| matchString.endsWith("\\..")) 
		        {
		            directoryTraverse = true;
		            if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && logger.isLoggable(Level.FINE))
		                logger.logp(Level.FINE, CLASS_NAME, "isDirectoryTraverse", "bad path :" + matchString);
		        }
		    }    
		}
                else{//PM82876 End

                    /**
                     * Do not allow ".." to appear in a path as it allows one to serve files from anywhere within
                     * the file system.
                     * Also check to see if the path or URI ends with '/', '\', or '.' .
                     * PQ44346 - Allow files on DFS to be served.
                     */
                    if ( (matchString.lastIndexOf("..") != -1) && (!matchString.startsWith("/...") )) 
                    {
                        directoryTraverse = true;
                    }

                }
		if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled()&&logger.isLoggable (Level.FINE))
			logger.logp(Level.FINE, CLASS_NAME,"isDirectoryTraverse", "returning" + directoryTraverse + " , matchstring :" + matchString);
			
		return directoryTraverse;
	}
785152
private static String checkFolder(String directory) {
        File dir = new File(directory);
        if (dir.isFile()) {
            directory = dir.getParent();
        }
        createFolder(directory);
        return directory;
    }
1071281
@Reqiured
    public void setDumpDirectory(String dumpDirectory) {
        if (dumpDirectory != null && dumpDirectory.trim().length() > 0) {
            File file = new File(dumpDirectory);
            if (file.exists() || file.mkdirs()) {
                this.dumpDirectory = file;
            }
        }
    }
493756
protected boolean isDirectory(Resource directory) {
	if (directory.exists()) return directory.isDirectory();
	try {
	    directory.createDirectory(true);
	    return true;
	}
	catch (IOException e) {
	    e.printStackTrace(getErrWriter());
	}
	return false;
    }
49785
def _IsDirectory(parent, item):
  """"""
  return tf.io.gfile.isdir(os.path.join(parent, item))
872786
def is_dir(path):
    """"""
    try:
        return path.expanduser().absolute().is_dir()
    except AttributeError:
        return os.path.isdir(os.path.abspath(os.path.expanduser(str(path))))
34161
@SuppressWarnings("deprecation")
  private boolean isNamespace(Path dir) throws IOException {
    FileStatus[] stats = rootFileSystem.listStatus(dir, PathFilters.notHidden());
    for (FileStatus stat : stats) {
      if (stat.isDir() && isDataset(stat.getPath())) {
        return true;
      }
    }
    return false;
  }
702136
public static boolean deleteDirectory(final File dir) {
		boolean success = true;
		if (dir != null && dir.exists()) {
			try {
				if (dir.isDirectory()) {
					for (final File file : dir.listFiles()) {
						if(file == null) {
							return false;
						}
						if (!deleteDirectory(file)) {
							success = false;
							return success;
						}
					}
				}
				if (!dir.delete()) {
					success = false;
					return success;
				}
				return success;
			} catch (Exception e) {
				// Failed to delete files or directory
			}
		}
		return false;
	}