Methods

getEtag()

getEtag() : string

Get the Etag of the file or folder The Etag is an string id used to detect changes to a file or folder, every time the file or folder is changed the Etag will change to

Throws

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

Returns

string

getSize()

getSize() : integer

Get the size of the file or folder in bytes

Throws

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

Returns

integer

getMtime()

getMtime() : integer

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

Returns

integer

getName()

getName() : string

Get the filename of the file or folder

Returns

string

getInternalPath()

getInternalPath() : string

Get the path of the file or folder relative to the mountpoint of it's storage

Returns

string

getPath()

getPath() : string

Get the full path of the file or folder

Returns

string

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

getStorage()

getStorage() : \OCP\Files\Storage

Get the storage backend the file or folder is stored on

Throws

\OCP\Files\NotFoundException

Returns

\OCP\Files\Storage

getId()

getId() : integer

Get the internal file id for the file or folder

Throws

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

Returns

integer

isEncrypted()

isEncrypted() : boolean

Check whether the file is encrypted

Returns

boolean

getPermissions()

getPermissions() : integer

Get the permissions of the file or folder as a combination of one or more of the following constants: - \OCP\Constants::PERMISSION_READ - \OCP\Constants::PERMISSION_UPDATE - \OCP\Constants::PERMISSION_CREATE - \OCP\Constants::PERMISSION_DELETE - \OCP\Constants::PERMISSION_SHARE

Throws

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

Returns

integer

isReadable()

isReadable() : boolean

Check if the file or folder is readable

Throws

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

Returns

boolean

isUpdateable()

isUpdateable() : boolean

Check if the file or folder is writable

Throws

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

Returns

boolean

isCreatable()

isCreatable() : boolean

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

Returns

boolean

isDeletable()

isDeletable() : boolean

Check if the file or folder is deletable

Throws

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

Returns

boolean

isShareable()

isShareable() : boolean

Check if the file or folder is shareable

Throws

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

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

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

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

getParent()

getParent() : \OCP\Files\Folder

Get the parent folder of the file or folder

Returns

\OCP\Files\Folder

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