core/file: Rename cache_file_import() -> file_import()

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
Anna Schumaker 2018-02-27 08:25:40 -05:00
parent e1f13a7ef4
commit 59506d45e7
4 changed files with 9 additions and 9 deletions

View File

@ -246,17 +246,17 @@ int file_write(struct file *file, const void *data, size_t len)
return -1; return -1;
} }
bool cache_file_import(struct file *cache, const gchar *srcpath) bool file_import(struct file *file, const gchar *srcpath)
{ {
gchar *contents = NULL; gchar *contents = NULL;
gsize length = 0; gsize length = 0;
if (!cache->f_file || !srcpath) if (!file->f_file || !srcpath)
return false; return false;
if (!g_file_get_contents(srcpath, &contents, &length, NULL)) if (!g_file_get_contents(srcpath, &contents, &length, NULL))
return false; return false;
file_write(cache, contents, length); file_write(file, contents, length);
return true; return true;
} }

View File

@ -392,7 +392,7 @@ bool album_artwork_import(struct album *album, gchar *path)
file = __album_alloc_file(album); file = __album_alloc_file(album);
if (path && file_open(&file->ac_file, OPEN_WRITE_BINARY)) { if (path && file_open(&file->ac_file, OPEN_WRITE_BINARY)) {
ret = cache_file_import(&file->ac_file, path); ret = file_import(&file->ac_file, path);
file_close(&file->ac_file); file_close(&file->ac_file);
} }
__album_free_file(file); __album_free_file(file);

View File

@ -144,7 +144,7 @@ gchar *file_read(struct file *);
int file_write(struct file *, const void *, size_t); int file_write(struct file *, const void *, size_t);
/* Import a file into the cache. */ /* Import a file into the cache. */
bool cache_file_import(struct file *, const gchar *); bool file_import(struct file *, const gchar *);
/* Removes a closed file from disk. */ /* Removes a closed file from disk. */
bool file_remove(struct file *); bool file_remove(struct file *);

View File

@ -215,11 +215,11 @@ static void test_cache()
/* Test importing a file into the cache. */ /* Test importing a file into the cache. */
g_assert_false(file_exists(&copy)); g_assert_false(file_exists(&copy));
g_assert_false(cache_file_import(&copy, filepath)); g_assert_false(file_import(&copy, filepath));
g_assert_false(file_exists(&copy)); g_assert_false(file_exists(&copy));
g_assert_true(file_open(&copy, OPEN_WRITE_BINARY)); g_assert_true( file_open(&copy, OPEN_WRITE_BINARY));
g_assert_false(cache_file_import(&copy, NULL)); g_assert_false(file_import(&copy, NULL));
g_assert_true(cache_file_import(&copy, filepath)); g_assert_true( file_import(&copy, filepath));
g_assert_false(file_exists(&copy)); g_assert_false(file_exists(&copy));
file_close(&copy); file_close(&copy);
g_assert_true(file_exists(&copy)); g_assert_true(file_exists(&copy));