Module classes.helpers.vFilesys
Static methods for dealing with the file-system
Functions
get_path_parts (file_path) | important - folders should end with a slash |
get_parent_directory (file_path) | provided with a string, this method will find the parent folder (using file system functions, so the location is guaranteed to exist) |
ensure_unique_filename (file_path) | if file already exist, return a name with (number) appended to it |
get_directories (file_path) | split path into parts, seperated by slashes |
validate_filename (str) | make sure a file/folder name does not contain anything considered bad return bool |
sanitize_filename (filename) | remove illegal characters |
Functions
- get_path_parts (file_path)
-
important - folders should end with a slash
Parameters:
- file_path
Returns:
- string, folder
- string, filename
- string, extension
- get_parent_directory (file_path)
-
provided with a string, this method will find the parent folder
(using file system functions, so the location is guaranteed to exist)
Parameters:
- file_path
Returns:
- string or nil if failed
- int, error code
- ensure_unique_filename (file_path)
-
if file already exist, return a name with (number) appended to it
Parameters:
- file_path
- get_directories (file_path)
-
split path into parts, seperated by slashes
Parameters:
- file_path
Returns:
-
table>string
- validate_filename (str)
-
make sure a file/folder name does not contain anything considered bad
return bool
Parameters:
- str
- sanitize_filename (filename)
-
remove illegal characters
Parameters:
- filename