foobar2000 SDK  2015-01-14
Functions
input.cpp File Reference

Go to the source code of this file.

Functions

void input_open_file_helper (service_ptr_t< file > &p_file, const char *p_path, t_input_open_reason p_reason, abort_callback &p_abort)
 
static void prepare_for_open (service_ptr_t< input_entry > &p_service, service_ptr_t< file > &p_file, const char *p_path, filesystem::t_open_mode p_open_mode, abort_callback &p_abort, bool p_from_redirect)
 

Function Documentation

void input_open_file_helper ( service_ptr_t< file > &  p_file,
const char *  p_path,
t_input_open_reason  p_reason,
abort_callback p_abort 
)

Helper function for input implementation use; ensures that file is open with relevant access mode. This is typically called from input_impl::open() and such.

Parameters
p_fileFile object pointer to process. If passed pointer is non-null, the function does nothing and always succeeds; otherwise it attempts to open the file using filesystem API methods.
p_pathPath to the file.
p_reasonType of input operation requested. See: input_impl::open() parameters.
p_abortabort_callback object signaling user aborting the operation.

Definition at line 231 of file input.cpp.

232 {
233  if (p_file.is_empty()) {
234  switch(p_reason) {
235  default:
236  uBugCheck();
238  case input_open_decode:
239  filesystem::g_open(p_file,p_path,filesystem::open_mode_read,p_abort);
240  break;
242  filesystem::g_open(p_file,p_path,filesystem::open_mode_write_existing,p_abort);
243  break;
244  }
245  } else {
246  p_file->reopen(p_abort);
247  }
248 }
bool is_empty() const
Definition: service.h:120
PFC_NORETURN void SHARED_EXPORT uBugCheck()
static void prepare_for_open ( service_ptr_t< input_entry > &  p_service,
service_ptr_t< file > &  p_file,
const char *  p_path,
filesystem::t_open_mode  p_open_mode,
abort_callback p_abort,
bool  p_from_redirect 
)
static

Definition at line 41 of file input.cpp.

42 {
43  if (p_file.is_empty())
44  {
46  if (filesystem::g_get_interface(fs,p_path)) {
47  if (fs->supports_content_types()) {
48  fs->open(p_file,p_path,p_open_mode,p_abort);
49  }
50  }
51  }
52 
53  if (p_file.is_valid())
54  {
55  pfc::string8 content_type;
56  if (p_file->get_content_type(content_type))
57  {
58  if (input_entry::g_find_service_by_content_type(p_service,content_type))
59  return;
60  }
61  }
62 
63  if (input_entry::g_find_service_by_path(p_service,p_path))
64  {
65  if (p_from_redirect && p_service->is_redirect()) throw exception_io_unsupported_format();
66  return;
67  }
68 
69  throw exception_io_unsupported_format();
70 }
static bool g_find_service_by_content_type(service_ptr_t< input_entry > &p_out, const char *p_content_type)
Definition: input.cpp:24
static bool g_find_service_by_path(service_ptr_t< input_entry > &p_out, const char *p_path)
Definition: input.cpp:3
bool is_empty() const
Definition: service.h:120
bool is_valid() const
Definition: service.h:119
Autopointer class to be used with all services. Manages reference counter calls behind-the-scenes.
Definition: service.h:55