Node

interface OCP\Files\Node
Interface Node
Implemented by:OC\Files\Node\Node
Source:lib/public/Files/Node.php#46
Parent:OCP\Files\FileInfo

Methods

public OCP\Files\Node::move($targetPath)
Move the file or folder to a new location
Source:

lib/public/Files/Node.php#58

Parameters:
  • $targetPath (string) the absolute target path
Returns:

\OCP\Files\Node

Throws:

\OCP\Files\NotFoundException

Throws:

\OCP\Files\NotPermittedException if move not allowed or failed

Throws:

\OCP\Lock\LockedException

Throws:

\OCP\Files\InvalidPathException

Throws:

\OCP\Files\NotFoundException

Throws:

\OCP\Files\NotPermittedException if move not allowed or failed

Throws:

\OCP\Lock\LockedException

Throws:

\OCP\Files\InvalidPathException

Throws:

\OCP\Files\NotFoundException

Throws:

\OCP\Files\NotPermittedException if move not allowed or failed

Throws:

\OCP\Lock\LockedException

Throws:

\OCP\Files\InvalidPathException

Throws:

\OCP\Files\NotFoundException

Throws:

\OCP\Files\NotPermittedException if move not allowed or failed

Throws:

\OCP\Lock\LockedException

Throws:

\OCP\Files\InvalidPathException

Since:

6.0.0

public OCP\Files\Node::delete()
Delete the file or folder
Source:lib/public/Files/Node.php#69
Returns:void
Throws:\OCP\Files\NotPermittedException
Throws:\OCP\Files\InvalidPathException
Throws:\OCP\Files\NotFoundException
Throws:\OCP\Files\NotPermittedException
Throws:\OCP\Files\InvalidPathException
Throws:\OCP\Files\NotFoundException
Throws:\OCP\Files\NotPermittedException
Throws:\OCP\Files\InvalidPathException
Throws:\OCP\Files\NotFoundException
Since:6.0.0
public OCP\Files\Node::copy($targetPath)
Cope the file or folder to a new location
Source:

lib/public/Files/Node.php#78

Parameters:
  • $targetPath (string) the absolute target path
Returns:

\OCP\Files\Node

Since:

6.0.0

public OCP\Files\Node::touch($mtime=null)
Change the modified date of the file or folder
If $mtime is omitted the current time will be used
Source:

lib/public/Files/Node.php#91

Parameters:
  • $mtime (int) (optional) modified date as unix timestamp
Throws:

\OCP\Files\InvalidPathException

Throws:

\OCP\Files\NotFoundException

Throws:

\OCP\Files\NotPermittedException

Throws:

\OCP\Files\InvalidPathException

Throws:

\OCP\Files\NotFoundException

Throws:

\OCP\Files\NotPermittedException

Throws:

\OCP\Files\InvalidPathException

Throws:

\OCP\Files\NotFoundException

Throws:

\OCP\Files\NotPermittedException

Returns:

void

Since:

6.0.0

public OCP\Files\Node::getStorage()
Get the storage backend the file or folder is stored on
Source:lib/public/Files/Node.php#100
Returns:\OCP\Files\Storage
Throws:\OCP\Files\NotFoundException
Since:6.0.0
public OCP\Files\Node::getPath()
Get the full path of the file or folder
Source:lib/public/Files/Node.php#108
Returns:string
Since:6.0.0
public OCP\Files\Node::getInternalPath()
Get the path of the file or folder relative to the mountpoint of it’s storage
Source:lib/public/Files/Node.php#116
Returns:string
Since:6.0.0
public OCP\Files\Node::getId()
Get the internal file id for the file or folder
Source:lib/public/Files/Node.php#126
Returns:int
Throws:\OCP\Files\InvalidPathException
Throws:\OCP\Files\NotFoundException
Throws:\OCP\Files\InvalidPathException
Throws:\OCP\Files\NotFoundException
Since:6.0.0
public OCP\Files\Node::stat()
Get metadata of the file or folder
The returned array contains the following values:
- mtime
- size
Source:lib/public/Files/Node.php#137
Returns:array
Since:6.0.0
public OCP\Files\Node::getMTime()
Get the modified date of the file or folder as unix timestamp
Source:lib/public/Files/Node.php#147
Returns:int
Throws:\OCP\Files\InvalidPathException
Throws:\OCP\Files\NotFoundException
Throws:\OCP\Files\InvalidPathException
Throws:\OCP\Files\NotFoundException
Since:6.0.0
public OCP\Files\Node::getSize($includeMounts=true)
Get the size of the file or folder in bytes
Source:

lib/public/Files/Node.php#158

Parameters:
  • $includeMounts (bool)
Returns:

int

Throws:

\OCP\Files\InvalidPathException

Throws:

\OCP\Files\NotFoundException

Throws:

\OCP\Files\InvalidPathException

Throws:

\OCP\Files\NotFoundException

Since:

6.0.0

public OCP\Files\Node::getEtag()
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
Source:lib/public/Files/Node.php#170
Returns:string
Throws:\OCP\Files\InvalidPathException
Throws:\OCP\Files\NotFoundException
Throws:\OCP\Files\InvalidPathException
Throws:\OCP\Files\NotFoundException
Since:6.0.0
public OCP\Files\Node::getPermissions()
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
Source:lib/public/Files/Node.php#186
Returns:int
Throws:\OCP\Files\InvalidPathException
Throws:\OCP\Files\NotFoundException
Throws:\OCP\Files\InvalidPathException
Throws:\OCP\Files\NotFoundException
Since:6.0.0 - namespace of constants has changed in 8.0.0
public OCP\Files\Node::isReadable()
Check if the file or folder is readable
Source:lib/public/Files/Node.php#196
Returns:bool
Throws:\OCP\Files\InvalidPathException
Throws:\OCP\Files\NotFoundException
Throws:\OCP\Files\InvalidPathException
Throws:\OCP\Files\NotFoundException
Since:6.0.0
public OCP\Files\Node::isUpdateable()
Check if the file or folder is writable
Source:lib/public/Files/Node.php#206
Returns:bool
Throws:\OCP\Files\InvalidPathException
Throws:\OCP\Files\NotFoundException
Throws:\OCP\Files\InvalidPathException
Throws:\OCP\Files\NotFoundException
Since:6.0.0
public OCP\Files\Node::isDeletable()
Check if the file or folder is deletable
Source:lib/public/Files/Node.php#216
Returns:bool
Throws:\OCP\Files\InvalidPathException
Throws:\OCP\Files\NotFoundException
Throws:\OCP\Files\InvalidPathException
Throws:\OCP\Files\NotFoundException
Since:6.0.0
public OCP\Files\Node::isShareable()
Check if the file or folder is shareable
Source:lib/public/Files/Node.php#226
Returns:bool
Throws:\OCP\Files\InvalidPathException
Throws:\OCP\Files\NotFoundException
Throws:\OCP\Files\InvalidPathException
Throws:\OCP\Files\NotFoundException
Since:6.0.0
public OCP\Files\Node::getParent()
Get the parent folder of the file or folder
Source:lib/public/Files/Node.php#234
Returns:\OCP\Files\Folder
Since:6.0.0
public OCP\Files\Node::getName()
Get the filename of the file or folder
Source:lib/public/Files/Node.php#242
Returns:string
Since:6.0.0
public OCP\Files\Node::lock($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.
Source:

lib/public/Files/Node.php#265

Parameters:
  • $type (int) OCPLockILockingProvider::LOCK_SHARED or OCPLockILockingProvider::LOCK_EXCLUSIVE
Throws:

\OCP\Lock\LockedException

Since:

9.1.0

public OCP\Files\Node::changeLock($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.
Source:

lib/public/Files/Node.php#280

Parameters:
  • $targetType (int) OCPLockILockingProvider::LOCK_SHARED or OCPLockILockingProvider::LOCK_EXCLUSIVE
Throws:

\OCP\Lock\LockedException

Since:

9.1.0

public OCP\Files\Node::unlock($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.
Source:

lib/public/Files/Node.php#293

Parameters:
  • $type (int) OCPLockILockingProvider::LOCK_SHARED or OCPLockILockingProvider::LOCK_EXCLUSIVE
Throws:

\OCP\Lock\LockedException

Since:

9.1.0