Files Library (ssk.files.*)
WARNING - You should consider this an advanced library and use it with caution and clarity of purpose. While I have taken steps to reduce the likelihood of you deleting your hard drive, I won't say it is impossible if you try hard enough.
~ The Roaming Gamer
This library gives you the ability to fully explore, modify, copy, move, and remove folders and files in the current OS file-system. The only limits are the permissions the current OS has granted your application.
This library has been tested on these operating systems:
- Android (multiple versions)
- iOS (multiple versions)
- Windows (7,8,10) - This includes in the simulator and Desktop builds.
- OS X (multiple versions) - This includes in the simulator and Desktop builds.
Documents Folder (ssk.files.documents.*)
getRoot()
- Returns a string containing the full OS-path to thesystem.DocumentsDirectory
folder.getPath( path )
- This returns a string catenatingpath
to the full OS-path to thesystem.DocumentsDirectory
folder.
Resource Folder (ssk.files.resource.*)
getRoot()
- Returns a string containing the full OS-path to thesystem.ResourceDirectory
folder.getPath( path )
- This returns a string catenatingpath
to the full OS-path to thesystem.ResourceDirectory
folder.
Temporary Folder (ssk.files.temporary.*)
getRoot()
- Returns a string containing the full OS-path to thesystem.TemporaryDirectory
folder.getPath( path )
- This returns a string catenatingpath
to the full OS-path to thesystem.TemporaryDirectory
folder.
Desktop (OS X and Windows) (ssk.files.desktop.*)
getDesktopRoot()
- Returns a string containing the full OS-path to the user's Desktop.getDesktopPath( path )
- Catenatespath
to a string containing the full OS-path to the user's Desktop.getMyDocumentsRoot()
- Returns a string containing the full OS-path to the user's Documents Folder.getMyDocumentsPath( path )
- Catenatespath
to a string containing the full OS-path to the user's Documents Folder.getDrivePath( path )
- Returns the OS-specific drive path for any named drivepath
.explore( path )
- Openspath
folder using the current OSes file explorer utility.
Utilities (ssk.files.util.*)
appendFile( data, path )
- Appends the string indata
to the file atpath
, creating the file if it does not yet exists.dumpAttributes( path )
- Prints the file system attributes of the file/folder atpath
to the console.cpFile( src, dst )
- Copies the a filesrc
to the folderdst
.cpFolder( src, dst )
- Copies the a foldersrc
to the folderdst
.exists( path )
- Returnstrue
if the file atpath
exists. Returnsfalse
otherwise.isFile( path )
- Returnstrue
if the file atpath
is in fact a file and not some other file type. Returnsfalse
otherwise.isFolder( path )
- - Returnstrue
if the file atpath
is in fact a folder and not some other file type. Returnsfalse
otherwise.loadTable( path, secure )
- Reads a JSON encoded text file atpath
and returns it as a decoded table. Optionally uses the ssk.security system ifsecure
is specified and `true.mkFolder( path )
- Makes a folder namedpath
.- Tip: - This can only make the final folder in the path and will not create entire hieararchies of folders if they do not exist yet.
mvFile( src, dst )
- Moves the file atsrc
todst
, wheresrc
anddst
are complete paths.mvFolder( src, dst )
- Moves the folder atsrc
todst
, wheresrc
anddst
are complete paths.readFile( path )
- Returns a string containing the contents of the file atpath
ornil
if the file cannot be read.readFileToTable( path )
- Returns a table containing the contents of the file atpath
or{}
if the file cannot be read.- Tip: - This table is numerically indexed and each entry represents a line in the file separated by the newline character
\n
.
- Tip: - This table is numerically indexed and each entry represents a line in the file separated by the newline character
repairPath( path, forceForward )
- Returns a string with the slashes leaning in the right direction for the current OS.- If
forceForward
is specified andtrue
, the slashes will all be forced to be forward leaning.
- If
rmFile( path )
- Removes the file or folder atpath
.rmFolder( path )
- Removes the folder atpath
.saveTable( tbl, path, secure )
- Saves tabletbl
as a JSON encoded text file topath
and optionally uses the ssk.security system ifsecure
is specified and `true.writeFile( data, path )
- Writes the stringdata
to the file atpath
, replacing the file if it already exists.
Copyright © Roaming Gamer, LLC. 2008-2016; All Rights Reserved