3 #if FOOBAR2000_TARGET_VERSION >= 76 7 class archive_callback_impl :
public archive_callback {
9 archive_callback_impl(playlist_loader_callback::ptr p_callback,
abort_callback & p_abort) : m_callback(p_callback), m_abort(p_abort) {}
10 bool on_entry(archive * owner,
const char * p_path,
const t_filestats & p_stats,
const service_ptr_t<file> & p_reader)
12 process_path_internal(p_path,p_reader,m_callback,m_abort,playlist_loader_callback::entry_directory_enumerated,p_stats);
13 return !m_abort.is_aborting();
15 bool is_aborting()
const {
return m_abort.is_aborting();}
18 const playlist_loader_callback::ptr m_callback;
26 filesystem::g_get_canonical_path(p_path,filepath);
34 if (filesystem::g_get_interface(fs,filepath)) {
35 if (fs->supports_content_types()) {
36 fs->open(l_file,filepath,filesystem::open_mode_read,p_abort);
46 if (l_file->get_content_type(content_type)) {
49 if (l->is_our_content_type(content_type)) {
51 TRACK_CODE(
"playlist_loader::open",l->open(filepath,l_file,p_callback, p_abort));
53 }
catch(exception_io_unsupported_format) {
54 l_file->reopen(p_abort);
61 if (extension.
length()>0) {
62 playlist_loader::ptr l;
65 if (l_file.
is_empty()) filesystem::g_open_read(l_file,filepath,p_abort);
67 TRACK_CODE(
"playlist_loader::open",l->open(filepath,l_file,p_callback,p_abort));
69 }
catch(exception_io_unsupported_format) {
70 l_file->reopen(p_abort);
81 if (!g_try_load_playlist(fileHint, p_path, p_callback, p_abort))
throw exception_io_unsupported_format();
85 g_load_playlist_filehint(NULL,p_path,callback,abort);
90 TRACK_CALL_TEXT(
"index_tracks_helper");
91 if (p_reader.
is_empty() && filesystem::g_is_remote_safe(p_path))
93 TRACK_CALL_TEXT(
"remote");
97 p_callback->on_entry(handle,p_type,p_stats,
true);
99 TRACK_CALL_TEXT(
"hintable");
103 t_filestats stats = instance->get_file_stats(p_abort);
105 t_uint32 subsong,subsong_count = instance->get_subsong_count();
106 bool bInfoGetError =
false;
107 for(subsong=0;subsong<subsong_count;subsong++)
109 TRACK_CALL_TEXT(
"subsong-loop");
112 t_uint32 index = instance->get_subsong(subsong);
116 if (! bInfoGetError && p_callback->want_info(handle,p_type,stats,
true) )
120 TRACK_CODE(
"get_info",instance->get_info(index,info,p_abort));
122 bInfoGetError =
true;
124 p_callback->on_entry_info(handle,p_type,stats,info,
true);
128 p_callback->on_entry(handle,p_type,stats,
true);
135 bool got_input =
false;
139 }
catch(exception_aborted) {
141 }
catch(exception_io_unsupported_format) {
148 if (!got_input && !p_abort.is_aborting()) {
149 if (p_type == playlist_loader_callback::entry_user_requested)
153 p_callback->on_entry(handle,p_type,p_stats,
true);
163 class directory_callback_impl2 :
public directory_callback_impl
166 bool on_entry(filesystem * owner,
abort_callback & p_abort,
const char * url,
bool is_subdirectory,
const t_filestats & p_stats) {
170 const char * n = url;
173 if (att == ~0 || (att & FILE_ATTRIBUTE_HIDDEN) != 0)
return true;
177 return directory_callback_impl::on_entry(owner, p_abort, url, is_subdirectory, p_stats);
180 directory_callback_impl2(
bool p_recur) : directory_callback_impl(p_recur), m_addHidden(queryAddHidden()) {}
182 static bool queryAddHidden() {
184 static const GUID guid_cfg_addhidden =
185 { 0x2f9f4956, 0x363f, 0x4045, { 0x95, 0x31, 0x60, 0x3b, 0x1b, 0xf3, 0x9b, 0xa8 } };
187 advconfig_entry_checkbox::ptr ptr;
189 return ptr->get_state();
193 const bool m_addHidden;
204 callback->on_progress(p_path);
208 if (p_reader.
is_empty() && type != playlist_loader_callback::entry_directory_enumerated) {
209 directory_callback_impl2 directory_results(
true);
211 filesystem::g_list_directory(p_path,directory_results,abort);
212 for(
t_size n=0;n<directory_results.get_count();n++) {
213 process_path_internal(directory_results.get_item(n),0,callback,abort,playlist_loader_callback::entry_directory_enumerated,directory_results.get_item_stats(n));
216 }
catch(exception_aborted) {
throw;}
227 archive_callback_impl archive_results(callback, abort);
233 if (f->service_query_t(arch)) {
234 if (p_reader.
is_valid()) p_reader->reopen(abort);
237 TRACK_CODE(
"archive::archive_list",arch->archive_list(p_path,p_reader,archive_results,
true));
239 }
catch(exception_aborted) {
throw;}
252 if (p_reader.
is_valid()) p_reader->reopen(abort);
256 TRACK_CODE(
"link_resolver::resolve",ptr->resolve(p_reader,p_path,temp,abort));
260 }
catch(exception_aborted) {
throw;}
265 if (callback->is_path_wanted(p_path,type)) {
272 TRACK_CALL_TEXT(
"playlist_loader::g_process_path");
281 TRACK_CALL_TEXT(
"playlist_loader::g_save_playlist");
283 filesystem::g_get_canonical_path(p_filename,filename);
286 filesystem::g_open(r,filename,filesystem::open_mode_write_new,p_abort);
293 if (l->can_write() && !
stricmp_utf8(ext,l->get_extension())) {
295 TRACK_CODE(
"playlist_loader::write",l->write(filename,r,data,p_abort));
297 }
catch(exception_io_data) {}
300 throw exception_io_data();
302 try {filesystem::g_remove(filename,p_abort);}
catch(...) {}
310 if (g_try_load_playlist(NULL, filename, callback, abort))
return true;
312 g_process_path(filename,callback,abort,type);
DWORD SHARED_EXPORT uGetFileAttributes(const char *fn)
pfc::eventHandle_t abort_callback_event
void info(const char *p_message)
bool first(service_ptr_t< t_query > &p_out)
bool _extract_native_path_ptr(const char *&p_fspath)
int SHARED_EXPORT stricmp_utf8(const char *p1, const char *p2)
static bool g_process_path_ex(const char *p_path, playlist_loader_callback::ptr p_callback, abort_callback &p_abort, playlist_loader_callback::t_entry_type p_type=playlist_loader_callback::entry_user_requested)
Calls attempts to process specified path as a playlist; if that fails (i.e. not a playlist)...
static void fail(completion_notify_ptr p_notify)
static const t_filestats filestats_invalid
Invalid/unknown file stats constant. See: t_filestats.
static void g_open_for_info_read(service_ptr_t< input_info_reader > &p_instance, service_ptr_t< file > p_filehint, const char *p_path, abort_callback &p_abort, bool p_from_redirect=false)
static void index_tracks_helper(const char *p_path, const service_ptr_t< file > &p_reader, const t_filestats &p_stats, playlist_loader_callback::t_entry_type p_type, playlist_loader_callback::ptr p_callback, abort_callback &p_abort, bool &p_got_input)
static bool g_find_t(outptr &out, const GUID &id)
static bool g_find(service_ptr_t< link_resolver > &p_out, const char *p_path)
Helper function; finds link_resolver interface that supports specified link file. ...
static void g_process_path(const char *p_path, playlist_loader_callback::ptr p_callback, abort_callback &p_abort, playlist_loader_callback::t_entry_type p_type=playlist_loader_callback::entry_user_requested)
Processes specified path to generate list of playable items. Includes recursive directory/archive enu...
static void process_path_internal(const char *p_path, const service_ptr_t< file > &p_reader, playlist_loader_callback::ptr callback, abort_callback &abort, playlist_loader_callback::t_entry_type type, const t_filestats &p_stats)
static void g_save_playlist(const char *p_path, metadb_handle_list_cref p_data, abort_callback &p_abort)
Saves specified list of locations into a playlist file. Throws exception_io or derivatives on failure...
static void g_load_playlist_filehint(file::ptr fileHint, const char *p_path, playlist_loader_callback::ptr p_callback, abort_callback &p_abort)
Attempts to load a playlist file from specified filesystem path. Throws exception_io or derivatives o...
static void track_indexer__g_get_tracks_wrap(const char *p_path, const service_ptr_t< file > &p_reader, const t_filestats &p_stats, playlist_loader_callback::t_entry_type p_type, playlist_loader_callback::ptr p_callback, abort_callback &p_abort)
bool next(service_ptr_t< t_query > &p_out)
static void g_load_playlist(const char *p_path, playlist_loader_callback::ptr p_callback, abort_callback &p_abort)
Attempts to load a playlist file from specified filesystem path. Throws exception_io or derivatives o...
static bool g_try_load_playlist(file::ptr fileHint, const char *p_path, playlist_loader_callback::ptr p_callback, abort_callback &p_abort)
Attempts to load a playlist file from specified filesystem path. Throws exception_io or derivatives o...