GGFile makes it easy to work with files and directories.
Lua
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
GGFile.lua
README.md

README.md

GGFile

GGFile makes it easy to work with files and directories.

Basic Usage

Require the code
local GGFile = require( "GGFile" )
Create your file manager
local fileManager = GGFile:new()
Write data to a file
fileManager:write( "test.txt", "Hello,\nWorld!", system.DocumentsDirectory )
Read data from a file
print( fileManager:read( "test.txt", system.DocumentsDirectory ) )
Append data to a file
fileManager:append( "test.txt", "\nGlitch\nAre\nAwesome :-)", system.DocumentsDirectory )
Read in, and print out, all lines in a file.
local lines = fileManager:readLines( "test.txt", system.DocumentsDirectory )

for i = 1, #lines, 1 do
	print( lines[ i ] )
end
Rename a file
fileManager:rename( "test.txt", "test2.txt", system.DocumentsDirectory )
Delete a file
fileManager:delete( "test2.txt", system.DocumentsDirectory )
Move a file
fileManager:move( "test.lua", system.ResourceDirectory, "test.lua", system.DocumentsDirectory )
Copy a file
fileManager:copy( "test.lua", system.ResourceDirectory, "test.lua", system.DocumentsDirectory )
Get, and print out, a list of files found in a directory called 'savedPhotos' in the Documents Directory
local files = fileManager:getFilesInDirectory( "savedPhotos", system.DocumentsDirectory )

for i = 1, #files, 1 do
	print( files[ i ] )
end
Create a directory called 'test' in the Documents Directory
local success, reason = fileManager:makeDirectory( "", "test", system.DocumentsDirectory )

print( success, reason )
Delete a directory called 'test' from the Documents Directory
local success, reason = fileManager:removeDirectory( "test", system.DocumentsDirectory )

print( success, reason )
Get a specific attribute of a file
local attribute = fileManager:getAttributes( "test/srfg.txt", GGFile.Attribute.LastAccess )
print( attribute )
Get, and print out, all attributes of a file
local attributes = fileManager:getAttributes( "test/srfg.txt" )

for k, v in pairs( attributes ) do
	print( k, v )
end
Check if a file/directory exists
local exists = fileManager:exists( "test/srfg.txt" )
print( exists )
Check if something is a directory
local isDirectory = fileManager:isDirectory( "test" )
print( isDirectory )
Destroy the file manager
fileManager:destroy()
fileManager = nil