Methods

getFullPath()

getFullPath(string  $path) : string

Get the full path of an item in the folder within owncloud's filesystem

Parameters

string $path

relative path of an item in the folder

Throws

\OCP\Files\NotPermittedException

Returns

string

getRelativePath()

getRelativePath(string  $path) : string

Get the path of an item in the folder relative to the folder

Parameters

string $path

absolute path of an item in the folder

Throws

\OCP\Files\NotFoundException

Returns

string

isSubNode()

isSubNode(\OCP\Files\Node  $node) : boolean

check if a node is a (grand-)child of the folder

Parameters

\OCP\Files\Node $node

Returns

boolean

getDirectoryListing()

getDirectoryListing() : array<mixed,\OCP\Files\Node>

get the content of this directory

Throws

\OCP\Files\NotFoundException

Returns

array<mixed,\OCP\Files\Node>

get()

get(string  $path) : \OCP\Files\Node

Get the node at $path

Parameters

string $path

relative path of the file or folder

Throws

\OCP\Files\NotFoundException

Returns

\OCP\Files\Node

nodeExists()

nodeExists(string  $path) : boolean

Check if a file or folder exists in the folder

Parameters

string $path

relative path of the file or folder

Returns

boolean

newFolder()

newFolder(string  $path) : \OCP\Files\Folder

Create a new folder

Parameters

string $path

relative path of the new folder

Throws

\OCP\Files\NotPermittedException

Returns

\OCP\Files\Folder

newFile()

newFile(string  $path) : \OCP\Files\File

Create a new file

Parameters

string $path

relative path of the new file

Throws

\OCP\Files\NotPermittedException

Returns

\OCP\Files\File

search()

search(string  $query) : array<mixed,\OCP\Files\Node>

search for files with the name matching $query

Parameters

string $query

Returns

array<mixed,\OCP\Files\Node>

searchByMime()

searchByMime(string  $mimetype) : array<mixed,\OCP\Files\Node>

search for files by mimetype $mimetype can either be a full mimetype (image/png) or a wildcard mimetype (image)

Parameters

string $mimetype

Returns

array<mixed,\OCP\Files\Node>

searchByTag()

searchByTag(string|integer  $tag, string  $userId) : array<mixed,\OCP\Files\Node>

search for files by tag

Parameters

string|integer $tag

tag name or tag id

string $userId

owner of the tags

Returns

array<mixed,\OCP\Files\Node>

getById()

getById(integer  $id) : array<mixed,\OCP\Files\Node>

get a file or folder inside the folder by it's internal id

Parameters

integer $id

Returns

array<mixed,\OCP\Files\Node>

getFreeSpace()

getFreeSpace() : integer

Get the amount of free space inside the folder

Returns

integer

isCreatable()

isCreatable() : boolean

Check whether new files or folders can be created inside this folder

Returns

boolean

getNonExistingName()

getNonExistingName(string  $name) : string

Add a suffix to the name in case the file exists

Parameters

string $name

Throws

\OCP\Files\NotPermittedException

Returns

string

move()

move(string  $targetPath) : \OCP\Files\Node

Move the file or folder to a new location

Parameters

string $targetPath

the absolute target path

Throws

\OCP\Files\NotPermittedException

Returns

\OCP\Files\Node

delete()

delete() : void

Delete the file or folder

copy()

copy(string  $targetPath) : \OCP\Files\Node

Cope the file or folder to a new location

Parameters

string $targetPath

the absolute target path

Returns

\OCP\Files\Node

touch()

touch(integer  $mtime = null) : void

Change the modified date of the file or folder If $mtime is omitted the current time will be used

Parameters

integer $mtime

(optional) modified date as unix timestamp

Throws

\OCP\Files\NotPermittedException

getStorage()

getStorage() : \OCP\Files\Storage

Get the storage the file or folder is storage on

Returns

\OCP\Files\Storage

getPath()

getPath() : string

Get the absolute path

Returns

string

getInternalPath()

getInternalPath() : string

Get the path relative to the storage

Returns

string

getId()

getId() : integer

Get the file id of the file or folder

Returns

integer

stat()

stat() : array

Get metadata of the file or folder The returned array contains the following values: - mtime - size

Returns

array

getMTime()

getMTime() : integer

Get the modified date of the file or folder as unix timestamp

Throws

\OCP\Files\InvalidPathException
\OCP\Files\NotFoundException

Returns

integer

getSize()

getSize() : integer

Get the size in bytes for the file or folder

Returns

integer

getEtag()

getEtag() : string

Get the Etag of the file or folder

Returns

string

getPermissions()

getPermissions() : integer

Get the permissions of the file or folder as bitmasked combination of the following constants \OCP\Constants::PERMISSION_CREATE \OCP\Constants::PERMISSION_READ \OCP\Constants::PERMISSION_UPDATE \OCP\Constants::PERMISSION_DELETE \OCP\Constants::PERMISSION_SHARE \OCP\Constants::PERMISSION_ALL

Returns

integer

isReadable()

isReadable() : boolean

Check if the file or folder is readable

Returns

boolean

isUpdateable()

isUpdateable() : boolean

Check if a file is writable

Returns

boolean

isDeletable()

isDeletable() : boolean

Check if a file or folder can be deleted

Returns

boolean

isShareable()

isShareable() : boolean

Check if a file or folder can be shared

Returns

boolean

getParent()

getParent() : \OCP\Files\Folder

Get the parent folder of the file or folder

Returns

\OCP\Files\Folder

getName()

getName() : string

Get the name of the file or folder

Returns

string

lock()

lock(integer  $type) 

Acquire a lock on this file or folder.

A shared (read) lock will prevent any exclusive (write) locks from being created but any number of shared locks can be active at the same time. An exclusive lock will prevent any other lock from being created (both shared and exclusive).

A locked exception will be thrown if any conflicting lock already exists

Note that this uses mandatory locking, if you acquire an exclusive lock on a file it will block all other operations for that file, even within the same php process.

Acquiring any lock on a file will also create a shared lock on all parent folders of that file.

Note that in most cases you won't need to manually manage the locks for any files you're working with, any filesystem operation will automatically acquire the relevant locks for that operation.

Parameters

integer $type

\OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE

Throws

\OCP\Lock\LockedException

changeLock()

changeLock(integer  $targetType) 

Check the type of an existing lock.

A shared lock can be changed to an exclusive lock is there is exactly one shared lock on the file, an exclusive lock can always be changed to a shared lock since there can only be one exclusive lock int he first place.

A locked exception will be thrown when these preconditions are not met. Note that this is also the case if no existing lock exists for the file.

Parameters

integer $targetType

\OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE

Throws

\OCP\Lock\LockedException

unlock()

unlock(integer  $type) 

Release an existing lock.

This will also free up the shared locks on any parent folder that were automatically acquired when locking the file.

Note that this method will not give any sort of error when trying to free a lock that doesn't exist.

Parameters

integer $type

\OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE

Throws

\OCP\Lock\LockedException

getMtime()

getMtime() : integer

Get the last modified date as timestamp for the file or folder

Returns

integer

getMimetype()

getMimetype() : string

Get the full mimetype of the file or folder i.e. 'image/png'

Returns

string

getMimePart()

getMimePart() : string

Get the first part of the mimetype of the file or folder i.e. 'image'

Returns

string

isEncrypted()

isEncrypted() : boolean

Check whether the file is encrypted

Returns

boolean

isShared()

isShared() : boolean

Check if a file or folder is shared

Returns

boolean

isMounted()

isMounted() : boolean

Check if a file or folder is mounted

Returns

boolean

getMountPoint()

getMountPoint() : \OCP\Files\Mount\IMountPoint

Get the mountpoint the file belongs to

Returns

\OCP\Files\Mount\IMountPoint

getOwner()

getOwner() : \OCP\IUser

Get the owner of the file

Returns

\OCP\IUser

getChecksum()

getChecksum() : string

Get the stored checksum for this file

Returns

string

getUserFolder()

getUserFolder(String  $userId) : \OCP\Files\Folder

Returns a view to user's files folder

Parameters

String $userId

user ID

Returns

\OCP\Files\Folder