Determine if a directory is acceptable for building.

    A directory is suitable if any of the following are true:
      - it doesn't exist
      - it is empty
      - it contains an existing build cache
323400
def _is_cache_dir_appropriate(cache_dir, cache_file):
    
    if os.path.exists(cache_dir):
        files = os.listdir(cache_dir)
        if cache_file in files:
            return True
        return not bool(files)
    return True
1359576
public function isDir($directory)
    {
        $pwd = $this->ftp->pwd();

        if ($pwd === false) {
            throw new FtpException('Unable to resolve the current directory');
        }

        if (@$this->ftp->chdir($directory)) {
            $this->ftp->chdir($pwd);
            return true;
        }

        $this->ftp->chdir($pwd);

        return false;
    }
523700
def find_build_dir(path, build="_build"):
    """"""
    path = os.path.abspath(os.path.expanduser(path))
    contents = os.listdir(path)
    filtered_contents = [directory for directory in contents
                            if os.path.isdir(os.path.join(path, directory))]

    if build in filtered_contents:
        return os.path.join(path, build)
    else:
        if path == os.path.realpath("/"):
            return None
        else:
            return find_build_dir("{0}/..".format(path), build)
822047
def clean_directories!
      all_build_files = File.join(@app.config[:build_dir], '**', '*')

      empty_directories = Dir[all_build_files].select do |d|
        File.directory?(d)
      end

      empty_directories.each do |d|
        remove_file d, force: true if Pathname(d).children.empty?
      end
    end
1161963
public static void checkValidDir(final File dir) {
        checkNotNull("dir", dir);
        if (!dir.exists()) {
            throw new IllegalArgumentException("The directory '" + dir + "' does not exist!");
        }
        if (!dir.isDirectory()) {
            throw new IllegalArgumentException("The name '" + dir + "' is not a directory!");
        }
    }
1356187
def check_dirs():
    
    dirs = [MAIN_DIR, TEMP_DIR, DOWNLOAD_DIR, SAVESTAT_DIR]
    for directory in dirs:
        if directory.exists() and not directory.is_dir():
            raise FileExistsError(str(directory.resolve()) + " cannot be used as a directory.")
801730
def ensure_dir_exists(directory):
    """"""
    if directory and not os.path.exists(directory):
        os.makedirs(directory)
1288831
def directory_is_present(self, directory_path):
        
        p = self.p(directory_path)
        if not os.path.exists(p):
            return False
        if not os.path.isdir(p):
            raise IOError("%s is not a directory" % directory_path)
        return True
1093241
def setup_build_path(build_path):
    
    if os.path.isdir(build_path):
        fname = os.path.join(build_path, 'CMakeCache.txt')
        if os.path.exists(fname):
            sys.stderr.write('aborting setup\n')
            sys.stderr.write(
                'build directory {0} which contains CMakeCache.txt already exists\n'.
                format(build_path))
            sys.stderr.write(
                'remove the build directory and then rerun setup\n')
            sys.exit(1)
    else:
        os.makedirs(build_path, 0o755)
983152
def is_directory (self):
        
        filename = self.get_os_filename()
        return os.path.isdir(filename) and not os.path.islink(filename)
1329686
public boolean isDirectory() throws SmbException {
        if( getUncPath0().length() == 1 ) {
            return true;
        }
        if (!exists()) return false;
        return ( attributes & ATTR_DIRECTORY ) == ATTR_DIRECTORY;
    }
752930
def find_config():
    """"""
    previous = ""
    current = os.getcwd()
    while previous != current:
        check_path = os.path.join(current, "build.cache")
        if os.path.isfile(check_path):
            return check_path
        else:
            previous = current
            current = os.path.dirname(current)
    raise Exception("Can't find build cache")
304325
protected boolean isBuildNeeded()
            throws MojoExecutionException {
        File outDir = getOutputDirectory();
        return hasNoPreviousBuild(outDir) || hasArgumentsChanged(outDir) ||
                hasSourcesChanged(outDir) || hasNonWeavedClassesChanged(outDir);

    }
161172
def is_base_dir(d):
    ''''''
    if not dir_param_valid(d): # pragma: no cover
        raise 
    else:
        mfn = os.path.join(d,'s2') #marker name. it must be a directory.
        return os.path.isdir(mfn)
258352
def prepare_build_dir(self):
        ''''''
        self.build_dir = self.get_build_dir()
        self.common_dir = self.get_common_dir()
        copy_files(join(self.bootstrap_dir, 'build'), self.build_dir)
        copy_files(join(self.common_dir, 'build'), self.build_dir,
                   override=False)
        if self.ctx.symlink_java_src:
            info('Symlinking java src instead of copying')
            shprint(sh.rm, '-r', join(self.build_dir, 'src'))
            shprint(sh.mkdir, join(self.build_dir, 'src'))
            for dirn in listdir(join(self.bootstrap_dir, 'build', 'src')):
                shprint(sh.ln, '-s', join(self.bootstrap_dir, 'build', 'src', dirn),
                        join(self.build_dir, 'src'))
        with current_directory(self.build_dir):
            with open('project.properties', 'w') as fileh:
                fileh.write('target=android-{}'.format(self.ctx.android_api))
707023
def contains(bank, key, cachedir):
    '''
    
    '''
    if key is None:
        base = os.path.join(cachedir, os.path.normpath(bank))
        return os.path.isdir(base)
    else:
        keyfile = os.path.join(cachedir, os.path.normpath(bank), '{0}.p'.format(key))
        return os.path.isfile(keyfile)
396601
def make_directory_if_needed(directory_path):
    
    if os.path.exists(directory_path):
        if not os.path.isdir(directory_path):
            raise OSError("Path is not a directory:", directory_path)
    else:
        os.makedirs(directory_path)