Common

class OC\Files\Storage\Common
Storage backend class for providing common filesystem operation methods
which are not storage-backend specific.
\OC\Files\Storage\Common is never used directly; it is extended by all other
storage backends, where its methods may be overridden, and additional
(backend-specific) methods are defined.

Some \OC\Files\Storage\Common methods call functions which are first defined
in classes which extend it, e.g. $this->stat() .
Source:lib/private/Files/Storage/Common.php#78
Implements:OC\Files\Storage\Storage OCP\Files\Storage\ILockingStorage OCP\Files\Storage\IWriteStreamStorage
Used traits:OC\Files\Storage\LocalTempFileTrait

Properties

protected static property OC\Files\Storage\Common::$cache
Source:lib/private/Files/Storage/Common.php#81
protected static property OC\Files\Storage\Common::$scanner
Source:lib/private/Files/Storage/Common.php#82
protected static property OC\Files\Storage\Common::$watcher
Source:lib/private/Files/Storage/Common.php#83
protected static property OC\Files\Storage\Common::$propagator
Source:lib/private/Files/Storage/Common.php#84
protected static property OC\Files\Storage\Common::$storageCache
Source:lib/private/Files/Storage/Common.php#85
protected static property OC\Files\Storage\Common::$updater
Source:lib/private/Files/Storage/Common.php#86
protected static property OC\Files\Storage\Common::$mountOptions
Source:lib/private/Files/Storage/Common.php#88
protected static property OC\Files\Storage\Common::$owner
Source:lib/private/Files/Storage/Common.php#89

Methods

public OC\Files\Storage\Common::__construct($parameters)
Source:lib/private/Files/Storage/Common.php#94
protected OC\Files\Storage\Common::remove($path)
Remove a file or folder
Source:

lib/private/Files/Storage/Common.php#103

Parameters:
  • $path (string)
Returns:

bool

public OC\Files\Storage\Common::is_dir($path)
Source:lib/private/Files/Storage/Common.php#113
public OC\Files\Storage\Common::is_file($path)
Source:lib/private/Files/Storage/Common.php#117
public OC\Files\Storage\Common::filesize($path)
Source:lib/private/Files/Storage/Common.php#121
public OC\Files\Storage\Common::isReadable($path)
Source:lib/private/Files/Storage/Common.php#134
public OC\Files\Storage\Common::isUpdatable($path)
Source:lib/private/Files/Storage/Common.php#140
public OC\Files\Storage\Common::isCreatable($path)
Source:lib/private/Files/Storage/Common.php#147
public OC\Files\Storage\Common::isDeletable($path)
Source:lib/private/Files/Storage/Common.php#154
public OC\Files\Storage\Common::isSharable($path)
Source:lib/private/Files/Storage/Common.php#162
public OC\Files\Storage\Common::getPermissions($path)
Source:lib/private/Files/Storage/Common.php#166
public OC\Files\Storage\Common::filemtime($path)
Source:lib/private/Files/Storage/Common.php#186
public OC\Files\Storage\Common::file_get_contents($path)
Source:lib/private/Files/Storage/Common.php#195
public OC\Files\Storage\Common::file_put_contents($path, $data)
Source:lib/private/Files/Storage/Common.php#205
public OC\Files\Storage\Common::rename($path1, $path2)
Source:lib/private/Files/Storage/Common.php#213
public OC\Files\Storage\Common::copy($path1, $path2)
Source:lib/private/Files/Storage/Common.php#220
public OC\Files\Storage\Common::getMimeType($path)
Source:lib/private/Files/Storage/Common.php#246
public OC\Files\Storage\Common::hash($type, $path, $raw=false)
Source:lib/private/Files/Storage/Common.php#256
public OC\Files\Storage\Common::search($query)
Source:lib/private/Files/Storage/Common.php#264
public OC\Files\Storage\Common::getLocalFile($path)
Source:lib/private/Files/Storage/Common.php#268
protected OC\Files\Storage\Common::searchInDir($query, $dir="")
Source:

lib/private/Files/Storage/Common.php#298

Parameters:
  • $query (string)
  • $dir (string)
Returns:

array

public OC\Files\Storage\Common::hasUpdated($path, $time)
check if a file or folder has been updated since $time
The method is only used to check if the cache needs to be updated. Storage backends that don’t support checking
the mtime should always return false here. As a result storage implementations that always return false expect
exclusive access to the backend and will not pick up files that have been added in a way that circumvents
ownClouds filesystem.
Source:

lib/private/Files/Storage/Common.php#330

Parameters:
  • $path (string)
  • $time (int)
Returns:

bool

public OC\Files\Storage\Common::getCache($path="", $storage=null)
Source:lib/private/Files/Storage/Common.php#334
public OC\Files\Storage\Common::getScanner($path="", $storage=null)
Source:lib/private/Files/Storage/Common.php#344
public OC\Files\Storage\Common::getWatcher($path="", $storage=null)
Source:lib/private/Files/Storage/Common.php#354
public OC\Files\Storage\Common::getPropagator($storage=null)
get a propagator instance for the cache
Source:lib/private/Files/Storage/Common.php#372
Parameters:
Returns:\OC\Files\Cache\Propagator
public OC\Files\Storage\Common::getUpdater($storage=null)
Source:lib/private/Files/Storage/Common.php#383
public OC\Files\Storage\Common::getStorageCache($storage=null)
Source:lib/private/Files/Storage/Common.php#393
public OC\Files\Storage\Common::getOwner($path)
get the owner of a path
Source:

lib/private/Files/Storage/Common.php#409

Parameters:
  • $path (string) The path to get the owner
Returns:

string | bool uid or false

public OC\Files\Storage\Common::getETag($path)
get the ETag for a file or folder
Source:

lib/private/Files/Storage/Common.php#423

Parameters:
  • $path (string)
Returns:

string

public OC\Files\Storage\Common::cleanPath($path)
clean a path, i.e. remove all redundant ‘.’ and ‘.
.’
making sure that it can’t point to higher than ‘/’
Source:

lib/private/Files/Storage/Common.php#434

Parameters:
  • $path (string) The path to clean
Returns:

string cleaned path

public OC\Files\Storage\Common::test()
Test a storage for availability
Source:lib/private/Files/Storage/Common.php#456
Returns:bool
public OC\Files\Storage\Common::free_space($path)
get the free space in the storage
Source:

lib/private/Files/Storage/Common.php#476

Parameters:
  • $path (string)
Returns:

int | bool

public OC\Files\Storage\Common::isLocal()
Source:lib/private/Files/Storage/Common.php#483
public OC\Files\Storage\Common::instanceOfStorage($class)
Check if the storage is an instance of $class or is a wrapper for a storage that is an instance of $class
Source:

lib/private/Files/Storage/Common.php#495

Parameters:
  • $class (string)
Returns:

bool

public OC\Files\Storage\Common::getDirectDownload($path)
A custom storage implementation can return an url for direct download of a give file.
For now the returned array can hold the parameter url - in future more attributes might follow.
Source:

lib/private/Files/Storage/Common.php#511

Parameters:
  • $path (string)
Returns:

array | bool

public OC\Files\Storage\Common::verifyPath($path, $fileName)
Source:lib/private/Files/Storage/Common.php#519
Throws:\OCP\Files\InvalidPathException
protected OC\Files\Storage\Common::verifyPosixPath($fileName)
Source:

lib/private/Files/Storage/Common.php#556

Parameters:
  • $fileName (string)
Throws:

\OCP\Files\InvalidPathException

public OC\Files\Storage\Common::setMountOptions($options)
Source:

lib/private/Files/Storage/Common.php#586

Parameters:
  • $options (array)
public OC\Files\Storage\Common::getMountOption($name, $default=null)
Source:

lib/private/Files/Storage/Common.php#595

Parameters:
  • $name (string)
  • $default (mixed)
Returns:

mixed

public OC\Files\Storage\Common::copyFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath, $preserveMtime=false)
Source:

lib/private/Files/Storage/Common.php#606

Parameters:
Returns:

bool

public OC\Files\Storage\Common::moveFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath)
Source:

lib/private/Files/Storage/Common.php#671

Parameters:
Returns:

bool

public OC\Files\Storage\Common::getMetaData($path)
Source:lib/private/Files/Storage/Common.php#703
public OC\Files\Storage\Common::acquireLock($path, $type, $provider)
Source:

lib/private/Files/Storage/Common.php#735

Parameters:
  • $path (string)
  • $type (int) OCPLockILockingProvider::LOCK_SHARED or OCPLockILockingProvider::LOCK_EXCLUSIVE
  • $provider (OCP\Lock\ILockingProvider)
Throws:

\OCP\Lock\LockedException

public OC\Files\Storage\Common::releaseLock($path, $type, $provider)
Source:

lib/private/Files/Storage/Common.php#767

Parameters:
  • $path (string)
  • $type (int) OCPLockILockingProvider::LOCK_SHARED or OCPLockILockingProvider::LOCK_EXCLUSIVE
  • $provider (OCP\Lock\ILockingProvider)
Throws:

\OCP\Lock\LockedException

public OC\Files\Storage\Common::changeLock($path, $type, $provider)
Source:

lib/private/Files/Storage/Common.php#799

Parameters:
  • $path (string)
  • $type (int) OCPLockILockingProvider::LOCK_SHARED or OCPLockILockingProvider::LOCK_EXCLUSIVE
  • $provider (OCP\Lock\ILockingProvider)
Throws:

\OCP\Lock\LockedException

public OC\Files\Storage\Common::getAvailability()
Source:lib/private/Files/Storage/Common.php#834
Returns:array [ available, last_checked ]
public OC\Files\Storage\Common::setAvailability($isAvailable)
Source:

lib/private/Files/Storage/Common.php#841

Parameters:
  • $isAvailable (bool)
public OC\Files\Storage\Common::needsPartFile()
Source:lib/private/Files/Storage/Common.php#848
Returns:bool
public OC\Files\Storage\Common::writeStream($path, $stream, $size=null)
fallback implementation
Source:

lib/private/Files/Storage/Common.php#860

Parameters:
  • $path (string)
  • $stream (resource)
  • $size (int)
Returns:

int

public OC\Files\Storage\Common::getDirectoryContent($directory)
Source:lib/private/Files/Storage/Common.php#877