foobar2000_io::file Class Reference

#include <filesystem.h>

Inheritance diagram for foobar2000_io::file:

service_base foobar2000_io::stream_reader foobar2000_io::stream_writer foobar2000_io::file_dynamicinfo

List of all members.

Public Types

enum  t_seek_mode { seek_from_beginning = 0, seek_from_current = 1, seek_from_eof = 2 }
 Seeking mode constants. Note: these are purposedly defined to same values as standard C SEEK_* constants. More...
typedef file t_interface
typedef service_base t_interface_parent

Public Member Functions

virtual t_filesize get_size (abort_callback &p_abort)=0
virtual t_filesize get_position (abort_callback &p_abort)=0
virtual void resize (t_filesize p_size, abort_callback &p_abort)=0
virtual void seek (t_filesize p_position, abort_callback &p_abort)=0
virtual void seek_ex (t_sfilesize p_position, t_seek_mode p_mode, abort_callback &p_abort)
virtual bool can_seek ()=0
 Returns whether the file is seekable or not. If can_seek() returns false, all seek() or seek_ex() calls will fail; reopen() is still usable on nonseekable streams.
virtual bool get_content_type (pfc::string_base &p_out)=0
virtual bool is_in_memory ()
 Hint, returns whether the file is already fully buffered into memory.
virtual void on_idle (abort_callback &p_abort)
virtual t_filetimestamp get_timestamp (abort_callback &p_abort)
virtual void reopen (abort_callback &p_abort)=0
virtual bool is_remote ()=0
 Indicates whether the file is a remote resource and non-sequential access may be slowed down by lag. This is typically returns to true on non-seekable sources but may also return true on seekable sources indicating that seeking is supported but will be relatively slow.
t_filestats get_stats (abort_callback &p_abort)
 Retrieves file stats structure. Usese get_size() and get_timestamp().
bool is_eof (abort_callback &p_abort)
 Returns whether read/write cursor position is at the end of file.
void truncate (t_filesize p_position, abort_callback &p_abort)
 Truncates file to specified size (while preserving read/write cursor position if possible); uses set_eof().
void set_eof (abort_callback &p_abort)
 Truncates the file at current read/write cursor position.
t_filesize get_size_ex (abort_callback &p_abort)
 Helper; retrieves size of the file. If size is not available (get_size() returns filesize_invalid), throws exception_io_no_length.
t_filesize get_remaining (abort_callback &p_abort)
 Helper; retrieves amount of bytes between read/write cursor position and end of file. Fails when length can't be determined.
void ensure_seekable ()
 Helper; throws exception_io_object_not_seekable if file is not seekable.
void ensure_local ()
 Helper; throws exception_io_object_is_remote if the file is remote.

Static Public Member Functions

static t_filesize g_transfer (stream_reader *src, stream_writer *dst, t_filesize bytes, abort_callback &p_abort)
static void g_transfer_object (stream_reader *src, stream_writer *dst, t_filesize bytes, abort_callback &p_abort)
 Helper; transfers specified number of bytes between streams. Throws exception if requested number of bytes could not be read (EOF).
static void g_transfer_file (const service_ptr_t< file > &p_from, const service_ptr_t< file > &p_to, abort_callback &p_abort)
 Helper; transfers entire file content from one file to another, erasing previous content.
static t_filesize g_transfer (service_ptr_t< file > p_src, service_ptr_t< file > p_dst, t_filesize p_bytes, abort_callback &p_abort)
 Helper; improved performance over g_transfer on streams (avoids disk fragmentation when transferring large blocks).
static void g_transfer_object (service_ptr_t< file > p_src, service_ptr_t< file > p_dst, t_filesize p_bytes, abort_callback &p_abort)
 Helper; improved performance over g_transfer_file on streams (avoids disk fragmentation when transferring large blocks).

Static Public Attributes

static const GUID class_guid


Detailed Description

A class providing abstraction for an open file object, with reading/writing/seeking methods. See also: stream_reader, stream_writer (which it inherits read/write methods from).
Error handling: all methods may throw exception_io or one of derivatives on failure; exception_aborted when abort_callback is signaled.

Member Typedef Documentation

Reimplemented from service_base.

Reimplemented in foobar2000_io::file_dynamicinfo.


Member Enumeration Documentation

Seeking mode constants. Note: these are purposedly defined to same values as standard C SEEK_* constants.

Enumerator:
seek_from_beginning  Seek relative to beginning of file (same as seeking to absolute offset).
seek_from_current  Seek relative to current position.
seek_from_eof  Seek relative to end of file.


Member Function Documentation

virtual t_filesize foobar2000_io::file::get_size ( abort_callback p_abort  )  [pure virtual]

Retrieves size of the file.

Parameters:
p_abort abort_callback object signaling user aborting the operation.
Returns:
File size on success; filesize_invalid if unknown (nonseekable stream etc).

virtual t_filesize foobar2000_io::file::get_position ( abort_callback p_abort  )  [pure virtual]

Retrieves read/write cursor position in the file. In case of non-seekable stream, this should return number of bytes read so far since open/reopen call.

Parameters:
p_abort abort_callback object signaling user aborting the operation.
Returns:
Read/write cursor position

virtual void foobar2000_io::file::resize ( t_filesize  p_size,
abort_callback p_abort 
) [pure virtual]

Resizes file to specified size in bytes.

Parameters:
p_abort abort_callback object signaling user aborting the operation.

virtual void foobar2000_io::file::seek ( t_filesize  p_position,
abort_callback p_abort 
) [pure virtual]

Sets read/write cursor position to specific offset.

Parameters:
p_position position to seek to.
p_abort abort_callback object signaling user aborting the operation.

virtual void foobar2000_io::file::seek_ex ( t_sfilesize  p_position,
t_seek_mode  p_mode,
abort_callback p_abort 
) [virtual]

Sets read/write cursor position to specific offset; extended form allowing seeking relative to current position or to end of file.

Parameters:
p_position Position to seek to; interpretation of this value depends on p_mode parameter.
p_mode Seeking mode; see t_seek_mode enum values for further description.
p_abort abort_callback object signaling user aborting the operation.

virtual bool foobar2000_io::file::can_seek (  )  [pure virtual]

Returns whether the file is seekable or not. If can_seek() returns false, all seek() or seek_ex() calls will fail; reopen() is still usable on nonseekable streams.

virtual bool foobar2000_io::file::get_content_type ( pfc::string_base p_out  )  [pure virtual]

Retrieves mime type of the file.

Parameters:
p_out Receives content type string on success.

virtual bool foobar2000_io::file::is_in_memory (  )  [inline, virtual]

Hint, returns whether the file is already fully buffered into memory.

virtual void foobar2000_io::file::on_idle ( abort_callback p_abort  )  [inline, virtual]

Optional, called by owner thread before sleeping.

Parameters:
p_abort abort_callback object signaling user aborting the operation.

virtual t_filetimestamp foobar2000_io::file::get_timestamp ( abort_callback p_abort  )  [inline, virtual]

Retrieves last modification time of the file.

Parameters:
p_abort abort_callback object signaling user aborting the operation.
Returns:
Last modification time o fthe file; filetimestamp_invalid if N/A.

virtual void foobar2000_io::file::reopen ( abort_callback p_abort  )  [pure virtual]

Resets non-seekable stream, or seeks to zero on seekable file.

Parameters:
p_abort abort_callback object signaling user aborting the operation.

virtual bool foobar2000_io::file::is_remote (  )  [pure virtual]

Indicates whether the file is a remote resource and non-sequential access may be slowed down by lag. This is typically returns to true on non-seekable sources but may also return true on seekable sources indicating that seeking is supported but will be relatively slow.

t_filestats foobar2000_io::file::get_stats ( abort_callback p_abort  ) 

Retrieves file stats structure. Usese get_size() and get_timestamp().

bool foobar2000_io::file::is_eof ( abort_callback p_abort  ) 

Returns whether read/write cursor position is at the end of file.

void foobar2000_io::file::truncate ( t_filesize  p_position,
abort_callback p_abort 
)

Truncates file to specified size (while preserving read/write cursor position if possible); uses set_eof().

void foobar2000_io::file::set_eof ( abort_callback p_abort  )  [inline]

Truncates the file at current read/write cursor position.

t_filesize foobar2000_io::file::get_size_ex ( abort_callback p_abort  ) 

Helper; retrieves size of the file. If size is not available (get_size() returns filesize_invalid), throws exception_io_no_length.

t_filesize foobar2000_io::file::get_remaining ( abort_callback p_abort  ) 

Helper; retrieves amount of bytes between read/write cursor position and end of file. Fails when length can't be determined.

void foobar2000_io::file::ensure_seekable (  ) 

Helper; throws exception_io_object_not_seekable if file is not seekable.

void foobar2000_io::file::ensure_local (  ) 

Helper; throws exception_io_object_is_remote if the file is remote.

static t_filesize foobar2000_io::file::g_transfer ( stream_reader src,
stream_writer dst,
t_filesize  bytes,
abort_callback p_abort 
) [static]

Helper; transfers specified number of bytes between streams.

Returns:
number of bytes actually transferred. May be less than requested if e.g. EOF is reached.

static void foobar2000_io::file::g_transfer_object ( stream_reader src,
stream_writer dst,
t_filesize  bytes,
abort_callback p_abort 
) [static]

Helper; transfers specified number of bytes between streams. Throws exception if requested number of bytes could not be read (EOF).

static void foobar2000_io::file::g_transfer_file ( const service_ptr_t< file > &  p_from,
const service_ptr_t< file > &  p_to,
abort_callback p_abort 
) [static]

Helper; transfers entire file content from one file to another, erasing previous content.

static t_filesize foobar2000_io::file::g_transfer ( service_ptr_t< file p_src,
service_ptr_t< file p_dst,
t_filesize  p_bytes,
abort_callback p_abort 
) [static]

Helper; improved performance over g_transfer on streams (avoids disk fragmentation when transferring large blocks).

static void foobar2000_io::file::g_transfer_object ( service_ptr_t< file p_src,
service_ptr_t< file p_dst,
t_filesize  p_bytes,
abort_callback p_abort 
) [static]

Helper; improved performance over g_transfer_file on streams (avoids disk fragmentation when transferring large blocks).


Member Data Documentation

const GUID file::class_guid [static]

Initial value:

 
{ 0xb2f9fc40, 0x3e55, 0x4b23, { 0xa2, 0xc9, 0x22, 0xba, 0xad, 0x87, 0x95, 0xb1 } }

Reimplemented in foobar2000_io::file_dynamicinfo.


The documentation for this class was generated from the following files:

Generated on Fri Apr 18 13:56:59 2008 for foobar2000 SDK by  doxygen 1.5.5