|
foobar2000 SDK
2015-01-14
|
#include <filesystem.h>
Inheritance diagram for foobar2000_io::file:Public Types | |
| enum | t_seek_mode { seek_from_beginning = 0, seek_from_current = 1, seek_from_eof = 2 } |
Public Types inherited from service_base | |
| typedef service_base | t_interface |
Public Member Functions | |
| virtual bool | can_seek ()=0 |
| void | ensure_local () |
| void | ensure_seekable () |
| FB2K_MAKE_SERVICE_INTERFACE (file, service_base) | |
| virtual bool | get_content_type (pfc::string_base &p_out)=0 |
| virtual t_filesize | get_position (abort_callback &p_abort)=0 |
| t_filesize | get_remaining (abort_callback &p_abort) |
| virtual t_filesize | get_size (abort_callback &p_abort)=0 |
| t_filesize | get_size_ex (abort_callback &p_abort) |
| t_filestats | get_stats (abort_callback &p_abort) |
| virtual t_filetimestamp | get_timestamp (abort_callback &p_abort) |
| bool | is_eof (abort_callback &p_abort) |
| virtual bool | is_in_memory () |
| virtual bool | is_remote ()=0 |
| virtual void | on_idle (abort_callback &p_abort) |
| void | probe_remaining (t_filesize bytes, abort_callback &p_abort) |
| virtual void | reopen (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) |
| void | seek_probe (t_filesize p_position, abort_callback &p_abort) |
| void | set_eof (abort_callback &p_abort) |
| t_filesize | skip (t_filesize p_bytes, abort_callback &p_abort) |
| t_filesize | skip_seek (t_filesize p_bytes, abort_callback &p_abort) |
| void | truncate (t_filesize p_position, abort_callback &p_abort) |
Public Member Functions inherited from service_base | |
| template<typename outPtr_t > | |
| bool | cast (outPtr_t &outPtr) |
| virtual int | service_add_ref ()=0 throw () |
| virtual bool | service_query (service_ptr_t< service_base > &p_out, const GUID &p_guid) |
| template<class T > | |
| bool | service_query_t (service_ptr_t< T > &p_out) |
| virtual int | service_release ()=0 throw () |
Public Member Functions inherited from foobar2000_io::stream_reader | |
| virtual t_size | read (void *p_buffer, t_size p_bytes, abort_callback &p_abort)=0 |
| template<typename T > | |
| void | read_bendian_t (T &p_object, abort_callback &p_abort) |
| template<typename T > | |
| void | read_lendian_t (T &p_object, abort_callback &p_abort) |
| virtual void | read_object (void *p_buffer, t_size p_bytes, abort_callback &p_abort) |
| template<typename T > | |
| void | read_object_t (T &p_object, abort_callback &p_abort) |
| void | read_string (pfc::string_base &p_out, abort_callback &p_abort) |
| pfc::string | read_string (abort_callback &p_abort) |
| void | read_string_ex (pfc::string_base &p_out, t_size p_bytes, abort_callback &p_abort) |
| pfc::string | read_string_ex (t_size p_len, abort_callback &p_abort) |
| void | read_string_nullterm (pfc::string_base &out, abort_callback &abort) |
| void | read_string_raw (pfc::string_base &p_out, abort_callback &p_abort) |
| template<typename t_outArray > | |
| void | read_till_eof (t_outArray &out, abort_callback &abort) |
| virtual void | skip_object (t_filesize p_bytes, abort_callback &p_abort) |
| t_filesize | skip_till_eof (abort_callback &abort) |
Public Member Functions inherited from foobar2000_io::stream_writer | |
| virtual void | write (const void *p_buffer, t_size p_bytes, abort_callback &p_abort)=0 |
| template<typename T > | |
| void | write_bendian_t (const T &p_object, abort_callback &p_abort) |
| template<typename T > | |
| void | write_lendian_t (const T &p_object, abort_callback &p_abort) |
| void | write_object (const void *p_buffer, t_size p_bytes, abort_callback &p_abort) |
| template<typename T > | |
| void | write_object_t (const T &p_object, abort_callback &p_abort) |
| void | write_string (const char *p_string, abort_callback &p_abort) |
| void | write_string (const char *p_string, t_size p_len, abort_callback &p_abort) |
| template<typename T > | |
| void | write_string (const T &val, abort_callback &p_abort) |
| void | write_string_nullterm (const char *p_string, abort_callback &p_abort) |
| void | write_string_raw (const char *p_string, abort_callback &p_abort) |
Static Public Member Functions | |
| static t_filesize | g_transfer (stream_reader *src, stream_writer *dst, t_filesize bytes, abort_callback &p_abort) |
| 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) |
| static void | g_transfer_file (const service_ptr_t< file > &p_from, const service_ptr_t< file > &p_to, abort_callback &p_abort) |
| static void | g_transfer_object (stream_reader *src, stream_writer *dst, t_filesize bytes, abort_callback &p_abort) |
| 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) |
Additional Inherited Members | |
Protected Member Functions inherited from service_base | |
| service_base () | |
| ~service_base () | |
Protected Member Functions inherited from foobar2000_io::stream_reader | |
| stream_reader () | |
| ~stream_reader () | |
Protected Member Functions inherited from foobar2000_io::stream_writer | |
| stream_writer () | |
| ~stream_writer () | |
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.
Definition at line 203 of file filesystem.h.
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. |
Definition at line 207 of file filesystem.h.
|
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.
| void file::ensure_local | ( | ) |
Helper; throws exception_io_object_is_remote if the file is remote.
Definition at line 839 of file filesystem.cpp.
| void file::ensure_seekable | ( | ) |
Helper; throws exception_io_object_not_seekable if file is not seekable.
Definition at line 843 of file filesystem.cpp.
| foobar2000_io::file::FB2K_MAKE_SERVICE_INTERFACE | ( | file | , |
| service_base | |||
| ) |
|
static |
Helper; transfers specified number of bytes between streams.
|
static |
Helper; improved performance over g_transfer on streams (avoids disk fragmentation when transferring large blocks).
Definition at line 868 of file filesystem.cpp.
|
static |
Helper; transfers entire file content from one file to another, erasing previous content.
Definition at line 625 of file filesystem.cpp.
|
static |
Helper; transfers specified number of bytes between streams. Throws exception if requested number of bytes could not be read (EOF).
|
static |
Helper; improved performance over g_transfer_file on streams (avoids disk fragmentation when transferring large blocks).
Definition at line 872 of file filesystem.cpp.
|
pure virtual |
Retrieves mime type of the file.
| p_out | Receives content type string on success. |
|
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.
| p_abort | abort_callback object signaling user aborting the operation. |
| t_filesize 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.
Definition at line 852 of file filesystem.cpp.
|
pure virtual |
Retrieves size of the file.
| p_abort | abort_callback object signaling user aborting the operation. |
| t_filesize 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.
Definition at line 833 of file filesystem.cpp.
| t_filestats file::get_stats | ( | abort_callback & | p_abort | ) |
Retrieves file stats structure. Uses get_size() and get_timestamp().
Definition at line 594 of file filesystem.cpp.
|
inlinevirtual |
Retrieves last modification time of the file.
| p_abort | abort_callback object signaling user aborting the operation. |
Definition at line 262 of file filesystem.h.
| bool file::is_eof | ( | abort_callback & | p_abort | ) |
Returns whether read/write cursor position is at the end of file.
Definition at line 675 of file filesystem.cpp.
|
inlinevirtual |
Hint, returns whether the file is already fully buffered into memory.
Definition at line 253 of file filesystem.h.
|
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.
|
inlinevirtual |
Optional, called by owner thread before sleeping.
| p_abort | abort_callback object signaling user aborting the operation. |
Definition at line 257 of file filesystem.h.
| void file::probe_remaining | ( | t_filesize | bytes, |
| abort_callback & | p_abort | ||
| ) |
Security helper; fails early with exception_io_data_truncation if it is not possible to read this amount of bytes from this file at this position.
Definition at line 859 of file filesystem.cpp.
|
pure virtual |
Resets non-seekable stream, or seeks to zero on seekable file.
| p_abort | abort_callback object signaling user aborting the operation. |
|
pure virtual |
Resizes file to the specified size in bytes.
| p_abort | abort_callback object signaling user aborting the operation. |
|
pure virtual |
Sets read/write cursor position to the specified offset. Throws exception_io_seek_out_of_range if the specified offset is outside the valid range.
| p_position | position to seek to. |
| p_abort | abort_callback object signaling user aborting the operation. |
|
virtual |
Sets read/write cursor position to the specified offset; extended form allowing seeking relative to current position or to end of file.
| 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. |
Definition at line 24 of file filesystem.cpp.
| void file::seek_probe | ( | t_filesize | p_position, |
| abort_callback & | p_abort | ||
| ) |
Same as seek() but throws exception_io_data instead of exception_io_seek_out_of_range.
Definition at line 20 of file filesystem.cpp.
|
inline |
Truncates the file at current read/write cursor position.
Definition at line 281 of file filesystem.h.
|
virtual |
Attempts to skip specified number of bytes in the stream.
| p_bytes | Number of bytes to skip. |
| p_abort | abort_callback object signaling user aborting the operation. |
Reimplemented from foobar2000_io::stream_reader.
Definition at line 925 of file filesystem.cpp.
| t_filesize file::skip_seek | ( | t_filesize | p_bytes, |
| abort_callback & | p_abort | ||
| ) |
Definition at line 912 of file filesystem.cpp.
| void 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().
Definition at line 741 of file filesystem.cpp.
1.8.9.1