View¶
-
class
OC\Files\
View
¶ - Class to provide access to ownCloud filesystem via a “view”, and methods forworking with files within that view (e.g. read, write, delete, etc.). Eachview is restricted to a set of directories via a virtual root. The default viewuses the currently logged in user’s data directory as root (parts ofOC_Filesystem are merely a wrapper for OC\Files\View).Apps that need to access files outside of the user data folders (to modify filesbelonging to a user other than the one currently logged in, for example) shoulduse this class directly rather than using OC_Filesystem, or making use of PHP’sbuilt-in file manipulation functions. This will ensure all hooks and proxiesare triggered correctly.Filesystem functions are not called directly; they are passed to the correct\OC\Files\Storage\Storage object
Source: lib/private/Files/View.php#87
Properties¶
-
protected static property
OC\Files\View::$
lockingProvider
¶ Source: lib/private/Files/View.php#94 Type: \OCP\Lock\ILockingProvider
Methods¶
-
public
OC\Files\View::
__construct
($root="")¶ Source: Parameters: - $root (string)
Throws: \Exception
If $root contains an invalid path
-
public
OC\Files\View::
getAbsolutePath
($path=/)¶ Source: lib/private/Files/View.php#125
-
public
OC\Files\View::
chroot
($fakeRoot)¶ - change the root to a fake root
Source: Parameters: - $fakeRoot (string)
Returns: bool | null
-
public
OC\Files\View::
getRoot
()¶ - get the fake root
Source: lib/private/Files/View.php#159 Returns: string
-
public
OC\Files\View::
getRelativePath
($path)¶ - get path relative to the root of the view
Source: Parameters: - $path (string)
Returns: string
-
public
OC\Files\View::
getMountPoint
($path)¶ - get the mountpoint of the storage object for a path( note: because a storage is not always mounted inside the fakeroot, thereturned mountpoint is relative to the absolute root of the filesystemand does not take the chroot into account )
Source: Parameters: - $path (string)
Returns: string
-
public
OC\Files\View::
getMount
($path)¶ - get the mountpoint of the storage object for a path( note: because a storage is not always mounted inside the fakeroot, thereturned mountpoint is relative to the absolute root of the filesystemand does not take the chroot into account )
Source: Parameters: - $path (string)
Returns:
-
public
OC\Files\View::
resolvePath
($path)¶ - resolve a path to a storage and internal path
Source: Parameters: - $path (string)
Returns: array an array consisting of the storage and the internal path
-
public
OC\Files\View::
getLocalFile
($path)¶ - return the path to a local version of the filewe need this because we can’t know if a file is stored local or not fromoutside the filestorage and for some purposes a local file is needed
Source: Parameters: - $path (string)
Returns: string
-
public
OC\Files\View::
getLocalFolder
($path)¶ Source: Parameters: - $path (string)
Returns: string
-
public
OC\Files\View::
mkdir
($path)¶ - the following functions operate with arguments and return values identicalto those of their PHP built-in equivalents. Mostly they are merely wrappersfor \OC\Files\Storage\Storage via basicOperation().
Source: lib/private/Files/View.php#271
-
protected
OC\Files\View::
removeMount
($mount, $path)¶ - remove mount point
Source: Parameters: - $mount (
OC\Files\Mount\MoveableMount
) - $path (string) relative to data/
Returns: bool
- $mount (
-
public
OC\Files\View::
disableCacheUpdate
()¶ Source: lib/private/Files/View.php#311
-
public
OC\Files\View::
enableCacheUpdate
()¶ Source: lib/private/Files/View.php#315
-
protected
OC\Files\View::
writeUpdate
($storage, $internalPath, $time=null)¶ Source: lib/private/Files/View.php#319
-
protected
OC\Files\View::
removeUpdate
($storage, $internalPath)¶ Source: lib/private/Files/View.php#328
-
protected
OC\Files\View::
renameUpdate
($sourceStorage, $targetStorage, $sourceInternalPath, $targetInternalPath)¶ Source: lib/private/Files/View.php#334
-
public
OC\Files\View::
rmdir
($path)¶ Source: Parameters: - $path (string)
Returns: bool | mixed
-
public
OC\Files\View::
opendir
($path)¶ Source: Parameters: - $path (string)
Returns: resource
-
public
OC\Files\View::
is_dir
($path)¶ Source: Parameters: - $path (string)
Returns: bool | mixed
-
public
OC\Files\View::
is_file
($path)¶ Source: Parameters: - $path (string)
Returns: bool | mixed
-
public
OC\Files\View::
stat
($path)¶ Source: Parameters: - $path (string)
Returns: mixed
-
public
OC\Files\View::
filetype
($path)¶ Source: Parameters: - $path (string)
Returns: mixed
-
public
OC\Files\View::
filesize
($path)¶ Source: Parameters: - $path (string)
Returns: mixed
-
public
OC\Files\View::
readfile
($path)¶ Source: Parameters: - $path (string)
Returns: bool | mixed
Throws:
-
public
OC\Files\View::
readfilePart
($path, $from, $to)¶ Source: Parameters: - $path (string)
- $from (int)
- $to (int)
Returns: bool | mixed
Throws: Throws: Throws: Throws:
-
public
OC\Files\View::
isCreatable
($path)¶ Source: Parameters: - $path (string)
Returns: mixed
-
public
OC\Files\View::
isReadable
($path)¶ Source: Parameters: - $path (string)
Returns: mixed
-
public
OC\Files\View::
isUpdatable
($path)¶ Source: Parameters: - $path (string)
Returns: mixed
-
public
OC\Files\View::
isDeletable
($path)¶ Source: Parameters: - $path (string)
Returns: bool | mixed
-
public
OC\Files\View::
isSharable
($path)¶ Source: Parameters: - $path (string)
Returns: mixed
-
public
OC\Files\View::
file_exists
($path)¶ Source: Parameters: - $path (string)
Returns: bool | mixed
-
public
OC\Files\View::
filemtime
($path)¶ Source: Parameters: - $path (string)
Returns: mixed
-
public
OC\Files\View::
touch
($path, $mtime=null)¶ Source: Parameters: - $path (string)
- $mtime (int | string)
Returns: bool
-
public
OC\Files\View::
file_get_contents
($path)¶ Source: Parameters: - $path (string)
Returns: mixed
Throws:
-
protected
OC\Files\View::
emit_file_hooks_pre
($exists, $path, &$run)¶ Source: Parameters: - $exists (bool)
- $path (string)
- $run (bool)
-
protected
OC\Files\View::
emit_file_hooks_post
($exists, $path)¶ Source: Parameters: - $exists (bool)
- $path (string)
-
public
OC\Files\View::
file_put_contents
($path, $data)¶ Source: Parameters: - $path (string)
- $data (string | resource)
Returns: bool | mixed
Throws:
-
public
OC\Files\View::
unlink
($path)¶ Source: Parameters: - $path (string)
Returns: bool | mixed
-
public
OC\Files\View::
deleteAll
($directory)¶ Source: Parameters: - $directory (string)
Returns: bool | mixed
-
public
OC\Files\View::
rename
($path1, $path2)¶ - Rename/move a file or folder from the source path to target path.
Source: Parameters: - $path1 (string) source path
- $path2 (string) target path
Returns: bool | mixed
Throws:
-
public
OC\Files\View::
copy
($path1, $path2, $preserveMtime=false)¶ - Copy a file/folder from the source path to target path
Source: Parameters: - $path1 (string) source path
- $path2 (string) target path
- $preserveMtime (bool) whether to preserve mtime on the copy
Returns: bool | mixed
-
public
OC\Files\View::
fopen
($path, $mode)¶ Source: Parameters: - $path (string)
- $mode (string) ‘r’ or ‘w’
Returns: resource
Throws:
-
public
OC\Files\View::
toTmpFile
($path)¶ Source: Parameters: - $path (string)
Returns: bool | string
Throws:
-
public
OC\Files\View::
fromTmpFile
($tmpFile, $path)¶ Source: Parameters: - $tmpFile (string)
- $path (string)
Returns: bool | mixed
Throws:
-
public
OC\Files\View::
getMimeType
($path)¶ Source: Parameters: - $path (string)
Returns: mixed
Throws:
-
public
OC\Files\View::
hash
($type, $path, $raw=false)¶ Source: Parameters: - $type (string)
- $path (string)
- $raw (bool)
Returns: bool | null | string
-
public
OC\Files\View::
free_space
($path=/)¶ Source: Parameters: - $path (string)
Returns: mixed
Throws:
-
public
OC\Files\View::
hasUpdated
($path, $time)¶ - check if a file or folder has been updated since $time
Source: Parameters: - $path (string)
- $time (int)
Returns: bool
-
public
OC\Files\View::
getFileInfo
($path, $includeMountPoints=true)¶ - get the filesystem info
Source: Parameters: - $path (string)
- $includeMountPoints (bool | string) true to add mountpoint sizes,
‘ext’ to add only ext storage mount point sizes. Defaults to true. defaults to true
Returns: \OC\Files\FileInfo
| bool False if file does not exist
-
public
OC\Files\View::
getDirectoryContent
($directory, $mimetype_filter="")¶ - get the content of a directory
Source: Parameters: - $directory (string) path under datadirectory
- $mimetype_filter (string) limit returned content to this mimetype or mimepart
Returns:
-
public
OC\Files\View::
putFileInfo
($path, $data)¶ - change file metadata
Source: Parameters: - $path (string)
- $data (array |
\OCP\Files\FileInfo
)
Returns: int returns the fileid of the updated file
-
public
OC\Files\View::
search
($query)¶ - search for files with the name matching $query
Source: Parameters: - $query (string)
Returns:
-
public
OC\Files\View::
searchRaw
($query)¶ - search for files with the name matching $query
Source: Parameters: - $query (string)
Returns:
-
public
OC\Files\View::
searchByMime
($mimetype)¶ - search for files by mimetype
Source: Parameters: - $mimetype (string)
Returns:
-
public
OC\Files\View::
searchByTag
($tag, $userId)¶ - search for files by tag
Source: Parameters: - $tag (string | int) name or tag id
- $userId (string) owner of the tags
Returns:
-
public
OC\Files\View::
getOwner
($path)¶ - Get the owner for a file or folder
Source: Parameters: - $path (string)
Returns: string the user id of the owner
Throws:
-
public
OC\Files\View::
getETag
($path)¶ - get the ETag for a file or folder
Source: Parameters: - $path (string)
Returns: string
-
public
OC\Files\View::
getPath
($id, $storageId=null)¶ - Get the path of a file by id, relative to the viewNote that the resulting path is not guarantied to be unique for the id, multiple paths can point to the same file
Source: Parameters: - $id (int)
- $storageId (int | null)
Returns: string
Throws:
-
public
OC\Files\View::
verifyPath
($path, $fileName)¶ Source: Parameters: - $path (string)
- $fileName (string)
Throws:
-
public
OC\Files\View::
changeLock
($path, $type, $lockMountPoint=false)¶ - Change the lock type
Source: Parameters: - $path (string) the path of the file to lock, relative to the view
- $type (int) OCPLockILockingProvider::LOCK_SHARED or OCPLockILockingProvider::LOCK_EXCLUSIVE
- $lockMountPoint (bool) true to lock the mount point, false to lock the attached mount/storage
Returns: bool False if the path is excluded from locking, true otherwise
Throws: \OCP\Lock\LockedException
if the path is already locked
-
public
OC\Files\View::
lockFile
($path, $type, $lockMountPoint=false)¶ - Lock a path and all its parents up to the root of the view
Source: Parameters: - $path (string) the path of the file to lock relative to the view
- $type (int) OCPLockILockingProvider::LOCK_SHARED or OCPLockILockingProvider::LOCK_EXCLUSIVE
- $lockMountPoint (bool) true to lock the mount point, false to lock the attached mount/storage
Returns: bool False if the path is excluded from locking, true otherwise
Throws:
-
public
OC\Files\View::
unlockFile
($path, $type, $lockMountPoint=false)¶ - Unlock a path and all its parents up to the root of the view
Source: Parameters: - $path (string) the path of the file to lock relative to the view
- $type (int) OCPLockILockingProvider::LOCK_SHARED or OCPLockILockingProvider::LOCK_EXCLUSIVE
- $lockMountPoint (bool) true to lock the mount point, false to lock the attached mount/storage
Returns: bool False if the path is excluded from locking, true otherwise
Throws:
-
protected
OC\Files\View::
shouldLockFile
($path)¶ - Only lock files in data/user/files/
Source: Parameters: - $path (string) Absolute path to the file/folder we try to (un)lock
Returns: bool
-
public
OC\Files\View::
getPathRelativeToFiles
($absolutePath)¶ - Shortens the given absolute path to be relative to“$user/files”.
Source: Parameters: - $absolutePath (string) absolute path which is under “files”
Returns: string path relative to “files” with trimmed slashes or null if the path was NOT relative to files
Throws: \InvalidArgumentException
if the given path was not under “files”Since: 8.1.0
-
public
OC\Files\View::
getUidAndFilename
($filename)¶ Source: Parameters: - $filename (string)
Returns: array
Throws: Throws: Throws: Throws: