foobar2000 SDK  2015-08-03
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions
foobar2000_io::filesystemabstract

#include <filesystem.h>

+ Inheritance diagram for foobar2000_io::filesystem:

Public Types

enum  t_open_mode { open_mode_read, open_mode_write_existing, open_mode_write_new }
 
- Public Types inherited from service_base
typedef service_base t_interface
 

Public Member Functions

void copy_directory (const char *p_src, const char *p_dst, abort_callback &p_abort)
 
virtual void create_directory (const char *p_path, abort_callback &p_abort)=0
 
virtual bool get_canonical_path (const char *p_path, pfc::string_base &p_out)=0
 
virtual bool get_display_path (const char *p_path, pfc::string_base &p_out)=0
 
virtual void get_stats (const char *p_path, t_filestats &p_stats, bool &p_is_writeable, abort_callback &p_abort)=0
 
virtual bool is_our_path (const char *p_path)=0
 
virtual bool is_remote (const char *p_src)=0
 
virtual void list_directory (const char *p_path, directory_callback &p_out, abort_callback &p_abort)=0
 
virtual void move (const char *p_src, const char *p_dst, abort_callback &p_abort)=0
 
virtual void open (service_ptr_t< file > &p_out, const char *p_path, t_open_mode p_mode, abort_callback &p_abort)=0
 
virtual bool relative_path_create (const char *file_path, const char *playlist_path, pfc::string_base &out)
 
virtual bool relative_path_parse (const char *relative_path, const char *playlist_path, pfc::string_base &out)
 
virtual void remove (const char *p_path, abort_callback &p_abort)=0
 
void remove_directory_content (const char *path, abort_callback &abort)
 
void remove_object_recur (const char *path, abort_callback &abort)
 
virtual bool supports_content_types ()=0
 
- 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 ()
 

Static Public Member Functions

static void g_copy (const char *p_src, const char *p_dst, abort_callback &p_abort)
 
static void g_copy_directory (const char *p_src, const char *p_dst, abort_callback &p_abort)
 
static void g_copy_timeout (const char *p_src, const char *p_dst, double p_timeout, abort_callback &p_abort)
 
static void g_create_directory (const char *p_path, abort_callback &p_abort)
 
static bool g_exists (const char *p_path, abort_callback &p_abort)
 
static bool g_exists_writeable (const char *p_path, abort_callback &p_abort)
 
static void g_get_canonical_path (const char *path, pfc::string_base &out)
 
static void g_get_display_path (const char *path, pfc::string_base &out)
 
static bool g_get_interface (service_ptr_t< filesystem > &p_out, const char *path)
 
static filesystem::ptr g_get_interface (const char *path)
 
static bool g_get_native_path (const char *path, pfc::string_base &out)
 
static void g_get_stats (const char *p_path, t_filestats &p_stats, bool &p_is_writeable, abort_callback &p_abort)
 
static bool g_is_empty_directory (const char *path, abort_callback &p_abort)
 
static bool g_is_recognized_and_remote (const char *p_path)
 
static bool g_is_recognized_path (const char *p_path)
 
static bool g_is_remote (const char *p_path)
 
static bool g_is_remote_or_unrecognized (const char *p_path)
 
static bool g_is_remote_safe (const char *p_path)
 
static bool g_is_valid_directory (const char *path, abort_callback &p_abort)
 
static void g_link (const char *p_src, const char *p_dst, abort_callback &p_abort)
 
static void g_link_timeout (const char *p_src, const char *p_dst, double p_timeout, abort_callback &p_abort)
 
static void g_list_directory (const char *p_path, directory_callback &p_out, abort_callback &p_abort)
 
static void g_move (const char *p_src, const char *p_dst, abort_callback &p_abort)
 
static void g_move_timeout (const char *p_src, const char *p_dst, double p_timeout, abort_callback &p_abort)
 
static void g_open (service_ptr_t< file > &p_out, const char *p_path, t_open_mode p_mode, abort_callback &p_abort)
 
static void g_open_precache (service_ptr_t< file > &p_out, const char *path, abort_callback &p_abort)
 
static void g_open_read (service_ptr_t< file > &p_out, const char *path, abort_callback &p_abort)
 
static void g_open_temp (service_ptr_t< file > &p_out, abort_callback &p_abort)
 
static void g_open_tempmem (service_ptr_t< file > &p_out, abort_callback &p_abort)
 
static file::ptr g_open_tempmem ()
 
static void g_open_timeout (service_ptr_t< file > &p_out, const char *p_path, t_open_mode p_mode, double p_timeout, abort_callback &p_abort)
 
static void g_open_write_new (service_ptr_t< file > &p_out, const char *p_path, abort_callback &p_abort)
 
static bool g_relative_path_create (const char *p_file_path, const char *p_playlist_path, pfc::string_base &out)
 
static bool g_relative_path_parse (const char *p_relative_path, const char *p_playlist_path, pfc::string_base &out)
 
static void g_remove (const char *p_path, abort_callback &p_abort)
 
static void g_remove_object_recur (const char *path, abort_callback &abort)
 
static void g_remove_object_recur_timeout (const char *path, double timeout, abort_callback &abort)
 
static void g_remove_timeout (const char *p_path, double p_timeout, abort_callback &p_abort)
 
static FILE * streamio_open (const char *p_path, const char *p_flags)
 

Private Member Functions

 FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT (filesystem)
 

Additional Inherited Members

- Protected Member Functions inherited from service_base
 service_base ()
 
 ~service_base ()
 

Detailed Description

Entrypoint service for all filesystem operations.
Implementation: standard implementations for local filesystem etc are provided by core.
Instantiation: use static helper functions rather than calling filesystem interface methods directly, e.g. filesystem::g_open() to open a file.

Definition at line 383 of file filesystem.h.

Member Enumeration Documentation

Enumeration specifying how to open a file. See: filesystem::open(), filesystem::g_open().

Enumerator
open_mode_read 

Opens an existing file for reading; if the file does not exist, the operation will fail.

open_mode_write_existing 

Opens an existing file for writing; if the file does not exist, the operation will fail.

open_mode_write_new 

Opens a new file for writing; if the file exists, its contents will be wiped.

Definition at line 387 of file filesystem.h.

387  {
394  };
Opens an existing file for writing; if the file does not exist, the operation will fail...
Definition: filesystem.h:391
Opens an existing file for reading; if the file does not exist, the operation will fail...
Definition: filesystem.h:389
Opens a new file for writing; if the file exists, its contents will be wiped.
Definition: filesystem.h:393

Member Function Documentation

void filesystem::copy_directory ( const char *  p_src,
const char *  p_dst,
abort_callback p_abort 
)

Definition at line 553 of file filesystem.cpp.

553  {
554  try {
555  this->create_directory( dst, p_abort );
556  } catch(exception_io_already_exists) {}
557  directory_callback_impl_copy cb(dst, this);
558  list_directory(src, cb, p_abort);
559 }
virtual void create_directory(const char *p_path, abort_callback &p_abort)=0
Creates a directory.
virtual void list_directory(const char *p_path, directory_callback &p_out, abort_callback &p_abort)=0
virtual void foobar2000_io::filesystem::create_directory ( const char *  p_path,
abort_callback p_abort 
)
pure virtual

Creates a directory.

Implemented in foobar2000_io::archive_impl.

foobar2000_io::filesystem::FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT ( filesystem  )
private
void filesystem::g_copy ( const char *  p_src,
const char *  p_dst,
abort_callback p_abort 
)
static

Definition at line 570 of file filesystem.cpp.

570  {
571  service_ptr_t<file> r_src,r_dst;
572  t_filesize size;
573 
574  g_open(r_src,src,open_mode_read,p_abort);
575  size = r_src->get_size_ex(p_abort);
576  g_open(r_dst,dst,open_mode_write_new,p_abort);
577 
578  if (size > 0) {
579  try {
580  file::g_transfer_object(r_src,r_dst,size,p_abort);
581  } catch(...) {
582  r_dst.release();
583  abort_callback_dummy dummy;
584  try {g_remove(dst,dummy);} catch(...) {}
585  throw;
586  }
587  }
588 }
static void g_remove(const char *p_path, abort_callback &p_abort)
Removes file at specified path.
Definition: filesystem.cpp:167
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 ...
static void g_open(service_ptr_t< file > &p_out, const char *p_path, t_open_mode p_mode, abort_callback &p_abort)
Opens file at specified path, with specified access privileges.
Definition: filesystem.cpp:136
abort_callback_impl abort_callback_dummy
void release()
Definition: service.h:109
Opens an existing file for reading; if the file does not exist, the operation will fail...
Definition: filesystem.h:389
t_uint64 t_filesize
Type used for file size related variables.
Definition: filesystem.h:8
Opens a new file for writing; if the file exists, its contents will be wiped.
Definition: filesystem.h:393
void filesystem::g_copy_directory ( const char *  p_src,
const char *  p_dst,
abort_callback p_abort 
)
static

Definition at line 561 of file filesystem.cpp.

561  {
562  filesystem::ptr dstFS = filesystem::g_get_interface(dst);
563  try {
564  dstFS->create_directory( dst, p_abort );
565  } catch(exception_io_already_exists) {}
566  directory_callback_impl_copy cb(dst, dstFS);
567  g_list_directory(src,cb,p_abort);
568 }
static bool g_get_interface(service_ptr_t< filesystem > &p_out, const char *path)
Definition: filesystem.cpp:121
static void g_list_directory(const char *p_path, directory_callback &p_out, abort_callback &p_abort)
Definition: filesystem.cpp:210
void filesystem::g_copy_timeout ( const char *  p_src,
const char *  p_dst,
double  p_timeout,
abort_callback p_abort 
)
static

Definition at line 179 of file filesystem.cpp.

179  {
180  FB2K_RETRY_FILE_MOVE( g_copy(p_src, p_dst, p_abort), p_abort, p_timeout );
181 }
static void g_copy(const char *p_src, const char *p_dst, abort_callback &p_abort)
Definition: filesystem.cpp:570
void filesystem::g_create_directory ( const char *  p_path,
abort_callback p_abort 
)
static

Definition at line 183 of file filesystem.cpp.

184 {
185  g_get_interface(p_path)->create_directory(p_path,p_abort);
186 }
static bool g_get_interface(service_ptr_t< filesystem > &p_out, const char *path)
Definition: filesystem.cpp:121
bool filesystem::g_exists ( const char *  p_path,
abort_callback p_abort 
)
static

Definition at line 147 of file filesystem.cpp.

148 {
149  t_filestats stats;
150  bool dummy;
151  try {
152  g_get_stats(p_path,stats,dummy,p_abort);
153  } catch(exception_io_not_found) {return false;}
154  return true;
155 }
static void g_get_stats(const char *p_path, t_filestats &p_stats, bool &p_is_writeable, abort_callback &p_abort)
Definition: filesystem.cpp:659
bool filesystem::g_exists_writeable ( const char *  p_path,
abort_callback p_abort 
)
static

Definition at line 157 of file filesystem.cpp.

158 {
159  t_filestats stats;
160  bool writeable;
161  try {
162  g_get_stats(p_path,stats,writeable,p_abort);
163  } catch(exception_io_not_found) {return false;}
164  return writeable;
165 }
static void g_get_stats(const char *p_path, t_filestats &p_stats, bool &p_is_writeable, abort_callback &p_abort)
Definition: filesystem.cpp:659
void filesystem::g_get_canonical_path ( const char *  path,
pfc::string_base out 
)
static

Definition at line 74 of file filesystem.cpp.

75 {
76  TRACK_CALL_TEXT("filesystem::g_get_canonical_path");
77 
80  if (e.first(ptr)) do {
81  if (ptr->get_canonical_path(path,out)) return;
82  } while(e.next(ptr));
83  //no one wants to process this, let's copy over
84  out = path;
85 }
bool first(service_ptr_t< t_query > &p_out)
Definition: service.h:581
Autopointer class to be used with all services. Manages reference counter calls behind-the-scenes.
Definition: service.h:55
bool next(service_ptr_t< t_query > &p_out)
Definition: service.h:587
void filesystem::g_get_display_path ( const char *  path,
pfc::string_base out 
)
static

Definition at line 87 of file filesystem.cpp.

88 {
89  TRACK_CALL_TEXT("filesystem::g_get_display_path");
91  if (!g_get_interface(ptr,path))
92  {
93  //no one wants to process this, let's copy over
94  out = path;
95  }
96  else
97  {
98  if (!ptr->get_display_path(path,out))
99  out = path;
100  }
101 }
static bool g_get_interface(service_ptr_t< filesystem > &p_out, const char *path)
Definition: filesystem.cpp:121
Autopointer class to be used with all services. Manages reference counter calls behind-the-scenes.
Definition: service.h:55
bool filesystem::g_get_interface ( service_ptr_t< filesystem > &  p_out,
const char *  path 
)
static

Definition at line 121 of file filesystem.cpp.

122 {
125  if (e.first(ptr)) do {
126  if (ptr->is_our_path(path))
127  {
128  p_out = ptr;
129  return true;
130  }
131  } while(e.next(ptr));
132  return false;
133 }
bool first(service_ptr_t< t_query > &p_out)
Definition: service.h:581
Autopointer class to be used with all services. Manages reference counter calls behind-the-scenes.
Definition: service.h:55
bool next(service_ptr_t< t_query > &p_out)
Definition: service.h:587
filesystem::ptr filesystem::g_get_interface ( const char *  path)
static

Definition at line 115 of file filesystem.cpp.

115  {
116  filesystem::ptr rv;
117  if (!g_get_interface(rv, path)) throw exception_io_no_handler_for_path();
118  return rv;
119 
120 }
static bool g_get_interface(service_ptr_t< filesystem > &p_out, const char *path)
Definition: filesystem.cpp:121
bool filesystem::g_get_native_path ( const char *  path,
pfc::string_base out 
)
static

Extracts the native filesystem path, sets out to the input path if native path cannot be extracted so the output is always set.

Returns
True if native path was extracted successfully, false otherwise (but output is set anyway).

Definition at line 103 of file filesystem.cpp.

103  {
104  // Is proper file:// path?
105  if (foobar2000_io::extract_native_path( path, out ) ) return true;
106 
107  // Set anyway
108  out = path;
109 
110  // Maybe just a file:// less local path? Check for other protocol markers
111  // If no :// present, return true anyway
112  return strstr( path, "://" ) == NULL;
113 }
bool extract_native_path(const char *p_fspath, pfc::string_base &p_native)
Definition: filesystem.cpp:948
void filesystem::g_get_stats ( const char *  p_path,
t_filestats p_stats,
bool &  p_is_writeable,
abort_callback p_abort 
)
static

Definition at line 659 of file filesystem.cpp.

659  {
660  TRACK_CALL_TEXT("filesystem::g_get_stats");
661  return g_get_interface(p_path)->get_stats(p_path,p_stats,p_is_writeable,p_abort);
662 }
static bool g_get_interface(service_ptr_t< filesystem > &p_out, const char *path)
Definition: filesystem.cpp:121
bool filesystem::g_is_empty_directory ( const char *  path,
abort_callback p_abort 
)
static

Definition at line 471 of file filesystem.cpp.

472 {
473  directory_callback_isempty callback;
474  try {
475  g_list_directory(path,callback,p_abort);
476  } catch(exception_io const &) {return false;}
477  return callback.isempty();
478 }
static void g_list_directory(const char *p_path, directory_callback &p_out, abort_callback &p_abort)
Definition: filesystem.cpp:210
bool filesystem::g_is_recognized_and_remote ( const char *  p_path)
static

Definition at line 258 of file filesystem.cpp.

258  {
260  if (g_get_interface(fs,p_path)) return fs->is_remote(p_path);
261  else return false;
262 }
static bool g_get_interface(service_ptr_t< filesystem > &p_out, const char *path)
Definition: filesystem.cpp:121
Autopointer class to be used with all services. Manages reference counter calls behind-the-scenes.
Definition: service.h:55
bool filesystem::g_is_recognized_path ( const char *  p_path)
static

Definition at line 847 of file filesystem.cpp.

847  {
848  filesystem::ptr obj;
849  return g_get_interface(obj,p_path);
850 }
static bool g_get_interface(service_ptr_t< filesystem > &p_out, const char *path)
Definition: filesystem.cpp:121
bool filesystem::g_is_remote ( const char *  p_path)
static

Definition at line 254 of file filesystem.cpp.

254  {
255  return g_get_interface(p_path)->is_remote(p_path);
256 }
static bool g_get_interface(service_ptr_t< filesystem > &p_out, const char *path)
Definition: filesystem.cpp:121
bool filesystem::g_is_remote_or_unrecognized ( const char *  p_path)
static

Definition at line 264 of file filesystem.cpp.

264  {
266  if (g_get_interface(fs,p_path)) return fs->is_remote(p_path);
267  else return true;
268 }
static bool g_get_interface(service_ptr_t< filesystem > &p_out, const char *path)
Definition: filesystem.cpp:121
Autopointer class to be used with all services. Manages reference counter calls behind-the-scenes.
Definition: service.h:55
static bool foobar2000_io::filesystem::g_is_remote_safe ( const char *  p_path)
inlinestatic

Definition at line 431 of file filesystem.h.

431 {return g_is_recognized_and_remote(p_path);}
static bool g_is_recognized_and_remote(const char *p_path)
Definition: filesystem.cpp:258
bool filesystem::g_is_valid_directory ( const char *  path,
abort_callback p_abort 
)
static

Definition at line 480 of file filesystem.cpp.

480  {
481  try {
482  directory_callback_dummy cb;
483  g_list_directory(path,cb,p_abort);
484  return true;
485  } catch(exception_io const &) {return false;}
486 }
static void g_list_directory(const char *p_path, directory_callback &p_out, abort_callback &p_abort)
Definition: filesystem.cpp:210
void filesystem::g_link ( const char *  p_src,
const char *  p_dst,
abort_callback p_abort 
)
static

Definition at line 200 of file filesystem.cpp.

200  {
201  if (!foobar2000_io::_extract_native_path_ptr(p_src) || !foobar2000_io::_extract_native_path_ptr(p_dst)) throw exception_io_no_handler_for_path();
202  WIN32_IO_OP( CreateHardLink( pfc::stringcvt::string_os_from_utf8( p_dst ), pfc::stringcvt::string_os_from_utf8( p_src ), NULL) );
203 }
bool _extract_native_path_ptr(const char *&p_fspath)
Definition: filesystem.cpp:942
void filesystem::g_link_timeout ( const char *  p_src,
const char *  p_dst,
double  p_timeout,
abort_callback p_abort 
)
static

Definition at line 205 of file filesystem.cpp.

205  {
206  FB2K_RETRY_FILE_MOVE( g_link(p_src, p_dst, p_abort), p_abort, p_timeout );
207 }
static void g_link(const char *p_src, const char *p_dst, abort_callback &p_abort)
Definition: filesystem.cpp:200
void filesystem::g_list_directory ( const char *  p_path,
directory_callback p_out,
abort_callback p_abort 
)
static

Definition at line 210 of file filesystem.cpp.

211 {
212  TRACK_CALL_TEXT("filesystem::g_list_directory");
213  g_get_interface(p_path)->list_directory(p_path,p_out,p_abort);
214 }
static bool g_get_interface(service_ptr_t< filesystem > &p_out, const char *path)
Definition: filesystem.cpp:121
void filesystem::g_move ( const char *  p_src,
const char *  p_dst,
abort_callback p_abort 
)
static

Moves file from one path to another.

Definition at line 188 of file filesystem.cpp.

188  {
191  if (e.first(ptr)) do {
192  if (ptr->is_our_path(src) && ptr->is_our_path(dst)) {
193  ptr->move(src,dst,p_abort);
194  return;
195  }
196  } while(e.next(ptr));
197  throw exception_io_no_handler_for_path();
198 }
bool first(service_ptr_t< t_query > &p_out)
Definition: service.h:581
Autopointer class to be used with all services. Manages reference counter calls behind-the-scenes.
Definition: service.h:55
bool next(service_ptr_t< t_query > &p_out)
Definition: service.h:587
void filesystem::g_move_timeout ( const char *  p_src,
const char *  p_dst,
double  p_timeout,
abort_callback p_abort 
)
static

Attempts to move file from one path to another; if the operation fails with a sharing violation error, keeps retrying (with short sleep period between retries) for specified amount of time.

Definition at line 175 of file filesystem.cpp.

175  {
176  FB2K_RETRY_FILE_MOVE( g_move(p_src, p_dst, p_abort), p_abort, p_timeout );
177 }
static void g_move(const char *p_src, const char *p_dst, abort_callback &p_abort)
Moves file from one path to another.
Definition: filesystem.cpp:188
void filesystem::g_open ( service_ptr_t< file > &  p_out,
const char *  p_path,
t_open_mode  p_mode,
abort_callback p_abort 
)
static

Opens file at specified path, with specified access privileges.

Definition at line 136 of file filesystem.cpp.

137 {
138  TRACK_CALL_TEXT("filesystem::g_open");
139  g_get_interface(path)->open(p_out,path,mode,p_abort);
140 }
static bool g_get_interface(service_ptr_t< filesystem > &p_out, const char *path)
Definition: filesystem.cpp:121
void filesystem::g_open_precache ( service_ptr_t< file > &  p_out,
const char *  path,
abort_callback p_abort 
)
static

Definition at line 248 of file filesystem.cpp.

248  {
250  if (fs->is_remote(p_path)) throw exception_io_object_is_remote();
251  fs->open(p_out,p_path,open_mode_read,p_abort);
252 }
static bool g_get_interface(service_ptr_t< filesystem > &p_out, const char *path)
Definition: filesystem.cpp:121
Opens an existing file for reading; if the file does not exist, the operation will fail...
Definition: filesystem.h:389
Autopointer class to be used with all services. Manages reference counter calls behind-the-scenes.
Definition: service.h:55
static void foobar2000_io::filesystem::g_open_read ( service_ptr_t< file > &  p_out,
const char *  path,
abort_callback p_abort 
)
inlinestatic

Definition at line 440 of file filesystem.h.

440 {return g_open(p_out,path,open_mode_read,p_abort);}
static void g_open(service_ptr_t< file > &p_out, const char *p_path, t_open_mode p_mode, abort_callback &p_abort)
Opens file at specified path, with specified access privileges.
Definition: filesystem.cpp:136
Opens an existing file for reading; if the file does not exist, the operation will fail...
Definition: filesystem.h:389
void filesystem::g_open_temp ( service_ptr_t< file > &  p_out,
abort_callback p_abort 
)
static

Definition at line 638 of file filesystem.cpp.

638  {
639  g_open(p_out,"tempfile://",open_mode_write_new,p_abort);
640 }
static void g_open(service_ptr_t< file > &p_out, const char *p_path, t_open_mode p_mode, abort_callback &p_abort)
Opens file at specified path, with specified access privileges.
Definition: filesystem.cpp:136
Opens a new file for writing; if the file exists, its contents will be wiped.
Definition: filesystem.h:393
void filesystem::g_open_tempmem ( service_ptr_t< file > &  p_out,
abort_callback p_abort 
)
static

Definition at line 642 of file filesystem.cpp.

642  {
643  g_open(p_out,"tempmem://",open_mode_write_new,p_abort);
644 }
static void g_open(service_ptr_t< file > &p_out, const char *p_path, t_open_mode p_mode, abort_callback &p_abort)
Opens file at specified path, with specified access privileges.
Definition: filesystem.cpp:136
Opens a new file for writing; if the file exists, its contents will be wiped.
Definition: filesystem.h:393
file::ptr filesystem::g_open_tempmem ( )
static

Definition at line 646 of file filesystem.cpp.

646  {
647  abort_callback_dummy aborter;
648  file::ptr f; g_open_tempmem(f, aborter); return f;
649 }
abort_callback_impl abort_callback_dummy
static file::ptr g_open_tempmem()
Definition: filesystem.cpp:646
void filesystem::g_open_timeout ( service_ptr_t< file > &  p_out,
const char *  p_path,
t_open_mode  p_mode,
double  p_timeout,
abort_callback p_abort 
)
static

Attempts to open file at specified path; if the operation fails with sharing violation error, keeps retrying (with short sleep period between retries) for specified amount of time.

Definition at line 143 of file filesystem.cpp.

143  {
144  FB2K_RETRY_ON_SHARING_VIOLATION( g_open(p_out, p_path, p_mode, p_abort), p_abort, p_timeout);
145 }
static void g_open(service_ptr_t< file > &p_out, const char *p_path, t_open_mode p_mode, abort_callback &p_abort)
Opens file at specified path, with specified access privileges.
Definition: filesystem.cpp:136
void filesystem::g_open_write_new ( service_ptr_t< file > &  p_out,
const char *  p_path,
abort_callback p_abort 
)
static

Definition at line 622 of file filesystem.cpp.

622  {
623  g_open(p_out,p_path,open_mode_write_new,p_abort);
624 }
static void g_open(service_ptr_t< file > &p_out, const char *p_path, t_open_mode p_mode, abort_callback &p_abort)
Opens file at specified path, with specified access privileges.
Definition: filesystem.cpp:136
Opens a new file for writing; if the file exists, its contents will be wiped.
Definition: filesystem.h:393
bool filesystem::g_relative_path_create ( const char *  p_file_path,
const char *  p_playlist_path,
pfc::string_base out 
)
static

Definition at line 270 of file filesystem.cpp.

271 {
272 
273  bool rv = false;
275 
276  if (g_get_interface(fs,file_path))
277  rv = fs->relative_path_create(file_path,playlist_path,out);
278 
279  return rv;
280 }
static bool g_get_interface(service_ptr_t< filesystem > &p_out, const char *path)
Definition: filesystem.cpp:121
Autopointer class to be used with all services. Manages reference counter calls behind-the-scenes.
Definition: service.h:55
bool filesystem::g_relative_path_parse ( const char *  p_relative_path,
const char *  p_playlist_path,
pfc::string_base out 
)
static

Definition at line 282 of file filesystem.cpp.

283 {
286  if (e.first(ptr)) do {
287  if (ptr->relative_path_parse(relative_path,playlist_path,out)) return true;
288  } while(e.next(ptr));
289  return false;
290 }
bool first(service_ptr_t< t_query > &p_out)
Definition: service.h:581
Autopointer class to be used with all services. Manages reference counter calls behind-the-scenes.
Definition: service.h:55
bool next(service_ptr_t< t_query > &p_out)
Definition: service.h:587
void filesystem::g_remove ( const char *  p_path,
abort_callback p_abort 
)
static

Removes file at specified path.

Definition at line 167 of file filesystem.cpp.

167  {
168  g_get_interface(p_path)->remove(p_path,p_abort);
169 }
static bool g_get_interface(service_ptr_t< filesystem > &p_out, const char *path)
Definition: filesystem.cpp:121
void filesystem::g_remove_object_recur ( const char *  path,
abort_callback abort 
)
static

Definition at line 1003 of file filesystem.cpp.

1003  {
1004  g_get_interface(path)->remove_object_recur(path, abort);
1005 }
static bool g_get_interface(service_ptr_t< filesystem > &p_out, const char *path)
Definition: filesystem.cpp:121
void filesystem::g_remove_object_recur_timeout ( const char *  path,
double  timeout,
abort_callback abort 
)
static

Definition at line 999 of file filesystem.cpp.

999  {
1000  FB2K_RETRY_FILE_MOVE( g_remove_object_recur(path, abort), abort, timeout );
1001 }
static void g_remove_object_recur(const char *path, abort_callback &abort)
void filesystem::g_remove_timeout ( const char *  p_path,
double  p_timeout,
abort_callback p_abort 
)
static

Attempts to remove file at specified path; if the operation fails with a sharing violation error, keeps retrying (with short sleep period between retries) for specified amount of time.

Definition at line 171 of file filesystem.cpp.

171  {
172  FB2K_RETRY_FILE_MOVE( g_remove(p_path, p_abort), p_abort, p_timeout );
173 }
static void g_remove(const char *p_path, abort_callback &p_abort)
Removes file at specified path.
Definition: filesystem.cpp:167
virtual bool foobar2000_io::filesystem::get_canonical_path ( const char *  p_path,
pfc::string_base p_out 
)
pure virtual

Implemented in foobar2000_io::archive_impl.

virtual bool foobar2000_io::filesystem::get_display_path ( const char *  p_path,
pfc::string_base p_out 
)
pure virtual

Implemented in foobar2000_io::archive_impl.

virtual void foobar2000_io::filesystem::get_stats ( const char *  p_path,
t_filestats p_stats,
bool &  p_is_writeable,
abort_callback p_abort 
)
pure virtual

Retrieves stats of a file at specified path.

Implemented in foobar2000_io::archive_impl.

virtual bool foobar2000_io::filesystem::is_our_path ( const char *  p_path)
pure virtual

Implemented in foobar2000_io::archive_impl.

virtual bool foobar2000_io::filesystem::is_remote ( const char *  p_src)
pure virtual

Queries whether a file at specified path belonging to this filesystem is a remove object or not.

Implemented in foobar2000_io::archive_impl.

virtual void foobar2000_io::filesystem::list_directory ( const char *  p_path,
directory_callback p_out,
abort_callback p_abort 
)
pure virtual

Implemented in foobar2000_io::archive_impl.

virtual void foobar2000_io::filesystem::move ( const char *  p_src,
const char *  p_dst,
abort_callback p_abort 
)
pure virtual

Implemented in foobar2000_io::archive_impl.

virtual void foobar2000_io::filesystem::open ( service_ptr_t< file > &  p_out,
const char *  p_path,
t_open_mode  p_mode,
abort_callback p_abort 
)
pure virtual

Implemented in foobar2000_io::archive_impl.

virtual bool foobar2000_io::filesystem::relative_path_create ( const char *  file_path,
const char *  playlist_path,
pfc::string_base out 
)
inlinevirtual

Reimplemented in foobar2000_io::archive_impl.

Definition at line 409 of file filesystem.h.

409 {return false;}
virtual bool foobar2000_io::filesystem::relative_path_parse ( const char *  relative_path,
const char *  playlist_path,
pfc::string_base out 
)
inlinevirtual

Reimplemented in foobar2000_io::archive_impl.

Definition at line 410 of file filesystem.h.

410 {return false;}
virtual void foobar2000_io::filesystem::remove ( const char *  p_path,
abort_callback p_abort 
)
pure virtual

Implemented in foobar2000_io::archive_impl.

void filesystem::remove_directory_content ( const char *  path,
abort_callback abort 
)

Definition at line 978 of file filesystem.cpp.

978  {
979  class myCallback : public directory_callback {
980  public:
981  bool on_entry(filesystem * p_owner,abort_callback & p_abort,const char * p_url,bool p_is_subdirectory,const t_filestats & p_stats) {
982  if (p_is_subdirectory) p_owner->list_directory(p_url, *this, p_abort);
983  try {
984  p_owner->remove(p_url, p_abort);
985  } catch(exception_io_not_found) {}
986  return true;
987  }
988  };
989  myCallback cb;
990  list_directory(path, cb, abort);
991 }
virtual void list_directory(const char *p_path, directory_callback &p_out, abort_callback &p_abort)=0
void filesystem::remove_object_recur ( const char *  path,
abort_callback abort 
)

Definition at line 992 of file filesystem.cpp.

992  {
993  try {
994  remove_directory_content(path, abort);
995  } catch(exception_io_not_found) {}
996  remove(path, abort);
997 }
void remove_directory_content(const char *path, abort_callback &abort)
Definition: filesystem.cpp:978
FILE * filesystem::streamio_open ( const char *  p_path,
const char *  p_flags 
)
static

If for some bloody reason you ever need stream io compatibility, use this, INSTEAD of calling fopen() on the path string you've got; will only work with file:// (and not with http://, unpack:// or whatever)

Definition at line 435 of file filesystem.cpp.

436 {
437  FILE * ret = 0;
438  pfc::string8 temp;
439  g_get_canonical_path(path,temp);
440  if (!strncmp(temp,"file://",7))
441  {
443  }
444  return ret;
445 }
static void g_get_canonical_path(const char *path, pfc::string_base &out)
Definition: filesystem.cpp:74
virtual bool foobar2000_io::filesystem::supports_content_types ( )
pure virtual

Hint; returns whether this filesystem supports mime types.
When this returns false, all file::get_content_type() calls on files opened thru this filesystem implementation will return false; otherwise, file::get_content_type() calls may return true depending on the file.


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