File System


File system functions come in two forms. Older functions were written as two distinct functions names, only the prefix changed; Where fexists() operates on files in the secure data directory (often named mivadata) and sexists() operates on the web site directory (often called html or httpdocs).

These functions are grouped under Data Folder and Script Folder respectively.

Newer file systems functions contain an additional "location" parameter where location is either 'data' or 'script'. For example file_read( path, location, input_data var ). These functions are grouped together under Either Folder.

Name -- Syntax / Description
dir
dir( path, location, entries var )
Reads a directory list in path.
Returns the number of files found or 0 (zero) if none are found. The parameter entries returns an array of file names found.
  • path = The path to a directory relative to the location
  • location = "data" or "script"
  • entries = array of resultant file names
fchmod
fchmod( path, mode )
Changes a files or directory permissions.
Returns 1 if sucessful, 0 if fails
  • path = fully qualified path to the file
  • mode_number = ( nnnn decimal number) or '0nnnn' (octal string)
fcopy
fcopy( source, destination )
Copies a file in the data directory.
Returns 1 if sucessful, 0 if fails
  • source = source file fully qualified path
  • destination = destination file fully qualified path
fdelete
fdelete( path )
Deletes a file in the data directory. See sdelete()
Returns 1 if sucessful, 0 if fails
  • path = fully qualified path of the file to delete
fexists
fexists( path )
Tests if the file named in path exists in the data directory.
Returns 1 if the file exsists else 0.
  • path = the fully qualified path to the file
file_append
file_append( path, location, outputdata var )
Appends data to the end of the file in path.
Returns length of outputdata or -1 on error. file_append() will not create a file, but return -1 if the file does not exist.
  • path = fully qualified path to the file
  • location = location of the output file - 'data' or 'script'
  • outputdata = string variable containing the data to append
file_create
file_create( path, location, outputdata var )
Creates and appends data to the file in path.
Returns length of outputdata or -1 on error. file_create() will not append to an existing file, but return -1 if the file exists.
  • path = fully qualified path to the file
  • location = location of the output file - 'data' or 'script'
  • outputdata = string variable containing the data to append
file_read
file_read( path, location, inputdata var )
Reads a file.
Returns length of inputdata or -1 on error or file does not exist.
  • path = fully qualified path to the file
  • location = location of the input file - 'data' or 'script'
  • inputdata = string variable containing the data read
file_read_bytes
file_read_bytes( path, location, offset, length, data )
Reads a portion of the file specified by "path" and "location" into "data". Returns the number of bytes read, which may be less than "length", if an attempt was made to read past the end of the file, or -1 on error.
Returns the number of bytes read from the file. The file data is returned in "data".
  • path = The name or filepath of the file to open relative to the directory specified by "location"
  • location = One of "script" or "data"
  • offset = The zero-based offset at which to begin reading
  • length = The number of bytes to read. If < 0, the entire file after "offset" is read.
  • data = The variable in which to store the file data
file_touch
file_touch( file, location )
Updates the modification time of the specified file.
Return value: 0 on success, -1 on failure.
  • file = File name.
  • location = File location. "script" or "data", defaulting to "data" if any other value.
fisdir
fisdir( path )
Tests if the file named in path is a directory.
Returns 1 if the path is a directory else 0.
  • path = the fully qualified path to the directory
fmkdir
fmkdir( path )
Creates a directory specified by path in the data directory.
Returns 1 if sucessful, 0 if fails
  • path = the fully qualified path to the directory
fmode
fmode( path )
Returns the permissions mode of path in the data directory.
Returns the permissions mode or -1 if the file does not exist
  • path = the fully qualified path to the file or directory
frename
frename( source, destination )
Rename source file to destination file. Can rename or move a file in the data directory.
Returns 1 if sucessful, 0 if fails
  • source = source file fully qualified path
  • destination = destination file fully qualified path
fscopy
fscopy( data_source,script_destination )
Copies a file from data directory to the scripts directory.
Returns 1 if sucessful, 0 if fails
  • data_source = source file fully qualified path
  • scripts_destination = destination file fully qualified path
fsize
fsize( path )
Get the size of a file in the data directory
Returns the file size in bytes or -1 if the file does not exist.
  • path = the fully qualified path to the file
fsrename
fsrename( source, destination )
Rename data directory source file to script directory destination file. Can rename or move a file.
Returns 1 if sucessful, 0 if fails
  • source = source file fully qualified path
  • destination = destination file fully qualified path
fssymlink
fssymlink( source, destination )
This function creates a symbolic link from a file in the data directory to the scripts directory (Available on UNIX file systems only)
Returns 1 if sucessful, 0 if fails
  • source = source file fully qualified path in the data directory
  • destination = destination file fully qualified path in the scripts directory
fsymlink
fsymlink( source, destination )
(Unix only) Creates a symbolic link to the file in the data directory.
Returns 1 if sucessful, 0 if fails
  • source = source file fully qualified path
  • destination = destination file fully qualified path
ftime
ftime( path )
Gets the last modified time for the file in data directory.
Returns time_t since a file in the was last modified or -1 if the file does not exist.
  • path = the fully qualified path to the file
miva_lockfile
miva_lockfile( path, location )
Creates and locks a lockfile. Similar to the behavior of MvLOCKFILE without the closing /MvLOCKFILE behavior. It also creates the exact filename, rather than appending ".lck" to the filename as MvLOCKFILE does.
Returns 1 if sucessful, -1 if fails
  • path = fully qualified path to the file
  • location = location of the file - 'data' or 'script'
  • Use fdelete() or sdelete() to delete the lockfile.
schmod
schmod( path, mode )
Changes a files or directory permissions.
Returns 1 if sucessful, 0 if fails
  • path = fully qualified path to the file
  • mode_number = ( nnnn decimal number) or '0nnnn' (octal string)
scopy
scopy( source, destination )
Copies a file in the scripts directory.
Returns 1 if sucessful, 0 if fails
  • source = source file fully qualified path
  • destination = destination file fully qualified path
sdelete
sdelete( path )
Deletes a file in the scripts directory. See See fdelete()
Returns 1 if sucessful, 0 if fails
  • path = fully qualified path of the file to delete
sexists
sexists( path )
Tests if the file named in path exists in the scripts directory.
Returns 1 if the file exsists else 0.
  • path = the fully qualified path to the file.
sfcopy
sfcopy( source, destination )
Copies a file from the scripts directory to the data directory.
Returns 1 if sucessful, 0 if fails
  • scripts_source = source file fully qualified path in the scripts folder
  • data_destination = destination file fully qualified path in the data folder
sfrename
sfrename( source, destination )
Rename source file to destination file. Can rename or move a file in the scripts directory.
Returns 1 if sucessful, 0 if fails
  • source = source file fully qualified path
  • destination = destination file fully qualified path
sfsymlink
sfsymlink( source, destination )
This function creates a symbolic from a file in the scripts directory to the data directory (Available on UNIX file systems only)
Returns 1 if sucessful, 0 if fails
  • source - source file fully qualified path in the scripts directory
  • destination = destination file fully qualified path in the data directory
sisdir
sisdir( path )
Tests if the file named in path is a directory.
Returns 1 if the path is a directory else 0.
  • path = the fully qualified path to the directory
smkdir
smkdir( path )
Creates a directory specified by path in the scripts directory.
Returns 1 if sucessful, 0 if fails
  • path = the fully qualified path to the directory
smode
smode( path )
Returns the permissions mode of path in the scripts directory.
Returns the permissions mode or -1 if the file does not exist
  • path = the fully qualified path to the file or directory
srename
srename( source, destination )
Rename source file to destination file. Can rename or move a file in the scripts directory.
Returns 1 if sucessful, 0 if fails
  • source = source file fully qualified path
  • destination = destination file fully qualified path
ssize
ssize( path )
Get the size of a file in the scripts directory
Returns the file size in bytes or -1 if the file does not exist.
  • path = the fully qualified path to the file
ssymlink
ssymlink( source, destination )
(Unix only) Creates a symbolic link to the file in the scripts directory.
Returns 1 if sucessful, 0 if fails
  • source = source file fully qualified path
  • destination = destination file fully qualified path
stime
stime( path )
Gets the last modified time for the file in scripts directory.
Returns time_t since a file in the was last modified or -1 if the file does not exist.
  • path = the fully qualified path to the file
file_overwrite
file_overwrite( path, location, data var )
Replaces the file in path if it exists. If will not create the file if it does not exist.
Returns the length of data written or -1 on error
  • path = fully qualified path to the file
  • location = 'data' or 'script'
  • data = string variable containing the data to write
file_set_time
file_set_time( path, location, modified )
Updates the modification time of the specified file to the time_t value in modified.
Return value: 0 on success, -1 on failure.
  • path = complete path and file name.
  • location = File location. "script" or "data", defaulting to "data" if any other value.
  • modified = the time_t timestamp value.
User Annotations: filesystem