foobar2000 SDK  2015-08-03
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions
foobar2000_io::archive_implabstract

#include <filesystem.h>

+ Inheritance diagram for foobar2000_io::archive_impl:

Public Member Functions

virtual void archive_list (const char *path, const service_ptr_t< file > &p_reader, archive_callback &p_out, bool p_want_readers)=0
 
void make_unpack_path (pfc::string_base &path, const char *archive, const char *file)
 
- Public Member Functions inherited from foobar2000_io::archive
 FB2K_MAKE_SERVICE_INTERFACE (archive, filesystem)
 
- Public Member Functions inherited from foobar2000_io::filesystem
void copy_directory (const char *p_src, const char *p_dst, abort_callback &p_abort)
 
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 bool g_is_unpack_path (const char *path)
 
static void g_make_unpack_path (pfc::string_base &path, const char *archive, const char *file, const char *type)
 
static bool g_parse_unpack_path (const char *path, pfc::string_base &archive, pfc::string_base &file)
 
static bool g_parse_unpack_path_ex (const char *path, pfc::string_base &archive, pfc::string_base &file, pfc::string_base &type)
 
- Static Public Member Functions inherited from foobar2000_io::filesystem
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)
 

Protected Member Functions

virtual const char * get_archive_type ()=0
 
virtual t_filestats get_stats_in_archive (const char *p_archive, const char *p_file, abort_callback &p_abort)=0
 
virtual void open_archive (service_ptr_t< file > &p_out, const char *archive, const char *file, abort_callback &p_abort)=0
 
- Protected Member Functions inherited from service_base
 service_base ()
 
 ~service_base ()
 

Private Member Functions

void create_directory (const char *path, abort_callback &)
 
bool get_canonical_path (const char *path, pfc::string_base &out)
 
bool get_display_path (const char *path, pfc::string_base &out)
 
void get_stats (const char *p_path, t_filestats &p_stats, bool &p_is_writeable, abort_callback &p_abort)
 
bool is_our_path (const char *path)
 
bool is_remote (const char *src)
 
void list_directory (const char *p_path, directory_callback &p_out, abort_callback &p_abort)
 
void move (const char *src, const char *dst, abort_callback &p_abort)
 
void open (service_ptr_t< file > &p_out, const char *path, t_open_mode mode, abort_callback &p_abort)
 
bool relative_path_create (const char *file_path, const char *playlist_path, pfc::string_base &out)
 
bool relative_path_parse (const char *relative_path, const char *playlist_path, pfc::string_base &out)
 
void remove (const char *path, abort_callback &p_abort)
 

Additional Inherited Members

- Public Types inherited from foobar2000_io::filesystem
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
 

Detailed Description

Root class for archive implementations. Derive from this instead of from archive directly.

Definition at line 527 of file filesystem.h.

Member Function Documentation

virtual void foobar2000_io::archive_impl::archive_list ( const char *  path,
const service_ptr_t< file > &  p_reader,
archive_callback p_out,
bool  p_want_readers 
)
pure virtual
void archive_impl::create_directory ( const char *  p_path,
abort_callback p_abort 
)
privatevirtual

Creates a directory.

Implements foobar2000_io::filesystem.

Definition at line 655 of file filesystem.cpp.

655  {
656  throw exception_io_denied();
657 }
bool archive_impl::g_is_unpack_path ( const char *  path)
static

Definition at line 420 of file filesystem.cpp.

420  {
421  return strncmp(path,unpack_prefix,unpack_prefix_len) == 0;
422 }
static const unsigned unpack_prefix_len
Definition: filesystem.cpp:4
static const char unpack_prefix[]
Definition: filesystem.cpp:3
void archive_impl::g_make_unpack_path ( pfc::string_base path,
const char *  archive,
const char *  file,
const char *  type 
)
static

Definition at line 424 of file filesystem.cpp.

425 {
426  path = unpack_prefix;
427  path += name;
428  path_pack_string(path,archive);
429  path += file;
430 }
static const char unpack_prefix[]
Definition: filesystem.cpp:3
static void path_pack_string(pfc::string_base &out, const char *src)
Definition: filesystem.cpp:217
Decoder Validator v1 readme Usage Select a single file handled by the decoder you want to select Utils Decoder Utils Tag Writer Validator or Utils Fuzzer from the context menu with randomly generated info In case of the file will likely be permanently damaged or left with nonsense in its tags What Decoder Validator does Decoder Validator runs a series of automated decoding tests on the specified file
Definition: readme.txt:8
bool archive_impl::g_parse_unpack_path ( const char *  path,
pfc::string_base archive,
pfc::string_base file 
)
static

Definition at line 409 of file filesystem.cpp.

409  {
410  PFC_ASSERT( g_is_unpack_path(path) );
411  path = strchr(path,'|');
412  if (!path) return false;
413  int delta = path_unpack_string(archive,path);
414  if (delta<0) return false;
415  path += delta;
416  file = path;
417  return true;
418 }
static int path_unpack_string(pfc::string_base &out, const char *src)
Definition: filesystem.cpp:226
static bool g_is_unpack_path(const char *path)
Definition: filesystem.cpp:420
bool archive_impl::g_parse_unpack_path_ex ( const char *  path,
pfc::string_base archive,
pfc::string_base file,
pfc::string_base type 
)
static

Definition at line 396 of file filesystem.cpp.

396  {
397  PFC_ASSERT( g_is_unpack_path(path) );
398  const char * base = path + unpack_prefix_len; // strstr(path, "//");
399  const char * split = strchr(path,'|');
400  if (base == NULL || split == NULL || base > split) return false;
401  // base += 2;
402  type.set_string( base, split - base );
403  int delta = path_unpack_string(archive,split);
404  if (delta<0) return false;
405  split += delta;
406  file = split;
407  return true;
408 }
static int path_unpack_string(pfc::string_base &out, const char *src)
Definition: filesystem.cpp:226
static const unsigned unpack_prefix_len
Definition: filesystem.cpp:4
virtual void set_string(const char *p_string, t_size p_length=~0)
Definition: string_base.h:198
static bool g_is_unpack_path(const char *path)
Definition: filesystem.cpp:420
virtual const char* foobar2000_io::archive_impl::get_archive_type ( )
protectedpure virtual
bool archive_impl::get_canonical_path ( const char *  path,
pfc::string_base out 
)
privatevirtual

Implements foobar2000_io::filesystem.

Definition at line 294 of file filesystem.cpp.

295 {
296  if (is_our_path(path))
297  {
298  pfc::string8 archive,file,archive_canonical;
299  if (g_parse_unpack_path(path,archive,file))
300  {
301  g_get_canonical_path(archive,archive_canonical);
302  make_unpack_path(out,archive_canonical,file);
303 
304  return true;
305  }
306  else return false;
307  }
308  else return false;
309 }
bool is_our_path(const char *path)
Definition: filesystem.cpp:311
static void g_get_canonical_path(const char *path, pfc::string_base &out)
Definition: filesystem.cpp:74
void make_unpack_path(pfc::string_base &path, const char *archive, const char *file)
Definition: filesystem.cpp:432
Decoder Validator v1 readme Usage Select a single file handled by the decoder you want to select Utils Decoder Utils Tag Writer Validator or Utils Fuzzer from the context menu with randomly generated info In case of the file will likely be permanently damaged or left with nonsense in its tags What Decoder Validator does Decoder Validator runs a series of automated decoding tests on the specified file
Definition: readme.txt:8
static bool g_parse_unpack_path(const char *path, pfc::string_base &archive, pfc::string_base &file)
Definition: filesystem.cpp:409
bool archive_impl::get_display_path ( const char *  path,
pfc::string_base out 
)
privatevirtual

Implements foobar2000_io::filesystem.

Definition at line 326 of file filesystem.cpp.

327 {
328  pfc::string8 archive,file;
329  if (g_parse_unpack_path(path,archive,file))
330  {
331  g_get_display_path(archive,out);
332  out.add_string("|");
333  out.add_string(file);
334  return true;
335  }
336  else return false;
337 }
virtual void add_string(const char *p_string, t_size p_length=~0)=0
static void g_get_display_path(const char *path, pfc::string_base &out)
Definition: filesystem.cpp:87
Decoder Validator v1 readme Usage Select a single file handled by the decoder you want to select Utils Decoder Utils Tag Writer Validator or Utils Fuzzer from the context menu with randomly generated info In case of the file will likely be permanently damaged or left with nonsense in its tags What Decoder Validator does Decoder Validator runs a series of automated decoding tests on the specified file
Definition: readme.txt:8
static bool g_parse_unpack_path(const char *path, pfc::string_base &archive, pfc::string_base &file)
Definition: filesystem.cpp:409
void archive_impl::get_stats ( const char *  p_path,
t_filestats p_stats,
bool &  p_is_writeable,
abort_callback p_abort 
)
privatevirtual

Retrieves stats of a file at specified path.

Implements foobar2000_io::filesystem.

Definition at line 664 of file filesystem.cpp.

664  {
665  pfc::string8 archive,file;
666  if (g_parse_unpack_path(p_path,archive,file)) {
667  if (g_is_remote(archive)) throw exception_io_object_is_remote();
668  p_is_writeable = false;
669  p_stats = get_stats_in_archive(archive,file,p_abort);
670  }
671  else throw exception_io_not_found();
672 }
virtual t_filestats get_stats_in_archive(const char *p_archive, const char *p_file, abort_callback &p_abort)=0
static bool g_is_remote(const char *p_path)
Definition: filesystem.cpp:254
Decoder Validator v1 readme Usage Select a single file handled by the decoder you want to select Utils Decoder Utils Tag Writer Validator or Utils Fuzzer from the context menu with randomly generated info In case of the file will likely be permanently damaged or left with nonsense in its tags What Decoder Validator does Decoder Validator runs a series of automated decoding tests on the specified file
Definition: readme.txt:8
static bool g_parse_unpack_path(const char *path, pfc::string_base &archive, pfc::string_base &file)
Definition: filesystem.cpp:409
virtual t_filestats foobar2000_io::archive_impl::get_stats_in_archive ( const char *  p_archive,
const char *  p_file,
abort_callback p_abort 
)
protectedpure virtual
bool archive_impl::is_our_path ( const char *  path)
privatevirtual

Implements foobar2000_io::filesystem.

Definition at line 311 of file filesystem.cpp.

312 {
313  if (!g_is_unpack_path(path)) return false;
314  const char * type = get_archive_type();
315  path += 9;
316  while(*type)
317  {
318  if (*type!=*path) return false;
319  type++;
320  path++;
321  }
322  if (*path!='|') return false;
323  return true;
324 }
virtual const char * get_archive_type()=0
static bool g_is_unpack_path(const char *path)
Definition: filesystem.cpp:420
bool archive_impl::is_remote ( const char *  p_src)
privatevirtual

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

Implements foobar2000_io::filesystem.

Definition at line 356 of file filesystem.cpp.

356  {
357  pfc::string8 archive,file;
358  if (g_parse_unpack_path(src,archive,file)) return g_is_remote(archive);
359  else throw exception_io_not_found();
360 }
static bool g_is_remote(const char *p_path)
Definition: filesystem.cpp:254
Decoder Validator v1 readme Usage Select a single file handled by the decoder you want to select Utils Decoder Utils Tag Writer Validator or Utils Fuzzer from the context menu with randomly generated info In case of the file will likely be permanently damaged or left with nonsense in its tags What Decoder Validator does Decoder Validator runs a series of automated decoding tests on the specified file
Definition: readme.txt:8
static bool g_parse_unpack_path(const char *path, pfc::string_base &archive, pfc::string_base &file)
Definition: filesystem.cpp:409
void archive_impl::list_directory ( const char *  p_path,
directory_callback p_out,
abort_callback p_abort 
)
privatevirtual

Implements foobar2000_io::filesystem.

Definition at line 651 of file filesystem.cpp.

651  {
652  throw exception_io_not_found();
653 }
void archive_impl::make_unpack_path ( pfc::string_base path,
const char *  archive,
const char *  file 
)

Definition at line 432 of file filesystem.cpp.

432 {g_make_unpack_path(path,archive,file,get_archive_type());}
static void g_make_unpack_path(pfc::string_base &path, const char *archive, const char *file, const char *type)
Definition: filesystem.cpp:424
virtual const char * get_archive_type()=0
void archive_impl::move ( const char *  src,
const char *  dst,
abort_callback p_abort 
)
privatevirtual

Implements foobar2000_io::filesystem.

Definition at line 352 of file filesystem.cpp.

352  {
353  throw exception_io_denied();
354 }
void archive_impl::open ( service_ptr_t< file > &  p_out,
const char *  path,
t_open_mode  mode,
abort_callback p_abort 
)
privatevirtual

Implements foobar2000_io::filesystem.

Definition at line 339 of file filesystem.cpp.

340 {
341  if (mode != open_mode_read) throw exception_io_denied();
342  pfc::string8 archive,file;
343  if (!g_parse_unpack_path(path,archive,file)) throw exception_io_not_found();
344  open_archive(p_out,archive,file,p_abort);
345 }
Opens an existing file for reading; if the file does not exist, the operation will fail...
Definition: filesystem.h:389
virtual void open_archive(service_ptr_t< file > &p_out, const char *archive, const char *file, abort_callback &p_abort)=0
Decoder Validator v1 readme Usage Select a single file handled by the decoder you want to select Utils Decoder Utils Tag Writer Validator or Utils Fuzzer from the context menu with randomly generated info In case of the file will likely be permanently damaged or left with nonsense in its tags What Decoder Validator does Decoder Validator runs a series of automated decoding tests on the specified file
Definition: readme.txt:8
static bool g_parse_unpack_path(const char *path, pfc::string_base &archive, pfc::string_base &file)
Definition: filesystem.cpp:409
virtual void foobar2000_io::archive_impl::open_archive ( service_ptr_t< file > &  p_out,
const char *  archive,
const char *  file,
abort_callback p_abort 
)
protectedpure virtual
bool archive_impl::relative_path_create ( const char *  file_path,
const char *  playlist_path,
pfc::string_base out 
)
privatevirtual

Reimplemented from foobar2000_io::filesystem.

Definition at line 362 of file filesystem.cpp.

362  {
363  pfc::string8 archive,file;
364  if (g_parse_unpack_path(file_path,archive,file))
365  {
366  pfc::string8 archive_rel;
367  if (g_relative_path_create(archive,playlist_path,archive_rel))
368  {
369  pfc::string8 out_path;
370  make_unpack_path(out_path,archive_rel,file);
371  out.set_string(out_path);
372  return true;
373  }
374  }
375  return false;
376 }
static bool g_relative_path_create(const char *p_file_path, const char *p_playlist_path, pfc::string_base &out)
Definition: filesystem.cpp:270
virtual void set_string(const char *p_string, t_size p_length=~0)
Definition: string_base.h:198
void make_unpack_path(pfc::string_base &path, const char *archive, const char *file)
Definition: filesystem.cpp:432
Decoder Validator v1 readme Usage Select a single file handled by the decoder you want to select Utils Decoder Utils Tag Writer Validator or Utils Fuzzer from the context menu with randomly generated info In case of the file will likely be permanently damaged or left with nonsense in its tags What Decoder Validator does Decoder Validator runs a series of automated decoding tests on the specified file
Definition: readme.txt:8
static bool g_parse_unpack_path(const char *path, pfc::string_base &archive, pfc::string_base &file)
Definition: filesystem.cpp:409
bool archive_impl::relative_path_parse ( const char *  relative_path,
const char *  playlist_path,
pfc::string_base out 
)
privatevirtual

Reimplemented from foobar2000_io::filesystem.

Definition at line 378 of file filesystem.cpp.

379 {
380  if (!is_our_path(relative_path)) return false;
381  pfc::string8 archive_rel,file;
382  if (g_parse_unpack_path(relative_path,archive_rel,file))
383  {
384  pfc::string8 archive;
385  if (g_relative_path_parse(archive_rel,playlist_path,archive))
386  {
387  pfc::string8 out_path;
388  make_unpack_path(out_path,archive,file);
389  out.set_string(out_path);
390  return true;
391  }
392  }
393  return false;
394 }
bool is_our_path(const char *path)
Definition: filesystem.cpp:311
static bool g_relative_path_parse(const char *p_relative_path, const char *p_playlist_path, pfc::string_base &out)
Definition: filesystem.cpp:282
virtual void set_string(const char *p_string, t_size p_length=~0)
Definition: string_base.h:198
void make_unpack_path(pfc::string_base &path, const char *archive, const char *file)
Definition: filesystem.cpp:432
Decoder Validator v1 readme Usage Select a single file handled by the decoder you want to select Utils Decoder Utils Tag Writer Validator or Utils Fuzzer from the context menu with randomly generated info In case of the file will likely be permanently damaged or left with nonsense in its tags What Decoder Validator does Decoder Validator runs a series of automated decoding tests on the specified file
Definition: readme.txt:8
static bool g_parse_unpack_path(const char *path, pfc::string_base &archive, pfc::string_base &file)
Definition: filesystem.cpp:409
void archive_impl::remove ( const char *  path,
abort_callback p_abort 
)
privatevirtual

Implements foobar2000_io::filesystem.

Definition at line 348 of file filesystem.cpp.

348  {
349  throw exception_io_denied();
350 }

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