From 56e8c485af620bdd5123356adb74496a094a1c55 Mon Sep 17 00:00:00 2001 From: ineed bots Date: Fri, 1 Dec 2023 01:22:45 -0600 Subject: [PATCH] Final the fileio doc --- README.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 9d04a61..0a67b50 100644 --- a/README.md +++ b/README.md @@ -12,23 +12,23 @@ Adds custom GSC functions. ## FileIO This plugin provides FileIO interface to GSC for reading and writing files, this is exact to [CoD4x's](https://github.com/callofduty4x/CoD4x_Server/blob/master/scriptdocumentation/script_functions_reference.md#file-operations) interface. -However, all reads and writes will take place strictly and only in the `scriptdata` folder. +However, all reads and writes will take place strictly and only in the `scriptdata` folder, no up directory traversal allowed. All files will be closed upon GSC restart (map_restart or fast_restart or missionfailed, etc), only a maximum of 10 files may be opened at once. * ` FS_TestFile()` Returns `true` if the file exists, `false` otherwise. +* ` FS_Remove()` Deletes the file, return `true` if successful, `false` otherwise. ```gsc - if (FS_TestFile("test.txt")) + // test to see if "scriptdata/test.txt" file exists + if (FS_TestFile("test.txt")) // not a typo, all file io will take place inside the "scriptdata" folder { PrintConsole("Found test.txt!"); - } - ``` -* ` FS_Remove()` Deletes the file, return `true` if successful. - ```gsc - if (FS_Remove("test.txt")) - { - PrintConsole("test.txt was deleted!"); + // delete it! + if (FS_Remove("test.txt")) + { + PrintConsole("test.txt was deleted!"); + } } ``` @@ -39,11 +39,11 @@ All files will be closed upon GSC restart (map_restart or fast_restart or missio FS_FCloseAll(); // close them all ``` -* ` FS_FOpen(, )` Tries to open the file, mode is one of `read`, `write` (clears the file), `append` (appends to the file), returns the filehandle. Will return `0` if failed to open. +* ` FS_FOpen(, )` Tries to open the file, mode must be one of `read`, `write` (clears the file), `append` (appends to the file), returns the filehandle. Will return `0` if failed to open. * `FS_FClose()` Closes the file pointed by the filehandle given, which was returned from `FS_FOpen`. ```gsc // opens "scriptdata/test.txt", all io will take place inside the "scriptdata" folder - f = FS_FOpen("test.txt", "read"); // can be "read" "write" or "append" + f = FS_FOpen("test.txt", "read"); // can be "read" "write", or "append" if (!f) { @@ -76,7 +76,7 @@ All files will be closed upon GSC restart (map_restart or fast_restart or missio // close the file ``` -* ` FS_WriteLine(, )` Writes to the file pointed by the filehandle. Appends a newline character. Returns `true` if successful. Filehandle must be opened for writing. +* ` FS_WriteLine(, )` Writes to the file pointed by the filehandle. Appends a newline character. Returns `true` if successful, `false` otherwise. Filehandle must be opened for writing. * ` FS_Write(, )` Same as above, does not add a newline character. ```gsc // open the file for writing