CBXVirtualIo
Bitrix Framework support of other than English symbols in the public filenames applies certain limits on general work, specifically:
Direct calls are unavailable
- to file names selected by users,
- to folder names selected by users,
- to files and folders located in folders which names are selected by users.
For example, the file .access.php cannot be directly called because it can be located in the Folder folder: /Folder/.access.php
.
If the call is directed to the file inside the /bitrix
folder, it is the service area that should not contain non-English characters. Direct methods can be used. If the request to item is made outside /bitrix
folder, then either a name, or path can contain non-English characters. Also, CBXVirtualIo must be used.
Exception - widespread files inside site root: /404.php
, /auth.php
, /urlrewrite.php
, /.htaccess
, which, obviously cannot support non-English characters in the path, though they are located not in the /bitrix folder.
CBXVirtualIo class is used to handle files in public section, which are created by users, or user-created folders.
This class is not static, that's why it is recommended to create its instance before using it. To get "default" instance of CBXVirtualIo class, use the static method GetInstance(). This method creates a single class instant with "default" settings only once, when called for the first time:
$io = CBXVirtualIo::GetInstance();
Class methods
Method | Description | Available from version |
---|---|---|
CombinePath | Combines parts of a path into a single path. | |
RelativeToAbsolutePath | Converts product root path relative to absolute path. | |
SiteRelativeToAbsolutePath | Converts specified site root path to absolute path. | |
GetPhysicalName |
string CBXVirtualIo::GetPhysicalName( string $path ); Converts path (string) into file system format. It's not recommended to use this method without actual necessity. | |
GetLogicalName |
string CBXVirtualIo::GetLogicalName( string $path );Converts path (string) from file system format to site format. It is not recommend to use this method without actual necessity. | |
ExtractNameFromPath | Returns file or folder name from specified path. | |
ExtractPathFromPath | Returns path to file or folder from a specified path. | |
ValidatePathString | Validates correct path. | |
ValidateFalenameString | Validates file (folder) name. | |
DirectoryExists | Checks if specified folder exists. | |
FileExists | Checks if specified file exists. | |
GetDirectory | Returns folder class object for the specified path. | |
GetFile | Returns file class object for the specified path. | |
OpenFile |
resource CBXVirtualIo::OpenFile( string $path, string $mode );Opens file in the specified mode and returns its descriptor. It's better not to use this method without actual necessity. | |
CreateDirectory | Creates specified folder, if doesn't exist. | |
Delete | Deletes file or folder. | |
Copy | Copies file or folder. | |
Move | Moves file or folder | |
ClearCache | void CBXVirtualIo::ClearCache( );No parameters. Clears the file system cache, if available | 11.0.2 |
GetErrors | array CBXVirtualIo::GetErrors( );No parameters. Returns array of errors, occurred during the latest file operation. |