Until I can figure out how to process events properly, every method in the API should first call a method to check if a drive has been plugged in, or a drive removed (or if the tree exists). If a drive has been removed, the whole directory tree needs to be rebuilt (add a function to make this unneeded if possible! call a function before removing a drive to remove its entries). If a drive has been added, its contents need to be added to the tree. Note that removing or adding a drive also needs to re-calculate free space of the system.
Internal
something to loop through a loaded tree
the function(s) needed above
something to save or load a tree
Note that free space and used space are not stored. Instead, when a disk is loaded, they are calculated and saved temporarily for each disk (as well as a master free/used space). The file size of the index for each disk is part of this calculation, plus 1024 bytes assumed for expansion of the index file.
any time a file is updated, moved, deleted, whatever, the index should be updated, and free space and such re-calculated!
make sure to account for a trailing slash on a directory name (but not a file name! also don't allow files to be written with a trailing slash!)
account for allowing forward or backward slashes ONLY if fs supports it
From fs API
[ ] list(string path)
for loop through loaded table to find if specified path is directory, return its contents in an alphabetically ordered table (ex: {"abc", "abd", "bed"}), else return empty table
[ ] exists(string path)
for loop through loaded table, find if specified file or directory exists, return true/false
[ ] isDir(string path)
for loop through, find if directory, return true/false (if not exist, return false)
note: probably want to change this to return true unless a file exists there, because any directory can exist anywhere as far as GIFS is concerned
[ ] isReadOnly(string path)
(mostly) dummy fn for API compatibility, returns false unless path is root ("" or "/"), in which case, true (see API docs for CC)
[ ] getName(string path)
passes straight through to fs API (we do not need to change it)
[ ] getDrive(string path)
uses raw() to get actual file location, then passes to fs API to find what drive it is on
[ ] getSize(string path)
uses raw() to get actual file location, then passes to fs API
[ ] getFreeSpace(string path)
doesn't actually accept an argument, returns a pre-calculated free space (any time we write data or accept or remove a disk, the total free space is calculated!)
[ ] makeDir(string path)
for loop through table, creating entries if needed, and eventually making an empty directory where specified (or, if I go through with the other idea, nothing happens, dummy fn)
note: this isn't recommended(?), as GIFS doesn't care about directories, any directory exists as far as it is concerned, because anything can exist anywhere at any time (I might change this, I have to consider which disks empty directories are stored on...)
[ ] move(string from, string to)
check that the first exists, check that the second doesn't exist, then move the first to the second (if checks fail, error? need to verify that we're supposed to error here)
remember to update files on physical disk(s) and update free space (actually, it shouldn't need an update)
[ ] copy(string from, string to)
works just like move, except the original is kept intact (implement this first and extend it to make move!)
remember to update files on physical disk(s) and update free space!
[ ] delete(string path)
if exists, delete, else, nothing
note: remember that we need to delete the files on the disk and update free space!
[ ] combine(string basePath, string localPath)
passes straight through to fs, we don't need to care about it
[ ] open(string path, string mode)
[ ] find(string wildcard)
[ ] getDir(string path)
assuming this doesn't need to care about existence, pass straight through!
else, return the directory of the specified dir/path (this is the other component to getName basically)
[ ] fs.complete(string file/directory, string parent folder, [bool include files], [bool include slashes])
returns table completion list
DO NOT IMPLEMENT IN v0.1
Additional
[ ] raw(string path)
for loop through to find specified directory/file, return its actual location as a string (this is for compatibility with other APIs if needed)
returns nil if the raw path can't be found (or if the file is a GIFS composite file when I create that concept..note that such files need to be allowed to be used in the rest of the API, therefore, some care should be made in each fn involving files to recognize and change how they behave)
Until I can figure out how to process events properly, every method in the API should first call a method to check if a drive has been plugged in, or a drive removed (or if the tree exists). If a drive has been removed, the whole directory tree needs to be rebuilt (add a function to make this unneeded if possible! call a function before removing a drive to remove its entries). If a drive has been added, its contents need to be added to the tree. Note that removing or adding a drive also needs to re-calculate free space of the system.
Internal
Note that free space and used space are not stored. Instead, when a disk is loaded, they are calculated and saved temporarily for each disk (as well as a master free/used space). The file size of the index for each disk is part of this calculation, plus 1024 bytes assumed for expansion of the index file.
From fs API
{"abc", "abd", "bed"}
), else return empty table""
or"/"
), in which case, true (see API docs for CC)getName
basically)Additional
nil
if the raw path can't be found (or if the file is a GIFS composite file when I create that concept..note that such files need to be allowed to be used in the rest of the API, therefore, some care should be made in each fn involving files to recognize and change how they behave)