vfs.c File Reference

#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 <mowgli.h>

Go to the source code of this file.

Classes

struct  LookupNode

Functions

void vfs_set_lookup_func (VFSConstructor *(*func)(const gchar *scheme))
static VFSConstructordo_lookup (const gchar *scheme, gboolean prepare)
void vfs_prepare (const gchar *scheme)
void vfs_prepare_filename (const gchar *path)
void vfs_set_verbose (gboolean set)
static void logger (const gchar *format,...)
VFSFilevfs_fopen (const gchar *path, const gchar *mode)
 Opens a stream from a VFS transport using one of the registered VFSConstructor handlers.
gint vfs_fclose (VFSFile *file)
 Closes a VFS stream and destroys a VFSFile object.
gint64 vfs_fread (void *ptr, gint64 size, gint64 nmemb, VFSFile *file)
 Reads from a VFS stream.
gint64 vfs_fwrite (const void *ptr, gint64 size, gint64 nmemb, VFSFile *file)
 Writes to a VFS stream.
gint vfs_getc (VFSFile *file)
 Reads a character from a VFS stream.
gint vfs_ungetc (gint c, VFSFile *file)
 Pushes a character back to the VFS stream.
gint vfs_fseek (VFSFile *file, gint64 offset, gint whence)
 Performs a seek in given VFS stream.
void vfs_rewind (VFSFile *file)
 Rewinds a VFS stream.
gint64 vfs_ftell (VFSFile *file)
 Returns the current position in the VFS stream's buffer.
gboolean vfs_feof (VFSFile *file)
 Returns whether or not the VFS stream has reached EOF.
gint vfs_ftruncate (VFSFile *file, gint64 length)
 Truncates a VFS stream to a certain size.
gint64 vfs_fsize (VFSFile *file)
 Returns size of the file.
gchar * vfs_get_metadata (VFSFile *file, const gchar *field)
 Returns metadata about the stream.
gboolean vfs_file_test (const gchar *path, GFileTest test)
 Wrapper for g_file_test().
gboolean vfs_is_writeable (const gchar *path)
 Tests if a file is writeable.
VFSFilevfs_dup (VFSFile *in)
 Increments the amount of references that are using this FD.
gboolean vfs_is_remote (const gchar *path)
 Tests if a path is remote uri.
gboolean vfs_is_streaming (VFSFile *file)
 Tests if a file is associated to streaming.

Variables

static GStaticMutex mutex = G_STATIC_MUTEX_INIT
static GThread * lookup_thread = NULL
static VFSConstructor *(* lookup_func )(const gchar *scheme) = NULL
static mowgli_patricia_t * lookup_table = NULL
static gboolean verbose = FALSE

Function Documentation

static VFSConstructor* do_lookup ( const gchar *  scheme,
gboolean  prepare 
) [static]

Definition at line 61 of file vfs.c.

Referenced by vfs_fopen(), and vfs_prepare().

static void logger ( const gchar *  format,
  ... 
) [static]
VFSFile* vfs_dup ( VFSFile in  ) 

Increments the amount of references that are using this FD.

References are removed by calling vfs_fclose on the handle returned from this function. If the amount of references reaches zero, then the file will be closed.

Parameters:
in The VFSFile handle to mark as duplicated.
Returns:
VFSFile handle, which is same as given input.

Definition at line 492 of file vfs.c.

gint 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 200 of file vfs.c.

Referenced by buffered_file_vfs_fclose_impl(), file_find_decoder(), file_read_image(), file_read_tuple(), file_write_tuple(), playback_thread(), probe_buffer_fclose(), save_preset_file(), vfs_buffered_file_new_from_uri(), vfs_buffered_file_release_live_fd(), and vfs_file_get_contents().

gboolean 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 372 of file vfs.c.

Referenced by buffered_file_vfs_feof_impl(), and probe_buffer_feof().

gboolean vfs_file_test ( const gchar *  path,
GFileTest  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 445 of file vfs.c.

Referenced by add_list(), and playlist_remove_failed().

VFSFile* vfs_fopen ( const gchar *  path,
const gchar *  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 155 of file vfs.c.

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

gint64 vfs_fread ( void *  ptr,
gint64  size,
gint64  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 232 of file vfs.c.

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

gint vfs_fseek ( VFSFile file,
gint64  offset,
gint  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 316 of file vfs.c.

Referenced by buffered_file_vfs_fread_impl(), buffered_file_vfs_fseek_impl(), buffered_file_vfs_getc_impl(), import_winamp_eqf(), and probe_func().

gint64 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 407 of file vfs.c.

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

gint64 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 353 of file vfs.c.

Referenced by buffered_file_vfs_fread_impl(), buffered_file_vfs_fseek_impl(), buffered_file_vfs_ftell_impl(), and buffered_file_vfs_getc_impl().

gint vfs_ftruncate ( VFSFile file,
gint64  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 391 of file vfs.c.

gint64 vfs_fwrite ( const void *  ptr,
gint64  size,
gint64  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 254 of file vfs.c.

Referenced by buffered_file_vfs_fwrite_impl(), 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().

gchar* vfs_get_metadata ( VFSFile file,
const gchar *  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 427 of file vfs.c.

Referenced by buffered_file_vfs_metadata_impl(), probe_buffer_get_metadata(), and probe_by_mime().

gint 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 274 of file vfs.c.

Referenced by buffered_file_vfs_getc_impl(), and vfs_fgets().

gboolean vfs_is_remote ( const gchar *  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 508 of file vfs.c.

Referenced by check_opened().

gboolean 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 520 of file vfs.c.

gboolean vfs_is_writeable ( const gchar *  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 469 of file vfs.c.

void vfs_prepare ( const gchar *  scheme  ) 

Definition at line 94 of file vfs.c.

Referenced by vfs_prepare_filename().

void vfs_prepare_filename ( const gchar *  path  ) 

Definition at line 101 of file vfs.c.

Referenced by playback_start(), scan_next(), and vfs_async_file_get_contents().

void vfs_rewind ( VFSFile file  ) 

Rewinds a VFS stream.

Parameters:
file VFSFile object that represents the VFS stream.

Definition at line 336 of file vfs.c.

Referenced by buffered_file_vfs_rewind_impl(), and vfs_buffered_file_new_from_uri().

void vfs_set_lookup_func ( VFSConstructor *(*)(const gchar *scheme)  func  ) 

Definition at line 48 of file vfs.c.

Referenced by start_plugins_one(), and stop_plugins_one().

void vfs_set_verbose ( gboolean  set  ) 

Definition at line 114 of file vfs.c.

Referenced by init_two().

gint vfs_ungetc ( gint  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 292 of file vfs.c.


Variable Documentation

VFSConstructor*(* lookup_func)(const gchar *scheme) = NULL [static]
mowgli_patricia_t* lookup_table = NULL [static]

Definition at line 46 of file vfs.c.

Referenced by do_lookup(), and vfs_set_lookup_func().

GThread* lookup_thread = NULL [static]

Definition at line 44 of file vfs.c.

Referenced by do_lookup(), and vfs_set_lookup_func().

GStaticMutex mutex = G_STATIC_MUTEX_INIT [static]
gboolean verbose = FALSE [static]

Definition at line 112 of file vfs.c.


Generated on 27 Aug 2011 for Audacious by  doxygen 1.6.1