Mercurial > audlegacy
diff libaudacious/vfs_stdio.c @ 1975:976da06332df trunk
[svn] - newvfs code, part 1
author | nenolod |
---|---|
date | Thu, 16 Nov 2006 11:20:07 -0800 |
parents | e9c24e35bd76 |
children | 93c59698f5fd |
line wrap: on
line diff
--- a/libaudacious/vfs_stdio.c Thu Nov 16 10:53:21 2006 -0800 +++ b/libaudacious/vfs_stdio.c Thu Nov 16 11:20:07 2006 -0800 @@ -20,20 +20,8 @@ #include <sys/stat.h> #include <sys/types.h> - -struct _VFSFile { - FILE *handle; -}; - - -gboolean -vfs_init(void) -{ - return TRUE; -} - VFSFile * -vfs_fopen(const gchar * path, +stdio_vfs_fopen_impl(const gchar * path, const gchar * mode) { VFSFile *file; @@ -54,7 +42,7 @@ } gint -vfs_fclose(VFSFile * file) +stdio_vfs_fclose_impl(VFSFile * file) { gint ret = 0; @@ -72,7 +60,7 @@ } size_t -vfs_fread(gpointer ptr, +stdio_vfs_fread_impl(gpointer ptr, size_t size, size_t nmemb, VFSFile * file) @@ -84,7 +72,7 @@ } size_t -vfs_fwrite(gconstpointer ptr, +stdio_vfs_fwrite_impl(gconstpointer ptr, size_t size, size_t nmemb, VFSFile * file) @@ -96,19 +84,19 @@ } gint -vfs_getc(VFSFile *stream) +stdio_vfs_getc_impl(VFSFile *stream) { return getc( stream->handle ); } gint -vfs_ungetc(gint c, VFSFile *stream) +stdio_vfs_ungetc_impl(gint c, VFSFile *stream) { return ungetc( c , stream->handle ); } gint -vfs_fseek(VFSFile * file, +stdio_vfs_fseek_impl(VFSFile * file, glong offset, gint whence) { @@ -119,7 +107,7 @@ } void -vfs_rewind(VFSFile * file) +stdio_vfs_rewind_impl(VFSFile * file) { if (file == NULL) return; @@ -128,7 +116,7 @@ } glong -vfs_ftell(VFSFile * file) +stdio_vfs_ftell_impl(VFSFile * file) { if (file == NULL) return 0; @@ -137,7 +125,7 @@ } gboolean -vfs_feof(VFSFile * file) +stdio_vfs_feof_impl(VFSFile * file) { if (file == NULL) return FALSE; @@ -145,29 +133,51 @@ return (gboolean) feof(file->handle); } -gboolean -vfs_file_test(const gchar * path, GFileTest test) -{ - return g_file_test(path, test); -} - -/* NOTE: stat() is not part of stdio */ -gboolean -vfs_is_writeable(const gchar * path) -{ - struct stat info; - - if (stat(path, &info) == -1) - return FALSE; - - return (info.st_mode & S_IWUSR); -} - gint -vfs_truncate(VFSFile * file, glong size) +stdio_vfs_truncate_impl(VFSFile * file, glong size) { if (file == NULL) return -1; return ftruncate(fileno(file->handle), size); } + +VFSConstructor file_const = { + "file://", + stdio_vfs_fopen_impl, + stdio_vfs_fclose_impl, + stdio_vfs_fread_impl, + stdio_vfs_fwrite_impl, + stdio_vfs_getc_impl, + stdio_vfs_ungetc_impl, + stdio_vfs_fseek_impl, + stdio_vfs_rewind_impl, + stdio_vfs_ftell_impl, + stdio_vfs_feof_impl, + stdio_vfs_truncate_impl +}; + +VFSConstructor default_const = { + "/", + stdio_vfs_fopen_impl, + stdio_vfs_fclose_impl, + stdio_vfs_fread_impl, + stdio_vfs_fwrite_impl, + stdio_vfs_getc_impl, + stdio_vfs_ungetc_impl, + stdio_vfs_fseek_impl, + stdio_vfs_rewind_impl, + stdio_vfs_ftell_impl, + stdio_vfs_feof_impl, + stdio_vfs_truncate_impl +}; + +#if 0 +gboolean +vfs_init(void) +{ + vfs_register_transport(&default_const); + vfs_register_transport(&file_const); + return TRUE; +} +#endif