istanbul ignore next 
Checks if a directory is writable, returning a boolean or throwing an exception, depending on the arguments.
@param {string} dir The directory to check.
@returns {boolean} Whether or not the directory is writable.
481425
function isWritable(dir) {
	debug('checking if ' + dir + ' is writable');
	try {
		if (!fs.existsSync(dir)) {
			debug(' - it does not exist yet, attempting to create it');
			fs.mkdirSync(dir);
		}
		if (fs.accessSync) {
			fs.accessSync(dir, fs.W_OK);
		} else {
			debug(' - fs.accessSync is not available, falling back to manual write detection');
			fs.writeFileSync(path.join(dir, '.foo'), 'foo');
			assert.equal(fs.readFileSync(path.join(dir, '.foo'), 'UTF-8'), 'foo');
			fs.unlinkSync(path.join(dir, '.foo'));
		}
		debug(' - yes, it is writable');
		return true;
	} catch (exc) {
		debug(' - no, it is not writable: ', exc);
		return false;
	}
}
18087
function isWritable(obj, key) {
  var descriptor = Object.getOwnPropertyDescriptor(obj, key);
  return isUndefined(obj[key]) || descriptor && descriptor.writable
}
958460
function isWritable(obj, key) {
      var descriptor = getPropDescriptor(obj, key);
      return isUndefined(obj[key]) || descriptor && descriptor.writable
    }
939997
def is_writable(path):
    

    if os.access(path, os.W_OK):
        LOGGER.debug("> '{0}' path is writable.".format(path))
        return True
    else:
        LOGGER.debug("> '{0}' path is not writable.".format(path))
        return False
130981
function isExist(dir) {
  dir = path.normalize(dir);
  try {
    fs.accessSync(dir, fs.R_OK);
    return true;
  } catch (e) {
    return false;
  }
}
1161945
private boolean canWriteErrorDir(File errorPath) {
        String[] files = errorPath.list();
        if (files != null && files.length > FILE_CONTENT_LOG_MAX_FILE_NUM) {
            long now = System.currentTimeMillis();
            int delNum = 0;
            for (String filename : files) {
                File errImg = new File(errorPath, filename);
                if (now - errImg.lastModified() > EXPIRED_PERIOD) {
                    errImg.delete();
                    delNum++;
                }
            }

            if (files.length - delNum <= FILE_CONTENT_LOG_MAX_FILE_NUM) {
                return true;
            }

            return false;
        }

        return true;
    }
124294
function isWritable(p) {
    if (!fs.existsSync(p)) {
        return false;
    }
    let stats = fs.statSync(p);
    let mode = stats.mode;
    let uid = process.getuid ? process.getuid() : 0;
    let gid = process.getgid ? process.getgid() : 0;
    let owner = uid === stats.uid;
    let group = gid === stats.gid;
    return !!(owner && (mode & parseInt('00200', 8)) ||
        group && (mode & parseInt('00020', 8)) ||
        (mode & parseInt('00002', 8)));
}
785152
private static String checkFolder(String directory) {
        File dir = new File(directory);
        if (dir.isFile()) {
            directory = dir.getParent();
        }
        createFolder(directory);
        return directory;
    }
1101107
function assertIsDirectory(path) {
  try {
    if (!fs.lstatSync(path).isDirectory()) {
      console.log('Path "' + path + '" is not a directory.');
      process.exit();
    }
  } catch (e) {
    console.log('Directory "' + path + '" could not be found.');
    process.exit();
  }
}
740872
function createDirectory(directory) {
  if (!directory) {
    throw new Error('A directory must be passed to be created.');
  }
  const statObject = getStatObject(directory);
  if (statObject && statObject.isFile()) {
    throw new Error(`The directory to create '${directory}' is a file.`);
  }
  fse.ensureDirSync(directory);
}
865962
function isDirectory(filePath) {
	var isDir = false;
	try {
		var absolutePath = path.resolve(filePath);
		isDir = fs.lstatSync(absolutePath).isDirectory();
	} catch (e) {
		isDir = e.code === 'ENOENT';
	}
	return isDir;
}
1125075
final public static function isDirEmpty($dir)
    {
        if (!is_readable($dir)) {
            return (null);
        }
        $handle = opendir($dir);
        while (false !== ($entry = readdir($handle))) {
            if ($entry != "." && $entry != "..") {
                return (false);
            }
        }
        return (true);
    }
904167
function ensureDir(dir) {
        try {
            if (!fs_1.existsSync(dir))
                fs_1.mkdirSync(dir);
            return true;
        }
        catch (ex) {
            return false;
        }
    }
757447
function isWritable()
    {
        if (!$this->_assertUsable())
            return false;

        $mode = $this->getMetadata('mode');
        return in_array($mode, self::$readWriteHash['write']);
    }
634416
def is_readable_dir(path):
  """"""
  return os.path.isdir(path) and os.access(path, os.R_OK) and os.access(path, os.X_OK)
673178
@Override
	public boolean cd(String directory) {
		boolean flag = true;
		try {
			flag = client.changeWorkingDirectory(directory);
		} catch (IOException e) {
			throw new FtpException(e);
		}
		return flag;
	}
1204091
private function isDirectoryWritableOrCanBeCreated($directory)
    {
        // If the directory exists, check if it's writable
        if (is_dir($directory)) {
            return is_writable($directory);
        }

        // If the directory doesn't exist, check if the parent directory is writable so we can create it
        return $this->isDirectoryWritableOrCanBeCreated(dirname($directory));
    }