File functions
The following file and directory functions are supported. The file functions are compatible with theire PHP pendants.
Function/Arguments | Return | Description |
---|---|---|
fopen (string filename, string mode="r") | handle | Open or create a file named with filename. If parameter mode is not given then the file will be opened with read only permissions, otherwise the modes are equal to PHP/C fopen(): r, r+, w+, a, a+, x, x+ (c, c+, e are not implemented!). For detailed description read PHP file modes. On success the file handle is returned, otherwise null is returned an a warning is shown. The following special filenames are possible: 'v1://stdin' = standard input, 'v1://stdout' = standard output, 'v1://stderr' = standard error |
fwrite (handle file, string string [, number length]) | number | Write a string into the given file . If parameter length is not given then the full string is written, otherwise the specified number of bytes are written. On success the number of written bytes is returned, otherwise false is returned and a warning is shown. |
fread (handle file, string& string [, number length=0xFFFF]) | number | Read data from the given file into a string variable. The parameter string must be a reference to a variable. If length is not set then it tries to read 64 KB from the file. On success the number of read bytes is returned, otherwise false is returned. |
fgets (handle file) | string | Read a line until Ascii 13=\n from file . On success the read line is returned. If the end of file is reached false is returned. |
freadln (handle file, string& string) | bool | Read a line until Ascii 13=\n from file into a given string variable. The parameter string must be a reference to a variable. On success true is returned. If the end of file is reached false is returned. |
fclose (handle file) | bool | Close the file. On success true is returned. |
feof (handle file) | bool | Return true if the end of the file is reached and no more data can be read. |
ftell (handle file) | number | Return the current position of file pointer (read bytes). |
fseek (handle file, number position) | bool | Set the file pointer to a position beginning from 0. On success true is returned. |
filesize (string filename) | number | Return the file size of a given filename. If the file is not found false is returned. |
filemtime (string filename) | number | Return timestamp of last modification of filename. If the file is not found false is returned. |
filectime (string filename) | number | Return timestamp of creation of filename. If the file is not found false is returned. |
fileatime (string filename) | number | Return timestamp of last access of filename. If the file is not found false is returned. |
touch (string filename, number filemtime=time() [, number fileatime]) | bool | Set modification time filemtime and optional access time fileatime to filename. On success true is returned. |
file_exists (string path) | bool | Return true if a given path is a file or directory. |
is_file (string path) | bool | Return true if a given path is a file. |
is_dir (string path) | bool | Return true if a given path is a directory. |
filetype (string path) | string | Return the type of a given path. Possible return values: 'dir' = Directory; 'file' = File; false = not found |
unlink (string filename) | bool | Delete a file named with flename. On success true is returned. |
rename (string fromFilename, string toFilename) | bool | Rename (move) a file fromFilename toFilename. On success true is returned. |
copy (string fromFilename, string toFilename) | bool | Copy a file fromFilename toFilename. The file will be dublicated. On success true is returned. |
basename (string path) | string | Return the base name without directory of a given path. For example: c:\projects\v1\v1.exe will return v1.exe |
dirname (string path) | string | Return the directory of a given path. For example: c:\projects\v1\v1.exe will return c:\projects\v1 |
pathinfo (string path) | array | Same as PHP pathinfo (). Return an array with information about the given path. For example: c:\projects\v1\v1.exe will return: array ( 'dirname' => 'c:\projects\v1', 'basename' => 'v1.exe', 'extension' => 'exe', 'filename' => 'v1' ) |
realpath (string path) | string | Return the absolute system path of a given relative path. For example: ./v1.exe will return c:\projects\v1\v1.exe. realpath() does not work for files with length 0 and non readable files. |
fileno (handle file) | number | Return the system file descriptor of the V1 file or socket handle. This number can be given to external native functions, see Native function calling. |
Directory functions
See also example Read directory.
Function/Arguments | Return | Description |
---|---|---|
getcwd () | string | Return the current working directory. |
chdir (string directory) | bool | Set the current working directory. On success true is returned. Note: The default working directory is the directory of calling v1.exe. To determine the directory of current V1 file use: dirname(__FILE__) |
mkdir (string directory) | bool | Create a new directory. On success true is returned. |
rmdir (string directory) | bool | Remove a directory if its empty. On success true is returned. |
opendir (string directory) | handle | Open a directory to read containing filenames and sub directories. On success a directory handle is returned, otherwise null is returned. |
readdir (handle directory) | string | Read the next filename from a directory handle. On success the filename or sub directory is returned. If the last entry was read then false is returned. |
closedir (handle directory) | bool | Close a directory handle. On success true is returned. |
V1 Version 0.96 - Documentation generated Sun, 05 May 2024 07:59