core/file: Rename cache_file_import() -> file_import()
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
e1f13a7ef4
commit
59506d45e7
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -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 *);
|
||||||
|
|
|
@ -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(©));
|
g_assert_false(file_exists(©));
|
||||||
g_assert_false(cache_file_import(©, filepath));
|
g_assert_false(file_import(©, filepath));
|
||||||
g_assert_false(file_exists(©));
|
g_assert_false(file_exists(©));
|
||||||
g_assert_true(file_open(©, OPEN_WRITE_BINARY));
|
g_assert_true( file_open(©, OPEN_WRITE_BINARY));
|
||||||
g_assert_false(cache_file_import(©, NULL));
|
g_assert_false(file_import(©, NULL));
|
||||||
g_assert_true(cache_file_import(©, filepath));
|
g_assert_true( file_import(©, filepath));
|
||||||
g_assert_false(file_exists(©));
|
g_assert_false(file_exists(©));
|
||||||
file_close(©);
|
file_close(©);
|
||||||
g_assert_true(file_exists(©));
|
g_assert_true(file_exists(©));
|
||||||
|
|
Loading…
Reference in New Issue