int FileOpen(string filename, int mode)
Will open or create a file of the passed name, for either reading or writing, depending on the mode passed. It returns a handle to the file as a non zero integer. If the operation fails, it returns 0, which idealy you should check for before reading from the file.
The mode pass is to determine if you want to read from or write to the file, only one can be selected, and the file must be closed and re opened to change to the other mode. The defines used by verge are:
#define FILE_READ 1 #define FILE_WRITE 2 #define FILE_WRITE_APPEND 3
Verge will always return 0 if you try to open a file in read mode that does not exist, however write mode will create a new file with that name. More importantly however, FILE_WRITE will always overwrite any data if the file already exists. This is why appending to the end of an existing file should use FILE_WRITE_APPEND instead.
Verge does not let you access the directory structure oustside your current branch. You can access sub folders, but no overwriting stuff in c:\windows... unless of course verge is run from there.
Like most things in verge, case matters not a whit. You can pass upper or lower case letters for a filename, and it will still find the right thing, even if you are silly: "ReAdmE.tXT" will still open the file (in Windows anyway).
Note: In Linux or certain Mac filesystems, filenames are case-sensitive, so while using improper case may work in Windows, in Linux it'll explode. Be cautious!
int file = FileOpen("maped3.exe", FILE_WRITE); FileClose(file); // Oh dear! You've just replaced Maped 3 with a blank file // Doh... I actually just did, time to download the verge engine again
There are no talkbacks on this documentation page yet. Post the first?
Doc Nav |
Your docs |