OpenFile, ReadFile and WriteFile return a Stream object for reading and or writing data to files.
Directories can be examined file by file using a combination of the ReadDir, NextFile and CloseDir commands or LoadDir can be used to read the file names of a directory into a string array.
File properties can be examined with the FileType, FileTime, FileSize and FileMode commands.
Files and directories (folders) can be created and deleted with the CreateFile, CreateDir, DeleteFile and DeleteDir commands.
Finally, the FileSystem module contains various utility functions
for handling file paths in a system independent manner. These commands include RealPath,
StripDir,
StripExt,
StripAll,
StripSlash,
ExtractDir and
ExtractExt.
This command is similar to the OpenStream command but will attempt
to cache the contents of the file to ensure serial streams such as
http: based url's are seekable. Use the CloseStream command when
finished reading and or writing to a Stream returned by OpenFile.
This command is similar to the ReadStream command but will attempt
to cache the contents of the file to ensure serial streams such as
http: based url's are seekable. Use the CloseStream command when
finished reading and or writing to a Stream returned by OpenFile.
This command is identical to the WriteStream command.
After performing file operations on an open file make sure to
close the file stream with either CloseFile or the identical
CloseStream command.
Returns: 0 if file at path doesn't exist, FILETYPE_FILE (1) if the file is a plain file or FILETYPE_DIR (2) if the file is a directory
Returns: The time the file at path was last modified
Returns: Size, in bytes, of the file at path, or -1 if the file does not exist
Returns: True if successful
Example:
' createfile.bmx
success=CreateFile("myfile")
If Not success RuntimeError "error creating file"
Returns: True if successful
Example:
' createdir.bmx
success=CreateDir("myfolder")
If Not success RuntimeError "error creating directory"
Returns: True if successful
Example:
' deletefile.bmx
success=DeleteFile("myfile")
If Not success RuntimeError "error deleting file"
Returns: True if successful
Set recurse to true to delete all subdirectories and files recursively -
but be careful!
Example:
' deletedir.bmx
success=DeleteDir("myfolder")
If Not success RuntimeError "error deleting directory"
Returns: The current directory
Example:
' currentdir.bmx
cd$=CurrentDir()
Print "CurrentDir()="+cd$
Returns: An integer directory handle, or 0 if the directory does not exist
Returns: File name of next file in directory opened using ReadDir, or an empty string if there are no more files to read.
Returns: A string array containing contents of dir
The skip_dots parameter, if true, removes the '.' (current) and '..'
(parent) directories from the returned array.
Module | brl.filesystem |
Version | 1.00 |
Author | Mark Sibly |
License | Blitz Shared Source Code |
Copyright | Blitz Research Ltd |
Modserver | BRL |