File system functions

The SMFileSystem class contains a set of useful static functions, allowing the programmer to perform actions on the server's file system. See the class description for further details.


SMFileSystem class

Function
Return type
Description
::CreateFolder($path:string)
Boolean
Create folder at the specified path. Returns True on success, otherwise False.
::Move($path:string, $newPath:string)
Boolean
Move or rename a file or folder. Returns True on success, otherwise False.
::Delete($path:string)
Boolean
Delete the specified file or folder. Returns True on success, otherwise False.
Delete($path:string, $force:boolean)
Boolean
See description for Delete($path:string). Set $force True to remove all sub folders and files.
::GetFileSize($path:string)
Integer
Get the file size of a given file. The value -1 is returned in case of errors.
::GetFileModificationTime($path:string)
Integer
Get time for last modification of the specified file. Returns unix time stamp on success, -1 in case of errors.
::GetFiles($path:string)
String[]
Get all files from specified path.
::GetFolders($path:string)
String[]
Get all folders from specified path.
::HandleFileUpload($fileField:string, $moveToFolder:string)
Boolean
Receive a file from a file input field. Specify the name of the file input field in $fileField. $moveToFolder is set to the path of the folder in which the file should be permanently stored. A timestamp is added to the file name, if the specified file name is already in use.
::HandleFileUpload($fileField:string, $moveToFolder:string, $filenameRegEx:string) Boolean
See description for HandleFileUpload($fileField:string, $moveToFolder:string). This function allows for a regular expression to be set, specifying valid character for the given file name of the uploaded file. Characters not matching the regular expression will simply be removed from the filename.
::FolderExists($path:string)
Boolean
Returns True if the specified folder exists, otherwise False.
::FileExists($path:string)
Boolean
Returns True if the specified file exists, otherwise False.
::FileIsWritable($path:string)
Boolean Returns True if the specified file is writable, otherwise False.
::FileIsReadable($path:string) Boolean
Returns True if the specified file is readable, otherwise False.