Class: DataRegistry
The DataRegistry class provides a simple method to save projectdependent
data like highscores, savegames etc. in a directory of luxinia itself (for now).
The location of this data container might change in future to be stored
in a user specific directory of the OS.
The class provides simplified functions to load and save tables
as well as providing direct access for file operations.
Separating the user data and the projectdata helps to keep the project
directory clean. Keep in mind that it becomes impossible to save
data in the project directory if the project is compressed
into a single archive. Thus, this system should be favored instead
of direct file access.
The DataRegistry awaits a so called projectkey, which should be
a string that identifies the project. A directory in the data
directory with this name is then created. The additional
filename can contain directorie relations as well. If the
location does not exist, it will automaticly be created.
Methods:
Method overview:
- delete (projectkey,file)
- returns: ()
deletes the given file in the project
directory. Directories are only deleted, if they are empty.
- deleteall (projectkey,[dirpath])
- returns: ()
deletes the whole project or
the given subdirectories.
- dir (projectkey,[dirpath])
- returns: (iterator)
returns a directory
content iterator for the given directory.
- getpath (string projectkey,[string file])
- returns: (path)
returns a valid path that points to the given project path or
to the file in that projectpath
- loadtable (projectkey,file,[table defaulttable])
- returns: ([tab])
returns defaulttable if no matching file could be loaded, otherwise
the file's content is loaded
- makepath (path)
- returns: ()
makes sure that the given path exists
- open (projectkey,file,[mode])
- returns: (filehandle,[errormsg])
returns the filehandle to the given file or nil and the errormessage
if this could not be done
- savetable (projectkey,file,table data)
- returns: ()
writes the given data
table to the file located in the projectpath