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...

Defines

#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

Define 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:
file A VFSFile object to destroy.
Returns:
-1 on failure, 0 on success.

Definition at line 167 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:
file VFSFile object that represents the VFS stream.
Returns:
On success, whether or not the VFS stream is at EOF. Otherwise, FALSE.

Definition at line 336 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:
path A path to test.
test A GFileTest to run.
Returns:
The result of g_file_test().

Definition at line 409 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:
path The path or URI to open.
mode The preferred access privileges (not guaranteed).
Returns:
On success, a VFSFile object representing the stream.

Definition at line 125 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:
ptr A pointer to the destination buffer.
size The size of each element to read.
nmemb The number of elements to read.
file VFSFile object that represents the VFS stream.
Returns:
The number of elements succesfully read.

Definition at line 196 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:
file VFSFile object that represents the VFS stream.
offset The offset to seek to.
whence Type of the seek: SEEK_CUR, SEEK_SET or SEEK_END.
Returns:
On success, 0. Otherwise, -1.

Definition at line 280 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:
file VFSFile object that represents the VFS stream.
Returns:
On success, the size of the file in bytes. Otherwise, -1.

Definition at line 371 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:
file VFSFile object that represents the VFS stream.
Returns:
On success, the current position. Otherwise, -1.

Definition at line 317 of file vfs.c.

EXPORT int vfs_ftruncate ( VFSFile file,
int64_t  length 
)

Truncates a VFS stream to a certain size.

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

Definition at line 355 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:
ptr A const pointer to the source buffer.
size The size of each element to write.
nmemb The number of elements to write.
file VFSFile object that represents the VFS stream.
Returns:
The number of elements succesfully written.

Definition at line 218 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 106 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:
file VFSFile object that represents the VFS stream.
field The string constant field name to get.
Returns:
On success, a copy of the value of the field. Otherwise, NULL.

Definition at line 391 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:
file VFSFile object that represents the VFS stream.
Returns:
On success, a character. Otherwise, EOF.

Definition at line 238 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:
path A path to test.
Returns:
TRUE if the file is remote, otherwise FALSE.

Definition at line 452 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:
file A VFSFile object to test.
Returns:
TRUE if the file is streaming, otherwise FALSE.

Definition at line 463 of file vfs.c.

EXPORT bool_t vfs_is_writeable ( const char *  path  ) 

Tests if a file is writeable.

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

Definition at line 433 of file vfs.c.

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

Definition at line 96 of file vfs.c.

Referenced by probe_buffer_new(), and vfs_fopen().

EXPORT void vfs_rewind ( VFSFile file  ) 

Rewinds a VFS stream.

Parameters:
file VFSFile object that represents the VFS stream.

Definition at line 300 of file vfs.c.

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

Definition at line 57 of file vfs.c.

Referenced by start_plugins_one(), and stop_plugins_one().

EXPORT void vfs_set_verbose ( bool_t  set  ) 

Definition at line 64 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:
c The character to push back.
file VFSFile object that represents the VFS stream.
Returns:
On success, 0. Otherwise, EOF.

Definition at line 256 of file vfs.c.


Variable Documentation

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

Referenced by vfs_fopen(), and vfs_set_lookup_func().

bool_t verbose = FALSE [static]

Definition at line 62 of file vfs.c.

Referenced by init_two(), and parse_options().


Generated on 21 Aug 2012 for Audacious by  doxygen 1.6.1