Node
extends
FileInfo
in
Interface Node
Tags
Table of Contents
Constants
- BLACKLIST_FILES_REGEX = '\.(part|filepart)$'
- MIMETYPE_FOLDER = 'httpd/unix-directory'
- SPACE_NOT_COMPUTED = -1
- SPACE_UNKNOWN = -2
- SPACE_UNLIMITED = -3
- TYPE_FILE = 'file'
- TYPE_FOLDER = 'dir'
Methods
- changeLock() : mixed
- Check the type of an existing lock.
- copy() : Node
- Copy the file or folder to a new location
- delete() : void
- Delete the file or folder
- getChecksum() : string
- Get the stored checksum(s) for this file
- getCreationTime() : int
- Get the creation date as unix timestamp
- 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
- getExtension() : string
- Get the extension of the file
- getId() : int
- Get the internal file id for the file or folder
- getInternalPath() : string
- Get the path of the file or folder relative to the mountpoint of it's storage
- getMetadata() : array<string, int|string|bool|float|array<string|int, string>|array<string|int, int>>
- Get the metadata, if available
- getMimePart() : string
- Get the first part of the mimetype of the file or folder i.e. 'image'
- getMimetype() : string
- Get the full mimetype of the file or folder i.e. 'image/png'
- getMountPoint() : IMountPoint
- Get the mountpoint the file belongs to
- getMtime() : int
- Get the last modified date as timestamp for the file or folder
- getMTime() : int
- Get the modified date of the file or folder as unix timestamp
- getName() : string
- Get the filename of the file or folder
- getOwner() : IUser|null
- Get the owner of the file
- getParent() : Folder
- Get the parent folder of the file or folder
- getParentId() : int
- Get the fileid or the parent folder or -1 if this item has no parent folder (because it is the root)
- getPath() : string
- Get the full path of the file or folder
- getPermissions() : int
- 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
- getSize() : int|float
- Get the size of the file or folder in bytes
- getStorage() : IStorage
- Get the storage backend the file or folder is stored on
- getType() : string
- Check whether this is a file or a folder
- getUploadTime() : int
- Get the upload date as unix timestamp
- isCreatable() : bool
- Check whether new files or folders can be created inside this folder
- isDeletable() : bool
- Check if the file or folder is deletable
- isEncrypted() : bool
- Check whether the node is encrypted.
- isMounted() : bool
- Check if a file or folder is mounted
- isReadable() : bool
- Check if the file or folder is readable
- isShareable() : bool
- Check if the file or folder is shareable
- isShared() : bool
- Check if a file or folder is shared
- isUpdateable() : bool
- Check if the file or folder is writable
- lock() : mixed
- Acquire a lock on this file or folder.
- move() : Node
- Move the file or folder to a new location
- stat() : array<string|int, mixed>
- Get metadata of the file or folder The returned array contains the following values: - mtime - size
- touch() : void
- Change the modified date of the file or folder If $mtime is omitted the current time will be used
- unlock() : mixed
- Release an existing lock.
Constants
BLACKLIST_FILES_REGEX
public
mixed
BLACKLIST_FILES_REGEX
= '\.(part|filepart)$'
Tags
MIMETYPE_FOLDER
public
mixed
MIMETYPE_FOLDER
= 'httpd/unix-directory'
Tags
SPACE_NOT_COMPUTED
public
mixed
SPACE_NOT_COMPUTED
= -1
Tags
SPACE_UNKNOWN
public
mixed
SPACE_UNKNOWN
= -2
Tags
SPACE_UNLIMITED
public
mixed
SPACE_UNLIMITED
= -3
Tags
TYPE_FILE
public
mixed
TYPE_FILE
= 'file'
Tags
TYPE_FOLDER
public
mixed
TYPE_FOLDER
= 'dir'
Tags
Methods
changeLock()
Check the type of an existing lock.
public
changeLock(int $targetType) : mixed
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
- $targetType : int
-
\OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
Tags
copy()
Copy the file or folder to a new location
public
copy(string $targetPath) : Node
Parameters
- $targetPath : string
-
the absolute target path
Tags
Return values
Nodedelete()
Delete the file or folder
public
delete() : void
Tags
getChecksum()
Get the stored checksum(s) for this file
public
getChecksum() : string
Checksums are stored in the format TYPE:CHECKSUM, here may be multiple checksums separated by a single space e.g. MD5:d3b07384d113edec49eaa6238ad5ff00 SHA1:f1d2d2f924e986ac86fdf7b36c94bcdf32beec15
Tags
Return values
stringgetCreationTime()
Get the creation date as unix timestamp
public
getCreationTime() : int
If the creation time is not known, 0 will be returned
creation time is not set automatically by the server and is generally only available for files uploaded by the sync clients
Tags
Return values
intgetEtag()
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
public
getEtag() : string
Tags
Return values
stringgetExtension()
Get the extension of the file
public
getExtension() : string
Tags
Return values
stringgetId()
Get the internal file id for the file or folder
public
getId() : int
Tags
Return values
intgetInternalPath()
Get the path of the file or folder relative to the mountpoint of it's storage
public
getInternalPath() : string
Tags
Return values
stringgetMetadata()
Get the metadata, if available
public
getMetadata() : array<string, int|string|bool|float|array<string|int, string>|array<string|int, int>>
Tags
Return values
array<string, int|string|bool|float|array<string|int, string>|array<string|int, int>>getMimePart()
Get the first part of the mimetype of the file or folder i.e. 'image'
public
getMimePart() : string
Tags
Return values
stringgetMimetype()
Get the full mimetype of the file or folder i.e. 'image/png'
public
getMimetype() : string
Tags
Return values
stringgetMountPoint()
Get the mountpoint the file belongs to
public
getMountPoint() : IMountPoint
Tags
Return values
IMountPointgetMtime()
Get the last modified date as timestamp for the file or folder
public
getMtime() : int
Tags
Return values
intgetMTime()
Get the modified date of the file or folder as unix timestamp
public
getMTime() : int
Tags
Return values
intgetName()
Get the filename of the file or folder
public
getName() : string
Tags
Return values
stringgetOwner()
Get the owner of the file
public
getOwner() : IUser|null
Tags
Return values
IUser|nullgetParent()
Get the parent folder of the file or folder
public
getParent() : Folder
Tags
Return values
FoldergetParentId()
Get the fileid or the parent folder or -1 if this item has no parent folder (because it is the root)
public
getParentId() : int
Tags
Return values
intgetPath()
Get the full path of the file or folder
public
getPath() : string
Tags
Return values
stringgetPermissions()
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
public
getPermissions() : int
Tags
Return values
intgetSize()
Get the size of the file or folder in bytes
public
getSize([bool $includeMounts = true ]) : int|float
Parameters
- $includeMounts : bool = true
Tags
Return values
int|floatgetStorage()
Get the storage backend the file or folder is stored on
public
getStorage() : IStorage
Tags
Return values
IStoragegetType()
Check whether this is a file or a folder
public
getType() : string
Tags
Return values
string —\OCP\Files\FileInfo::TYPE_FILE|\OCP\Files\FileInfo::TYPE_FOLDER
getUploadTime()
Get the upload date as unix timestamp
public
getUploadTime() : int
If the upload time is not known, 0 will be returned
Upload time will be set automatically by the server for files uploaded over DAV files created by Nextcloud apps generally do not have an the upload time set
Tags
Return values
intisCreatable()
Check whether new files or folders can be created inside this folder
public
isCreatable() : bool
Tags
Return values
boolisDeletable()
Check if the file or folder is deletable
public
isDeletable() : bool
Tags
Return values
boolisEncrypted()
Check whether the node is encrypted.
public
isEncrypted() : bool
If it is a file, then it is server side encrypted. If it is a folder, then it is end-to-end encrypted.
Tags
Return values
boolisMounted()
Check if a file or folder is mounted
public
isMounted() : bool
Tags
Return values
boolisReadable()
Check if the file or folder is readable
public
isReadable() : bool
Tags
Return values
boolisShareable()
Check if the file or folder is shareable
public
isShareable() : bool
Tags
Return values
boolisShared()
Check if a file or folder is shared
public
isShared() : bool
Tags
Return values
boolisUpdateable()
Check if the file or folder is writable
public
isUpdateable() : bool
Tags
Return values
boollock()
Acquire a lock on this file or folder.
public
lock(int $type) : mixed
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
- $type : int
-
\OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
Tags
move()
Move the file or folder to a new location
public
move(string $targetPath) : Node
Parameters
- $targetPath : string
-
the absolute target path
Tags
Return values
Nodestat()
Get metadata of the file or folder The returned array contains the following values: - mtime - size
public
stat() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>touch()
Change the modified date of the file or folder If $mtime is omitted the current time will be used
public
touch([int $mtime = null ]) : void
Parameters
- $mtime : int = null
-
(optional) modified date as unix timestamp
Tags
unlock()
Release an existing lock.
public
unlock(int $type) : mixed
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
- $type : int
-
\OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE