foobar2000 SDK  2015-08-03
Data Structures | Typedefs | Functions | Variables
foobar2000_io Namespace Reference

Data Structures

class  abort_callback
 
class  abort_callback_dummy
 
class  abort_callback_impl
 
class  archive
 
class  archive_callback
 
class  archive_factory_t
 
class  archive_impl
 
class  directory_callback
 
class  directory_callback_impl
 
class  directory_callback_retrieveList
 
class  directory_callback_retrieveListEx
 
class  directory_callback_retrieveListRecur
 
class  file
 
class  file_cached
 
class  file_dynamicinfo
 
class  file_readonly_t
 
class  file_streamstub
 
class  filesystem
 
class  format_filetimestamp
 
class  format_filetimestamp_utc
 
class  stream_reader
 
class  stream_writer
 
struct  t_filestats
 

Typedefs

typedef abort_callback_impl abort_callback_dummy
 
typedef pfc::eventHandle_t abort_callback_event
 
typedef service_ptr_t< filefile_ptr
 
typedef file_readonly_t< filefile_readonly
 
typedef std::function< void(const char *, t_filestats const &, bool) > listDirectoryFunc_t
 
typedef t_uint64 t_filesize
 
typedef t_uint64 t_filetimestamp
 
typedef t_int64 t_sfilesize
 

Functions

bool _extract_native_path_ptr (const char *&p_fspath)
 
PFC_NORETURN void exception_io_from_win32 (DWORD p_code)
 
bool extract_native_path (const char *p_fspath, pfc::string_base &p_native)
 
bool extract_native_path_ex (const char *p_fspath, pfc::string_base &p_native)
 
file_ptr fileOpen (const char *p_path, filesystem::t_open_mode p_mode, abort_callback &p_abort, double p_timeout)
 
file_ptr fileOpenReadExisting (const char *p_path, abort_callback &p_abort, double p_timeout=0)
 
file_ptr fileOpenWriteExisting (const char *p_path, abort_callback &p_abort, double p_timeout=0)
 
file_ptr fileOpenWriteNew (const char *p_path, abort_callback &p_abort, double p_timeout=0)
 
t_filetimestamp filetimestamp_from_string (const char *date)
 
t_filetimestamp filetimestamp_from_system_timer ()
 
void generate_temp_location_for_file (pfc::string_base &p_out, const char *p_origpath, const char *p_extension, const char *p_magic)
 
template<typename T >
pfc::string getPathCanonical (const T &source)
 
template<typename T >
pfc::string getPathDisplay (const T &source)
 
t_filetimestamp import_filetimestamp (FILETIME ft)
 
bool is_native_filesystem (const char *p_fspath)
 
template<typename t_list >
static void listDirectories (const char *p_path, t_list &p_out, abort_callback &p_abort)
 
void listDirectory (const char *path, abort_callback &aborter, listDirectoryFunc_t func)
 
template<typename t_list >
static void listFiles (const char *p_path, t_list &p_out, abort_callback &p_abort)
 
template<typename t_list >
static void listFilesAndDirectories (const char *p_path, t_list &p_files, t_list &p_directories, abort_callback &p_abort)
 
template<typename t_list >
static void listFilesRecur (const char *p_path, t_list &p_out, abort_callback &p_abort)
 
bool matchContentType (const char *fullString, const char *ourType)
 
bool matchProtocol (const char *fullString, const char *protocolName)
 
 PFC_DECLARE_EXCEPTION (exception_aborted, pfc::exception,"User abort")
 
 PFC_DECLARE_EXCEPTION (exception_io, pfc::exception,"I/O error")
 
 PFC_DECLARE_EXCEPTION (exception_io_not_found, exception_io,"Object not found")
 
 PFC_DECLARE_EXCEPTION (exception_io_denied, exception_io,"Access denied")
 
 PFC_DECLARE_EXCEPTION (exception_io_denied_readonly, exception_io_denied,"File is read-only")
 
 PFC_DECLARE_EXCEPTION (exception_io_data, exception_io,"Unsupported format or corrupted file")
 
 PFC_DECLARE_EXCEPTION (exception_io_data_truncation, exception_io_data,"Unsupported format or corrupted file")
 
 PFC_DECLARE_EXCEPTION (exception_io_unsupported_format, exception_io_data,"Unsupported file format")
 
 PFC_DECLARE_EXCEPTION (exception_io_object_is_remote, exception_io,"This operation is not supported on remote objects")
 
 PFC_DECLARE_EXCEPTION (exception_io_sharing_violation, exception_io,"File is already in use")
 
 PFC_DECLARE_EXCEPTION (exception_io_device_full, exception_io,"Device full")
 
 PFC_DECLARE_EXCEPTION (exception_io_seek_out_of_range, exception_io,"Seek offset out of range")
 
 PFC_DECLARE_EXCEPTION (exception_io_object_not_seekable, exception_io,"Object is not seekable")
 
 PFC_DECLARE_EXCEPTION (exception_io_no_length, exception_io,"Length of object is unknown")
 
 PFC_DECLARE_EXCEPTION (exception_io_no_handler_for_path, exception_io,"Invalid path")
 
 PFC_DECLARE_EXCEPTION (exception_io_already_exists, exception_io,"Object already exists")
 
 PFC_DECLARE_EXCEPTION (exception_io_no_data, exception_io,"The process receiving or sending data has terminated")
 
 PFC_DECLARE_EXCEPTION (exception_io_network_not_reachable, exception_io,"Network not reachable")
 
 PFC_DECLARE_EXCEPTION (exception_io_write_protected, exception_io_denied,"The media is write protected")
 
 PFC_DECLARE_EXCEPTION (exception_io_file_corrupted, exception_io,"The file is corrupted")
 
 PFC_DECLARE_EXCEPTION (exception_io_disk_change, exception_io,"Disc not available")
 
 PFC_DECLARE_EXCEPTION (exception_io_directory_not_empty, exception_io,"Directory not empty")
 
 PFC_DECLARE_EXCEPTION (exception_io_net, exception_io,"Connection error")
 
 PFC_DECLARE_EXCEPTION (exception_io_dns, exception_io_net,"DNS error")
 
void purgeOldFiles (const char *directory, t_filetimestamp period, abort_callback &abort)
 
void substituteProtocol (pfc::string_base &out, const char *fullString, const char *protocolName)
 
PFC_NORETURN void win32_file_write_failure (DWORD p_code, const char *path)
 

Variables

static const t_filesize filesize_invalid = (t_filesize)(~0)
 
static const t_filestats filestats_invalid = {filesize_invalid,filetimestamp_invalid}
 
static const t_filetimestamp filetimestamp_1second_increment = 10000000
 
const t_filetimestamp filetimestamp_invalid = 0
 

Detailed Description

Contains various I/O related structures and interfaces.

Typedef Documentation

Definition at line 87 of file abort_callback.h.

Definition at line 8 of file abort_callback.h.

Definition at line 324 of file filesystem.h.

Definition at line 357 of file filesystem.h.

typedef std::function< void (const char *, t_filestats const & , bool ) > foobar2000_io::listDirectoryFunc_t

Definition at line 4 of file filesystem_helper.h.

Type used for file size related variables.

Definition at line 8 of file filesystem.h.

Type used for file timestamp related variables. 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601; 0 for invalid/unknown time.

Definition at line 12 of file filesystem.h.

Type used for file size related variables when a signed value is needed.

Definition at line 10 of file filesystem.h.

Function Documentation

bool foobar2000_io::_extract_native_path_ptr ( const char *&  p_fspath)

Definition at line 942 of file filesystem.cpp.

942  {
943  static const char header[] = "file://"; static const t_size headerLen = 7;
944  if (strncmp(p_fspath,header,headerLen) != 0) return false;
945  p_fspath += headerLen;
946  return true;
947 }
size_t t_size
Definition: int_types.h:48
PFC_NORETURN void foobar2000_io::exception_io_from_win32 ( DWORD  p_code)

Definition at line 773 of file filesystem.cpp.

773  {
774  //pfc::string_fixed_t<32> debugMsg; debugMsg << "Win32 I/O error #" << (t_uint32)p_code;
775  //TRACK_CALL_TEXT(debugMsg);
776  switch(p_code) {
777  case ERROR_ALREADY_EXISTS:
778  case ERROR_FILE_EXISTS:
779  throw exception_io_already_exists();
780  case ERROR_NETWORK_ACCESS_DENIED:
781  case ERROR_ACCESS_DENIED:
782  throw exception_io_denied();
783  case ERROR_WRITE_PROTECT:
784  throw exception_io_write_protected();
785  case ERROR_BUSY:
786  case ERROR_PATH_BUSY:
787  case ERROR_SHARING_VIOLATION:
788  case ERROR_LOCK_VIOLATION:
789  throw exception_io_sharing_violation();
790  case ERROR_HANDLE_DISK_FULL:
791  case ERROR_DISK_FULL:
792  throw exception_io_device_full();
793  case ERROR_FILE_NOT_FOUND:
794  case ERROR_PATH_NOT_FOUND:
795  throw exception_io_not_found();
796  case ERROR_BROKEN_PIPE:
797  case ERROR_NO_DATA:
798  throw exception_io_no_data();
799  case ERROR_NETWORK_UNREACHABLE:
800  case ERROR_NETNAME_DELETED:
801  throw exception_io_network_not_reachable();
802  case ERROR_NOT_READY:
803  throw exception_io_device_not_ready();
804  case ERROR_INVALID_DRIVE:
805  throw exception_io_invalid_drive();
806  case ERROR_CRC:
807  case ERROR_FILE_CORRUPT:
808  case ERROR_DISK_CORRUPT:
809  throw exception_io_file_corrupted();
810  case ERROR_BUFFER_OVERFLOW:
811  throw exception_io_buffer_overflow();
812  case ERROR_DISK_CHANGE:
813  throw exception_io_disk_change();
814  case ERROR_DIR_NOT_EMPTY:
815  throw exception_io_directory_not_empty();
816  case ERROR_INVALID_NAME:
817  throw exception_io_invalid_path_syntax();
818  case ERROR_NO_SYSTEM_RESOURCES:
819  case ERROR_NONPAGED_SYSTEM_RESOURCES:
820  case ERROR_PAGED_SYSTEM_RESOURCES:
821  case ERROR_WORKING_SET_QUOTA:
822  case ERROR_PAGEFILE_QUOTA:
823  case ERROR_COMMITMENT_LIMIT:
824  throw exception_io("Insufficient system resources");
825  case ERROR_IO_DEVICE:
826  throw exception_io("Device error");
827  default:
828  throw exception_io_win32_ex(p_code);
829  }
830 }
bool foobar2000_io::extract_native_path ( const char *  p_fspath,
pfc::string_base p_native 
)

Definition at line 948 of file filesystem.cpp.

948  {
949  if (!_extract_native_path_ptr(p_fspath)) return false;
950  p_native = p_fspath;
951  return true;
952 }
bool _extract_native_path_ptr(const char *&p_fspath)
Definition: filesystem.cpp:942
bool foobar2000_io::extract_native_path_ex ( const char *  p_fspath,
pfc::string_base p_native 
)

Definition at line 954 of file filesystem.cpp.

954  {
955  if (!_extract_native_path_ptr(p_fspath)) return false;
956  if (p_fspath[0] != '\\' || p_fspath[1] != '\\') {
957  p_native = "\\\\?\\";
958  p_native += p_fspath;
959  } else {
960  p_native = p_fspath;
961  }
962  return true;
963 }
bool _extract_native_path_ptr(const char *&p_fspath)
Definition: filesystem.cpp:942
file_ptr foobar2000_io::fileOpen ( const char *  p_path,
filesystem::t_open_mode  p_mode,
abort_callback p_abort,
double  p_timeout 
)
inline

Definition at line 576 of file filesystem.h.

576  {
577  file_ptr temp; filesystem::g_open_timeout(temp,p_path,p_mode,p_timeout,p_abort); PFC_ASSERT(temp.is_valid()); return temp;
578  }
bool is_valid() const
Definition: service.h:119
file_ptr foobar2000_io::fileOpenReadExisting ( const char *  p_path,
abort_callback p_abort,
double  p_timeout = 0 
)
inline

Definition at line 580 of file filesystem.h.

580  {
581  return fileOpen(p_path,filesystem::open_mode_read,p_abort,p_timeout);
582  }
file_ptr fileOpen(const char *p_path, filesystem::t_open_mode p_mode, abort_callback &p_abort, double p_timeout)
Definition: filesystem.h:576
file_ptr foobar2000_io::fileOpenWriteExisting ( const char *  p_path,
abort_callback p_abort,
double  p_timeout = 0 
)
inline

Definition at line 583 of file filesystem.h.

583  {
584  return fileOpen(p_path,filesystem::open_mode_write_existing,p_abort,p_timeout);
585  }
file_ptr fileOpen(const char *p_path, filesystem::t_open_mode p_mode, abort_callback &p_abort, double p_timeout)
Definition: filesystem.h:576
file_ptr foobar2000_io::fileOpenWriteNew ( const char *  p_path,
abort_callback p_abort,
double  p_timeout = 0 
)
inline

Definition at line 586 of file filesystem.h.

586  {
587  return fileOpen(p_path,filesystem::open_mode_write_new,p_abort,p_timeout);
588  }
file_ptr fileOpen(const char *p_path, filesystem::t_open_mode p_mode, abort_callback &p_abort, double p_timeout)
Definition: filesystem.h:576
t_filetimestamp foobar2000_io::filetimestamp_from_string ( const char *  date)

Definition at line 27 of file filetimetools.cpp.

27  {
28  // Accepted format
29  // YYYY-MM-DD HH:MM:SS
30  try {
31  t_size remaining = strlen(date);
32  SYSTEMTIME st = {};
33  st.wDay = 1; st.wMonth = 1;
34  for(;;) {
35 #define ADVANCE(n) { PFC_ASSERT( remaining >= n); date += n; remaining -= n; }
36 #define ADVANCE_TEST(n) { if (remaining < n) throw exception_time_error(); }
37 #define PARSE(var, digits) { ADVANCE_TEST(digits); var = (WORD) ParseDateElem(date, digits); ADVANCE(digits) ; }
38 #define TEST_END( durationIncrement )
39 #define SKIP(c) { ADVANCE_TEST(1); if (date[0] != c) throw exception_time_error(); ADVANCE(1); }
40 #define SKIP_SPACING() {while(remaining > 0 && is_spacing(*date)) ADVANCE(1);}
41  SKIP_SPACING();
42  PARSE( st.wYear, 4 ); if (st.wYear < 1601) throw exception_time_error();
43  TEST_END(wYear); SKIP('-');
44  PARSE( st.wMonth, 2 ); if (st.wMonth < 1 || st.wMonth > 12) throw exception_time_error();
45  TEST_END(wMonth); SKIP('-');
46  PARSE( st.wDay, 2); if (st.wDay < 1 || st.wDay > 31) throw exception_time_error();
47  TEST_END(wDay); SKIP(' ');
48  PARSE( st.wHour, 2); if (st.wHour >= 24) throw exception_time_error();
49  TEST_END(wHour); SKIP(':');
50  PARSE( st.wMinute, 2); if (st.wMinute >= 60) throw exception_time_error();
51  TEST_END(wMinute); SKIP(':');
52  PARSE( st.wSecond, 2); if (st.wSecond >= 60) throw exception_time_error();
53  SKIP_SPACING();
54  TEST_END( wSecond );
55 #undef ADVANCE
56 #undef ADVANCE_TEST
57 #undef PARSE
58 #undef TEST_END
59 #undef SKIP
60 #undef SKIP_SPACING
61  if (remaining > 0) throw exception_time_error();
62  break;
63  }
64  t_filetimestamp base, out;
65  if (!SystemTimeToFileTime(&st, (FILETIME*) &base)) throw exception_time_error();
66  if (!LocalFileTimeToFileTime((const FILETIME*)&base, (FILETIME*)&out)) throw exception_time_error();
67  return out;
68  } catch(exception_time_error) {
69  return filetimestamp_invalid;
70  }
71 }
const t_filetimestamp filetimestamp_invalid
Invalid/unknown file timestamp constant. Also see: t_filetimestamp.
Definition: filesystem.h:14
size_t t_size
Definition: int_types.h:48
t_uint64 t_filetimestamp
Type used for file timestamp related variables. 64-bit value representing the number of 100-nanosecon...
Definition: filesystem.h:12
exception_io_data exception_time_error
t_filetimestamp foobar2000_io::filetimestamp_from_system_timer ( )

Definition at line 684 of file filesystem.cpp.

685 {
686  return pfc::fileTimeNow();
687 }
uint64_t fileTimeNow()
Definition: timers.cpp:66
void foobar2000_io::generate_temp_location_for_file ( pfc::string_base p_out,
const char *  p_origpath,
const char *  p_extension,
const char *  p_magic 
)

Definition at line 892 of file filesystem.cpp.

892  {
893  hasher_md5_result hash;
894  {
896  hasher_md5_state state;
897  hasher->initialize(state);
898  hasher->process(state,p_origpath,strlen(p_origpath));
899  hasher->process(state,p_extension,strlen(p_extension));
900  hasher->process(state,p_magic,strlen(p_magic));
901  hash = hasher->get_result(state);
902  }
903 
904  p_out = p_origpath;
905  p_out.truncate(p_out.scan_filename());
906  p_out += "temp-";
907  p_out += pfc::format_hexdump(hash.m_data,sizeof(hash.m_data),"");
908  p_out += ".";
909  p_out += p_extension;
910 }
char m_data[16]
Definition: hasher_md5.h:6
t_size scan_filename() const
Definition: string_base.h:235
virtual void truncate(t_size len)=0
template<typename T >
pfc::string foobar2000_io::getPathCanonical ( const T source)

Definition at line 668 of file filesystem.h.

668  {
670  filesystem::g_get_canonical_path(pfc::stringToPtr(source),temp);
671  return temp.toString();
672  }
const char * stringToPtr(T const &val)
Definition: string_base.h:1020
string8_fastalloc string_formatter
Definition: string_base.h:615
template<typename T >
pfc::string foobar2000_io::getPathDisplay ( const T source)

Definition at line 662 of file filesystem.h.

662  {
664  filesystem::g_get_display_path(pfc::stringToPtr(source),temp);
665  return temp.toString();
666  }
const char * stringToPtr(T const &val)
Definition: string_base.h:1020
string8_fastalloc string_formatter
Definition: string_base.h:615
t_filetimestamp foobar2000_io::import_filetimestamp ( FILETIME  ft)
inline

Definition at line 568 of file filesystem.h.

568  {
569  return *reinterpret_cast<t_filetimestamp*>(&ft);
570  }
t_uint64 t_filetimestamp
Type used for file timestamp related variables. 64-bit value representing the number of 100-nanosecon...
Definition: filesystem.h:12
bool foobar2000_io::is_native_filesystem ( const char *  p_fspath)

Definition at line 938 of file filesystem.cpp.

938  {
939  return _extract_native_path_ptr( p_fspath );
940 }
bool _extract_native_path_ptr(const char *&p_fspath)
Definition: filesystem.cpp:942
template<typename t_list >
static void foobar2000_io::listDirectories ( const char *  p_path,
t_list &  p_out,
abort_callback p_abort 
)
static

Definition at line 641 of file filesystem.h.

641  {
642  directory_callback_retrieveList<t_list> callback(p_out,false,true);
643  filesystem::g_list_directory(p_path,callback,p_abort);
644  }
void foobar2000_io::listDirectory ( const char *  path,
abort_callback aborter,
listDirectoryFunc_t  func 
)

Definition at line 218 of file filesystem_helper.cpp.

218  {
219  listDirectoryCallback cb; cb.m_func = func;
220  filesystem::g_list_directory(path, cb, aborter);
221  }
template<typename t_list >
static void foobar2000_io::listFiles ( const char *  p_path,
t_list &  p_out,
abort_callback p_abort 
)
static

Definition at line 636 of file filesystem.h.

636  {
637  directory_callback_retrieveList<t_list> callback(p_out,true,false);
638  filesystem::g_list_directory(p_path,callback,p_abort);
639  }
template<typename t_list >
static void foobar2000_io::listFilesAndDirectories ( const char *  p_path,
t_list &  p_files,
t_list &  p_directories,
abort_callback p_abort 
)
static

Definition at line 646 of file filesystem.h.

646  {
647  directory_callback_retrieveListEx<t_list> callback(p_files,p_directories);
648  filesystem::g_list_directory(p_path,callback,p_abort);
649  }
template<typename t_list >
static void foobar2000_io::listFilesRecur ( const char *  p_path,
t_list &  p_out,
abort_callback p_abort 
)
static

Definition at line 651 of file filesystem.h.

651  {
653  filesystem::g_list_directory(p_path,callback,p_abort);
654  }
bool foobar2000_io::matchContentType ( const char *  fullString,
const char *  ourType 
)

Definition at line 1059 of file filesystem.cpp.

1059  {
1060  t_size lim = pfc::string_find_first(fullString, ';');
1061  if (lim != ~0) {
1062  while(lim > 0 && fullString[lim-1] == ' ') --lim;
1063  }
1064  return pfc::stricmp_ascii_ex(fullString,lim, ourType, ~0) == 0;
1065 }
int stricmp_ascii_ex(const char *const s1, t_size const len1, const char *const s2, t_size const len2)
size_t t_size
Definition: int_types.h:48
t_size string_find_first(const char *p_string, char p_tofind, t_size p_start)
bool foobar2000_io::matchProtocol ( const char *  fullString,
const char *  protocolName 
)

Definition at line 1066 of file filesystem.cpp.

1066  {
1067  const t_size len = strlen(protocolName);
1068  if (pfc::stricmp_ascii_ex(fullString, len, protocolName, len) != 0) return false;
1069  return fullString[len] == ':' && fullString[len+1] == '/' && fullString[len+2] == '/';
1070 }
int stricmp_ascii_ex(const char *const s1, t_size const len1, const char *const s2, t_size const len2)
size_t t_size
Definition: int_types.h:48
foobar2000_io::PFC_DECLARE_EXCEPTION ( exception_aborted  ,
pfc::exception  ,
"User abort"   
)
foobar2000_io::PFC_DECLARE_EXCEPTION ( exception_io  ,
pfc::exception  ,
"I/O error"   
)

Generic I/O error. Root class for I/O failure exception. See relevant default message for description of each derived exception class.

foobar2000_io::PFC_DECLARE_EXCEPTION ( exception_io_not_found  ,
exception_io  ,
"Object not found"   
)

Object not found.

foobar2000_io::PFC_DECLARE_EXCEPTION ( exception_io_denied  ,
exception_io  ,
"Access denied"   
)

Access denied.

foobar2000_io::PFC_DECLARE_EXCEPTION ( exception_io_denied_readonly  ,
exception_io_denied  ,
"File is read-only"   
)

Access denied.

foobar2000_io::PFC_DECLARE_EXCEPTION ( exception_io_data  ,
exception_io  ,
"Unsupported format or corrupted file  
)

Unsupported format or corrupted file (unexpected data encountered).

foobar2000_io::PFC_DECLARE_EXCEPTION ( exception_io_data_truncation  ,
exception_io_data  ,
"Unsupported format or corrupted file  
)

Unsupported format or corrupted file (truncation encountered).

foobar2000_io::PFC_DECLARE_EXCEPTION ( exception_io_unsupported_format  ,
exception_io_data  ,
"Unsupported file format"   
)

Unsupported format (a subclass of "unsupported format or corrupted file" exception).

foobar2000_io::PFC_DECLARE_EXCEPTION ( exception_io_object_is_remote  ,
exception_io  ,
"This operation is not supported on remote objects"   
)

Object is remote, while specific operation is supported only for local objects.

foobar2000_io::PFC_DECLARE_EXCEPTION ( exception_io_sharing_violation  ,
exception_io  ,
"File is already in use  
)

Sharing violation.

foobar2000_io::PFC_DECLARE_EXCEPTION ( exception_io_device_full  ,
exception_io  ,
"Device full"   
)

Device full.

foobar2000_io::PFC_DECLARE_EXCEPTION ( exception_io_seek_out_of_range  ,
exception_io  ,
"Seek offset out of range"   
)

Attempt to seek outside valid range.

foobar2000_io::PFC_DECLARE_EXCEPTION ( exception_io_object_not_seekable  ,
exception_io  ,
"Object is not seekable"   
)

This operation requires a seekable object.

foobar2000_io::PFC_DECLARE_EXCEPTION ( exception_io_no_length  ,
exception_io  ,
"Length of object is unknown"   
)

This operation requires an object with known length.

foobar2000_io::PFC_DECLARE_EXCEPTION ( exception_io_no_handler_for_path  ,
exception_io  ,
"Invalid path"   
)

Invalid path.

foobar2000_io::PFC_DECLARE_EXCEPTION ( exception_io_already_exists  ,
exception_io  ,
"Object already exists"   
)

Object already exists.

foobar2000_io::PFC_DECLARE_EXCEPTION ( exception_io_no_data  ,
exception_io  ,
"The process receiving or sending data has terminated"   
)

Pipe error.

foobar2000_io::PFC_DECLARE_EXCEPTION ( exception_io_network_not_reachable  ,
exception_io  ,
"Network not reachable"   
)

Network not reachable.

foobar2000_io::PFC_DECLARE_EXCEPTION ( exception_io_write_protected  ,
exception_io_denied  ,
"The media is write protected"   
)

Media is write protected.

foobar2000_io::PFC_DECLARE_EXCEPTION ( exception_io_file_corrupted  ,
exception_io  ,
"The file is corrupted"   
)

File is corrupted. This indicates filesystem call failure, not actual invalid data being read by the app.

foobar2000_io::PFC_DECLARE_EXCEPTION ( exception_io_disk_change  ,
exception_io  ,
"Disc not available"   
)

The disc required for requested operation is not available.

foobar2000_io::PFC_DECLARE_EXCEPTION ( exception_io_directory_not_empty  ,
exception_io  ,
"Directory not empty"   
)

The directory is not empty.

foobar2000_io::PFC_DECLARE_EXCEPTION ( exception_io_net  ,
exception_io  ,
"Connection error"   
)

A network connectivity error.

foobar2000_io::PFC_DECLARE_EXCEPTION ( exception_io_dns  ,
exception_io_net  ,
"DNS error"   
)

A network connectivity error, specifically a DNS query failure.

void foobar2000_io::purgeOldFiles ( const char *  directory,
t_filetimestamp  period,
abort_callback abort 
)

Definition at line 1007 of file filesystem.cpp.

1007  {
1008 
1009  class myCallback : public directory_callback {
1010  public:
1011  myCallback(t_filetimestamp period) : m_base(filetimestamp_from_system_timer() - period) {}
1012  bool on_entry(filesystem * p_owner,abort_callback & p_abort,const char * p_url,bool p_is_subdirectory,const t_filestats & p_stats) {
1013  if (!p_is_subdirectory && p_stats.m_timestamp < m_base) {
1014  try {
1015  filesystem::g_remove_timeout(p_url, 1, p_abort);
1016  } catch(exception_io_not_found) {}
1017  }
1018  return true;
1019  }
1020  private:
1021  const t_filetimestamp m_base;
1022  };
1023 
1024  myCallback cb(period);
1025  filesystem::g_list_directory(directory, cb, abort);
1026 }
t_filetimestamp filetimestamp_from_system_timer()
Definition: filesystem.cpp:684
t_uint64 t_filetimestamp
Type used for file timestamp related variables. 64-bit value representing the number of 100-nanosecon...
Definition: filesystem.h:12
void foobar2000_io::substituteProtocol ( pfc::string_base out,
const char *  fullString,
const char *  protocolName 
)

Definition at line 1071 of file filesystem.cpp.

1071  {
1072  const char * base = strstr(fullString, "://");
1073  if (base) {
1074  out = protocolName; out << base;
1075  } else {
1076  PFC_ASSERT(!"Should not get here");
1077  out = fullString;
1078  }
1079 }
PFC_NORETURN void foobar2000_io::win32_file_write_failure ( DWORD  p_code,
const char *  path 
)

Definition at line 765 of file filesystem.cpp.

765  {
766  if (p_code == ERROR_ACCESS_DENIED) {
767  const DWORD attr = uGetFileAttributes(path);
768  if (attr != ~0 && (attr & FILE_ATTRIBUTE_READONLY) != 0) throw exception_io_denied_readonly();
769  }
770  exception_io_from_win32(p_code);
771 }
DWORD SHARED_EXPORT uGetFileAttributes(const char *fn)
PFC_NORETURN void exception_io_from_win32(DWORD p_code)
Definition: filesystem.cpp:773

Variable Documentation

const t_filesize foobar2000_io::filesize_invalid = (t_filesize)(~0)
static

Invalid/unknown file size constant. Also see: t_filesize.

Definition at line 16 of file filesystem.h.

const t_filestats foobar2000_io::filestats_invalid = {filesize_invalid,filetimestamp_invalid}
static

Invalid/unknown file stats constant. See: t_filestats.

Definition at line 80 of file filesystem.h.

const t_filetimestamp foobar2000_io::filetimestamp_1second_increment = 10000000
static

Definition at line 18 of file filesystem.h.

const t_filetimestamp foobar2000_io::filetimestamp_invalid = 0

Invalid/unknown file timestamp constant. Also see: t_filetimestamp.

Definition at line 14 of file filesystem.h.