Check if file can be written.

@return bool
335404
public function writable()
    {
        return file_exists($this->filename) ? is_writable($this->filename) && is_file($this->filename) : $this->writableDir(\dirname($this->filename));
    }
41545
public function isWritable()
    {
        return in_array($this->mode, [
            StreamMode::WRITE_CLEAN,
            StreamMode::WRITE_END,
            StreamMode::CREATE_READ_WRITE,
            StreamMode::CREATE_WRITE,
            StreamMode::READ_WRITE,
            StreamMode::READ_WRITE_CLEAN,
            StreamMode::READ_WRITE_END,
        ]);
    }
1202963
private function isStreamWritable($path)
    {
        $stream = $this->getStreamByPathScheme($path);
        if ($stream instanceof StreamInterface) {
            return $stream->isWritable();
        }

        return false;
    }
285968
protected function checkFile($writable = true)
    {
        if(!$this->fileExists()) throw NonExistentFileException::createForFileDoesNotExists($this->getFilePath());
        if(!is_readable($this->file_path)) throw NotReadableFileException::createForNotReadable($this->getFilePath());
        if($writable)
        {
            if(!is_writable($this->file_path)) throw NotWritableFileException::createForNotWritable($this->getFilePath());
        }
    }
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;
	}
}
1290460
public boolean canWrite()
    {
        if ( ! _strutsConfigFile.canWrite() )
        {
            return false;
        }
        
        try
        {
            //
            // This appears to be the only way to predict whether the file can actually be
            // written to; it may be that canWrite() returns true, but the file permissions
            // (NTFS only?) will cause an exception to be thrown.
            //
            new FileOutputStream( _strutsConfigFile, true ).close();
        }
        catch ( FileNotFoundException e )
        {
            return false;
        }
        catch ( IOException e )
        {
            return false;
        }
        
        return true;
    }
358852
public function isAvailable()
    {
        return \file_exists($this->cacheDir) && \is_dir($this->cacheDir) && \is_writable($this->cacheDir);
    }
901008
def is_writable(filename):
    
    if not os.path.exists(filename):
        parentdir = os.path.dirname(filename)
        return os.path.isdir(parentdir) and os.access(parentdir, os.W_OK)
    return os.path.isfile(filename) and os.access(filename, os.W_OK)
593110
public static function isWritable($path = false) {

        if($path && self::isFile($path) && is_writable($path)) {

            return true;
        }

        return false;
    }
374469
public function isWritable($path)
	{
		$path = Util::normalizePath($path);

		return (bool) $this->adapter->isWritable($path);
	}
680368
public function isWritable()
    {
        if ($this->stream) {
            $meta = $this->getMetadata();
            $writableModes = ['r+', 'w', 'w+', 'a', 'a+', 'x', 'x+', 'c', 'c+'];
            foreach ($writableModes as $mode) {
                if (strpos($meta['mode'], $mode) === 0) {
                    return true;
                }
            }
        }
        return false;
    }
269041
public function isWritableByCurrentUser()
    {
        if ($this->hasConfigValue()) {
            return false;
        }

        if (isset($this->hasWritePermission)) {
            return $this->hasWritePermission;
        }

        // performance improvement, do not detect this in __construct otherwise likely rather "big" query to DB.
        $this->hasWritePermission = Piwik::hasUserSuperUserAccess();

        return $this->hasWritePermission;
    }
692436
protected function isWritable($file)
    {
        return (bool) ((file_exists($file) && is_writable($file)) || (!file_exists($file) && is_writable(dirname($file))));
    }
1324159
public function isWritable()
    {
        if (is_resource($this->stream) === true) {
            $metadata = $this->getMetadata();
            return Validator::isWritable($metadata);
        }
        return false;
    }
682963
public function delete(): bool
    {
        if (is_file($this->path)) {
            if (is_writable($this->path)) {
                return unlink($this->path);
            }
            throw new FileException('Cannot delete file, because ('.$this->path.') is not writable', FileException::NOT_WRITEABLE);
        }

        return true;
    }
209257
public function is_supported()
	{
		if ( ! is_dir($this->_cache_path))
		{
			if (!mkdir($this->_cache_path, 0777, false))
			{
				return false;
			}
		}

		return is_really_writable($this->_cache_path);
	}
1019323
protected function canAccess()
    {
        $replacingFile = $this->getReplacingFile();
        if ($replacingFile === null) {
            return false;
        }
        $replacingFilePermissions = new Checker($replacingFile);

        return $replacingFilePermissions->canEditFileContents();
    }