Documentation

CBXVirtualFile

CBXVirtualFile class is used to handle files.

Class instance is not connected with physical file, i. e. the actual file may be non-existent. Class instance can be retrieved, for example, by calling the method GetFile($path) of the CBXVirtualFile class instance.

$fp = $io->RelativeToAbsolutePath("/папка1/.access.php");
$f = $io->GetFile($fp);
$f->MarkWritable();

Note:

This class is considered deprecated. It is recommended to use new core D7 class, located in the /bitrix/modules/main/lib/io/file.php.

Class methods

Method Description Available from version
GetName
string
CBXVirtualFile::GetName()
No parameters. Returns file name.
GetPath
string
CBXVirtualFile::GetPath()
No parameters. Returns file path.
GetPathWithName
string
CBXVirtualFile::GetPathWithName()
No parameters. Returns file name with path.
IsDirectory
bool
CBXVirtualFile::IsDirectory()
No parameters. Returns false.
IsExists
bool
CBXVirtualFile::IsExists()
No parameters. Returns true, if file do not exists physically. Otherwise false.
MarkWritable
void
CBXVirtualFile::MarkWritable()
No parameters. Marks file to be writable.
GetPermissions
int
CBXVirtualFile::GetPermissions()
No parameters. Returns file access permissions.
GetModificationTime
int
CBXVirtualFile::GetModificationTime()
No parameters. Returns time when a file was last modified.
GetLastAccessTime
int
CBXVirtualFile::GetLastAccessTime()
No parameters. Returns time when a file was last accessed.
GetType
string
CBXVirtualFile::GetType()
No parameters. Returns file type based on its extension. Available types: IMAGE, FLASH, SOURCE, UNKNOWN.
GetExtension
string
CBXVirtualFile::GetExtension()
No parameters. Returns file extension.
Open
resource
CBXVirtualFile::Open string $mode)
Opens file in the specified mode and returns its descriptor. It is not advise to use this method, only if really necessary.
GetContents
string
CBXVirtualFile::GetContents()
No parameters. The method returns file content. If the file doe not exist, null is returned.
PutContents
bool
CBXVirtualFile::($data)
No parameters. The method records new content into a file. If the file does not exist, it is created. Returns true on success and false otherwise.
GetFileSize
int
CBXVirtualFile::GetFileSize()
No parameters. Returns file size or null, if the file does not exist.
IsWritable
bool
CBXVirtualFile::IsWritable()
No parameters. Returns true, if the file is writable. Otherwise returns false.
IsReadable
bool
CBXVirtualFile::IsReadable()
No parameters. Returns true, if the file is readable. Otherwise, returns false.
ReadFile
string
CBXVirtualFile::ReadFile()
No parameters. Reads file content.
GetErrors
array
CBXVirtualFile::GetErrors()
No parameters. Returns array of errors, occurred during the last file-related operation.


© «Bitrix24», 2001-2024