Commit Graph

38 Commits

Author SHA1 Message Date
Anna Schumaker a2854ef31e core/file: Remove the CACHE_FILE_INIT macro
It was only used by the testing code, so it's not seeing any use in the
real world.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2018-02-20 15:39:33 -05:00
Anna Schumaker b39c4c9ba4 core/file: File version is OCARINA_MINOR_VERSION
This makes file versioning way easier, since every file will have the
same version.  I'll still need to manage minimum-supported versions, but
that shouldn't be too difficult going forward.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2016-09-26 08:07:35 -04:00
Anna Schumaker 80d921343d core/file: Add support for importing a file into the cache
This will be needed to allow the user to manually set album art from a
downloaded file.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-07-12 14:16:46 -04:00
Anna Schumaker a6bfbbb1c6 core/file: Add file_remove() function
I plan to use this for upgrades to remove obsolete files.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-06-24 10:50:37 -04:00
Anna Schumaker 0344a2088d core/file: Add cache_file_write() function
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-06-24 10:50:37 -04:00
Anna Schumaker 9db9df619f core/file: Add cache_file_close() function
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-06-24 10:50:37 -04:00
Anna Schumaker e137eb0108 core/file: Add cache_file_open() function
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-06-24 10:50:37 -04:00
Anna Schumaker 3723dff87d core/file: Add cache_file_exists() function
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-06-24 10:50:37 -04:00
Anna Schumaker 79ecaa11fb core/file: Add cache_file_write_path() function
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-06-24 10:50:37 -04:00
Anna Schumaker 5dcf681e48 core/file: Add cache_file_path() function
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-06-24 10:50:37 -04:00
Anna Schumaker b5e13af30c core/file: Add cache_file_init() function
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-06-24 10:50:37 -04:00
Anna Schumaker 12949651f7 core/file: Add struct cache_file
I want to reuse as much file code as I can for cache files, but I need a
new struct since data and cache files track different properties.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-06-24 10:50:37 -04:00
Anna Schumaker 9e0f017e61 core/file: Build in minimum version checks
I don't think it makes sense that callers of file_open() are expected to
check the file version after opening.  This should be something handled
by the file code so we can print a consistent error message.

Implements issue #5: Better file versioning
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-06-24 10:50:37 -04:00
Anna Schumaker ee4f0d4c89 core/file: Writes go to a temporary file first
And then rename the temporary file when closed.  This protects users
data in case Ocarina gets killed.

Implements issue #31: Make file writes seem atomic
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-06-24 10:50:37 -04:00
Anna Schumaker 224290d4eb core/file: file->f_name can be a pointer
I'm only setting this to a static string, so it doesn't make sense to
store this as a char array.  Let's use a string pointer instead.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-06-24 10:50:37 -04:00
Anna Schumaker 08394c3168 core/file: Add a C-style initializer macro
I eventually intend to remove the file_init() function, once everything
has been converted to C.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-10-12 08:30:01 -04:00
Anna Schumaker cf6364f5d1 core/file.c: Convert file to C
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-10-12 08:23:06 -04:00
Anna Schumaker 7529ccd4cc core/file: Switch file_readl() to return a gchar *
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-10-12 08:23:06 -04:00
Anna Schumaker 471c773bd5 core/file: Switch file_path() to return a gchar *
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-10-12 08:23:06 -04:00
Anna Schumaker d306c809b6 core/file: Switch file_init() to take a gchar *
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-10-12 08:23:06 -04:00
Anna Schumaker d783c6b479 core/file: Remove NOT_OPEN open mode
I can use the file->f_file pointer for the same thing.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-10-12 08:23:06 -04:00
Anna Schumaker dbd27d1297 core/file: Use a C-style file stream for reading from files
I also introduced a file_readf() function to make it easier to read a
formatted string from the file.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-10-12 08:23:05 -04:00
Anna Schumaker f24da08d85 core/file: Use a C-style file stream for writing to files
I also introduced a file_writef() function to make it easier to write a
formatted string to the file.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-10-12 08:22:36 -04:00
Anna Schumaker 3b220d3f3a core/file: Move file_readl() out of the file struct
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-10-09 09:14:34 -04:00
Anna Schumaker 074339040b core/file: Remove the file struct constructor
And replace it with the function file_init().  Let's take this chance to
rework parts of the unit test as well.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-10-09 09:14:34 -04:00
Anna Schumaker 09c7164aee core/file: Move the close() function out of the file struct
This change also lets me remove the destructor, since code is expected
to call file_close() when IO is complete.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-10-09 09:14:34 -04:00
Anna Schumaker c88b796a7a core/file: Move the open() function out of the file struct
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-10-09 09:14:08 -04:00
Anna Schumaker a88da1dabf core/file: Refactor file opening code
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-10-08 15:46:15 -04:00
Anna Schumaker 7e9eb9e7d2 core/file: Move exists() out of the file struct
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-10-08 15:46:09 -04:00
Anna Schumaker aa21ede894 core/file: Move get_filepath() function out of the file struct
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-10-08 15:45:57 -04:00
Anna Schumaker ce94680d4d core/file: Move get_version() function out of the file struct
This is now a simple function for accessing the current version of the
file.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-10-08 15:45:51 -04:00
Anna Schumaker 1dcc56c87e core/file: Convert class to a struct
In addition, we lowercase variable names and add an f_ prefix to all
struct mebers.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-10-07 10:39:51 -04:00
Anna Schumaker da8131aa6d tests/core: Update file test to new testing framework
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-10-07 08:26:27 -04:00
Anna Schumaker ead1397b31 Remove Doxygen tags
I wasn't actually using Doxygen for anything, so it's probably best just
to remove it.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-09-02 14:24:42 -04:00
Anna Schumaker 47f6684923 file: Update documentation and various cleanups
I add more detailed documentation matching what was in my DESIGN file.
In addition, I also prefix private File members with an underscore like
I do in other Ocarina classes.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2014-11-01 21:56:59 -04:00
Anna Schumaker 7bde6d98aa file: Add doxygen documentation
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2014-09-16 08:22:44 -04:00
Anna Schumaker 9ea0fd4f29 core: Update include file #ifndef guards
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2014-06-21 09:49:07 -04:00
Anna Schumaker 95064e4537 Rename lib/ -> core/
I plan to introduce a new lib/ that sits between the gui and the backend
files (similar to how glibc sits between the kernel and userspace).
This gets the rename out of the way before I change my mind again.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2014-06-05 10:21:32 -04:00