Audacious  $Id:Doxyfile42802007-03-2104:39:00Znenolod$
Classes | Macros | Functions | Variables
vfs.c File Reference
#include <glib.h>
#include <inttypes.h>
#include "vfs.h"
#include "audstrings.h"
#include <stdio.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <string.h>
#include "config.h"

Go to the source code of this file.

Classes

struct  VFSFile
 VFSFile objects describe an opened VFS stream, basically being similar in purpose as stdio FILE More...

Macros

#define VFS_SIG   ('V' | ('F' << 8) | ('S' << 16))

Functions

EXPORT void vfs_set_lookup_func (VFSConstructor *(*func)(const char *scheme))
EXPORT void vfs_set_verbose (bool_t set)
static void logger (const char *format,...)
EXPORT VFSFilevfs_new (const char *path, VFSConstructor *vtable, void *handle)
EXPORT const char * vfs_get_filename (VFSFile *file)
EXPORT void * vfs_get_handle (VFSFile *file)
EXPORT VFSFilevfs_fopen (const char *path, const char *mode)
 Opens a stream from a VFS transport using one of the registered VFSConstructor handlers.
EXPORT int vfs_fclose (VFSFile *file)
 Closes a VFS stream and destroys a VFSFile object.
EXPORT int64_t vfs_fread (void *ptr, int64_t size, int64_t nmemb, VFSFile *file)
 Reads from a VFS stream.
EXPORT int64_t vfs_fwrite (const void *ptr, int64_t size, int64_t nmemb, VFSFile *file)
 Writes to a VFS stream.
EXPORT int vfs_getc (VFSFile *file)
 Reads a character from a VFS stream.
EXPORT int vfs_ungetc (int c, VFSFile *file)
 Pushes a character back to the VFS stream.
EXPORT int vfs_fseek (VFSFile *file, int64_t offset, int whence)
 Performs a seek in given VFS stream.
EXPORT void vfs_rewind (VFSFile *file)
 Rewinds a VFS stream.
EXPORT int64_t vfs_ftell (VFSFile *file)
 Returns the current position in the VFS stream's buffer.
EXPORT bool_t vfs_feof (VFSFile *file)
 Returns whether or not the VFS stream has reached EOF.
EXPORT int vfs_ftruncate (VFSFile *file, int64_t length)
 Truncates a VFS stream to a certain size.
EXPORT int64_t vfs_fsize (VFSFile *file)
 Returns size of the file.
EXPORT char * vfs_get_metadata (VFSFile *file, const char *field)
 Returns metadata about the stream.
EXPORT bool_t vfs_file_test (const char *path, int test)
 Wrapper for g_file_test().
EXPORT bool_t vfs_is_writeable (const char *path)
 Tests if a file is writeable.
EXPORT bool_t vfs_is_remote (const char *path)
 Tests if a path is remote uri.
EXPORT bool_t vfs_is_streaming (VFSFile *file)
 Tests if a file is associated to streaming.

Variables

static VFSConstructor *(* lookup_func )(const char *scheme) = NULL
static bool_t verbose = FALSE

Macro Definition Documentation

#define VFS_SIG   ('V' | ('F' << 8) | ('S' << 16))

Function Documentation

static void logger ( const char *  format,
  ... 
)
static
EXPORT int vfs_fclose ( VFSFile file)

Closes a VFS stream and destroys a VFSFile object.

Parameters:
fileA VFSFile object to destroy.
Returns:
-1 on failure, 0 on success.

Definition at line 166 of file vfs.c.

Referenced by file_find_decoder(), file_read_image(), file_read_tuple(), file_write_tuple(), playback_thread(), playlist_load(), playlist_save(), probe_buffer_fclose(), save_preset_file(), and vfs_file_get_contents().

EXPORT bool_t vfs_feof ( VFSFile file)

Returns whether or not the VFS stream has reached EOF.

Parameters:
fileVFSFile object that represents the VFS stream.
Returns:
On success, whether or not the VFS stream is at EOF. Otherwise, FALSE.

Definition at line 335 of file vfs.c.

Referenced by probe_buffer_feof().

EXPORT bool_t vfs_file_test ( const char *  path,
int  test 
)

Wrapper for g_file_test().

Parameters:
pathA path to test.
testA GFileTest to run.
Returns:
The result of g_file_test().

Definition at line 408 of file vfs.c.

Referenced by add_generic(), and playlist_remove_failed().

EXPORT VFSFile* vfs_fopen ( const char *  path,
const char *  mode 
)

Opens a stream from a VFS transport using one of the registered VFSConstructor handlers.

Parameters:
pathThe path or URI to open.
modeThe preferred access privileges (not guaranteed).
Returns:
On success, a VFSFile object representing the stream.

Definition at line 124 of file vfs.c.

Referenced by check_opened(), file_read_image(), file_read_tuple(), file_write_tuple(), playback_thread(), playlist_load(), playlist_save(), probe_buffer_new(), save_preset_file(), and vfs_file_get_contents().

EXPORT int64_t vfs_fread ( void *  ptr,
int64_t  size,
int64_t  nmemb,
VFSFile file 
)

Reads from a VFS stream.

Parameters:
ptrA pointer to the destination buffer.
sizeThe size of each element to read.
nmembThe number of elements to read.
fileVFSFile object that represents the VFS stream.
Returns:
The number of elements succesfully read.

Definition at line 195 of file vfs.c.

Referenced by import_winamp_eqf(), increase_buffer(), vfs_fget_be16(), vfs_fget_be32(), vfs_fget_be64(), vfs_fget_le16(), vfs_fget_le32(), vfs_fget_le64(), and vfs_file_get_contents().

EXPORT int vfs_fseek ( VFSFile file,
int64_t  offset,
int  whence 
)

Performs a seek in given VFS stream.

Standard C-style values of whence can be used to indicate desired action.

  • SEEK_CUR seeks relative to current stream position.
  • SEEK_SET seeks to given absolute position (relative to stream beginning).
  • SEEK_END sets stream position to current file end.
Parameters:
fileVFSFile object that represents the VFS stream.
offsetThe offset to seek to.
whenceType of the seek: SEEK_CUR, SEEK_SET or SEEK_END.
Returns:
On success, 0. Otherwise, -1.

Definition at line 279 of file vfs.c.

Referenced by import_winamp_eqf(), and probe_func().

EXPORT int64_t vfs_fsize ( VFSFile file)

Returns size of the file.

Parameters:
fileVFSFile object that represents the VFS stream.
Returns:
On success, the size of the file in bytes. Otherwise, -1.

Definition at line 370 of file vfs.c.

Referenced by probe_buffer_fsize(), vfs_file_get_contents(), and vfs_is_streaming().

EXPORT int64_t vfs_ftell ( VFSFile file)

Returns the current position in the VFS stream's buffer.

Parameters:
fileVFSFile object that represents the VFS stream.
Returns:
On success, the current position. Otherwise, -1.

Definition at line 316 of file vfs.c.

EXPORT int vfs_ftruncate ( VFSFile file,
int64_t  length 
)

Truncates a VFS stream to a certain size.

Parameters:
fileVFSFile object that represents the VFS stream.
lengthThe length to truncate at.
Returns:
On success, 0. Otherwise, -1.

Definition at line 354 of file vfs.c.

EXPORT int64_t vfs_fwrite ( const void *  ptr,
int64_t  size,
int64_t  nmemb,
VFSFile file 
)

Writes to a VFS stream.

Parameters:
ptrA const pointer to the source buffer.
sizeThe size of each element to write.
nmembThe number of elements to write.
fileVFSFile object that represents the VFS stream.
Returns:
The number of elements succesfully written.

Definition at line 217 of file vfs.c.

Referenced by save_preset_file(), vfs_fput_be16(), vfs_fput_be32(), vfs_fput_be64(), vfs_fput_le16(), vfs_fput_le32(), vfs_fput_le64(), vfs_fputc(), and vfs_fputs().

EXPORT const char* vfs_get_filename ( VFSFile file)

Definition at line 105 of file vfs.c.

Referenced by import_winamp_eqf().

EXPORT void* vfs_get_handle ( VFSFile file)
EXPORT char* vfs_get_metadata ( VFSFile file,
const char *  field 
)

Returns metadata about the stream.

Parameters:
fileVFSFile object that represents the VFS stream.
fieldThe string constant field name to get.
Returns:
On success, a copy of the value of the field. Otherwise, NULL.

Definition at line 390 of file vfs.c.

Referenced by probe_buffer_get_metadata(), and probe_by_mime().

EXPORT int vfs_getc ( VFSFile file)

Reads a character from a VFS stream.

Parameters:
fileVFSFile object that represents the VFS stream.
Returns:
On success, a character. Otherwise, EOF.

Definition at line 237 of file vfs.c.

Referenced by vfs_fgets().

EXPORT bool_t vfs_is_remote ( const char *  path)

Tests if a path is remote uri.

Parameters:
pathA path to test.
Returns:
TRUE if the file is remote, otherwise FALSE.

Definition at line 476 of file vfs.c.

Referenced by check_opened().

EXPORT bool_t vfs_is_streaming ( VFSFile file)

Tests if a file is associated to streaming.

Parameters:
fileA VFSFile object to test.
Returns:
TRUE if the file is streaming, otherwise FALSE.

Definition at line 487 of file vfs.c.

EXPORT bool_t vfs_is_writeable ( const char *  path)

Tests if a file is writeable.

Parameters:
pathA path to test.
Returns:
TRUE if the file is writeable, otherwise FALSE.

Definition at line 457 of file vfs.c.

EXPORT VFSFile* vfs_new ( const char *  path,
VFSConstructor vtable,
void *  handle 
)

Definition at line 95 of file vfs.c.

Referenced by probe_buffer_new(), and vfs_fopen().

EXPORT void vfs_rewind ( VFSFile file)

Rewinds a VFS stream.

Parameters:
fileVFSFile object that represents the VFS stream.

Definition at line 299 of file vfs.c.

EXPORT void vfs_set_lookup_func ( VFSConstructor *(*)(const char *scheme)  func)

Definition at line 56 of file vfs.c.

Referenced by start_plugins_one(), and stop_plugins_one().

EXPORT void vfs_set_verbose ( bool_t  set)

Definition at line 63 of file vfs.c.

Referenced by init_two().

EXPORT int vfs_ungetc ( int  c,
VFSFile file 
)

Pushes a character back to the VFS stream.

Parameters:
cThe character to push back.
fileVFSFile object that represents the VFS stream.
Returns:
On success, 0. Otherwise, EOF.

Definition at line 255 of file vfs.c.


Variable Documentation

VFSConstructor*(* lookup_func)(const char *scheme) = NULL
static

Definition at line 54 of file vfs.c.

Referenced by vfs_fopen(), and vfs_set_lookup_func().

bool_t verbose = FALSE
static

Definition at line 61 of file vfs.c.

Referenced by init_two(), and parse_options().