Functions | Variables

vfs.c File Reference

#include "vfs.h"
#include "audstrings.h"
#include <stdio.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <string.h>

Go to the source code of this file.

Functions

void vfs_register_transport (VFSConstructor *vtable)
 Registers a VFSConstructor vtable with the VFS system.
static VFSConstructorvfs_get_constructor (const gchar *path)
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.
glong 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

GList * vfs_transports = NULL
 GList of VFSConstructor objects holding all the registered VFS transports.

Function Documentation

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 365 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 110 of file vfs.c.

Referenced by buffered_file_vfs_fclose_impl(), file_find_decoder(), file_read_image(), file_read_tuple(), file_write_tuple(), playback_monitor_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 254 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 318 of file vfs.c.

Referenced by add_list().

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

Referenced by check_opened(), file_read_image(), file_read_tuple(), file_write_tuple(), playback_monitor_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 138 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 208 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 284 of file vfs.c.

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

glong 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 239 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 269 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 155 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().

static VFSConstructor* vfs_get_constructor ( const gchar *  path  )  [static]

Definition at line 47 of file vfs.c.

Referenced by vfs_fopen(), and vfs_is_remote().

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 300 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, -1.

Definition at line 170 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 381 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 402 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 342 of file vfs.c.

void vfs_register_transport ( VFSConstructor vtable  ) 

Registers a VFSConstructor vtable with the VFS system.

Parameters:
vtable The VFSConstructor vtable to register.

Definition at line 41 of file vfs.c.

void vfs_rewind ( VFSFile file  ) 

Rewinds a VFS stream.

Parameters:
file VFSFile object that represents the VFS stream.

Definition at line 224 of file vfs.c.

Referenced by buffered_file_vfs_rewind_impl(), and vfs_buffered_file_new_from_uri().

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

Definition at line 186 of file vfs.c.


Variable Documentation

GList* vfs_transports = NULL

GList of VFSConstructor objects holding all the registered VFS transports.

Definition at line 33 of file vfs.c.

Referenced by plugin_system_cleanup(), vfs_get_constructor(), and vfs_register_transport().