fs/Path: add method GetSuffix()

Type-safe wrapper for uri_get_suffix().
This commit is contained in:
Max Kellermann 2015-03-01 01:09:53 +01:00
parent 41cc31c124
commit 7ce96585f5
5 changed files with 14 additions and 4 deletions

View File

@ -1635,12 +1635,12 @@ test_run_input_LDADD = \
$(ARCHIVE_LIBS) \ $(ARCHIVE_LIBS) \
$(TAG_LIBS) \ $(TAG_LIBS) \
libconf.a \ libconf.a \
libutil.a \
libevent.a \ libevent.a \
libthread.a \ libthread.a \
$(FS_LIBS) \ $(FS_LIBS) \
$(ICU_LDADD) \ $(ICU_LDADD) \
libsystem.a \ libsystem.a \
libutil.a \
$(GLIB_LIBS) $(GLIB_LIBS)
test_run_input_SOURCES = test/run_input.cxx \ test_run_input_SOURCES = test/run_input.cxx \
test/ScopeIOThread.hxx \ test/ScopeIOThread.hxx \
@ -1682,12 +1682,12 @@ test_visit_archive_LDADD = \
$(ARCHIVE_LIBS) \ $(ARCHIVE_LIBS) \
$(TAG_LIBS) \ $(TAG_LIBS) \
libconf.a \ libconf.a \
libutil.a \
libevent.a \ libevent.a \
libthread.a \ libthread.a \
$(FS_LIBS) \ $(FS_LIBS) \
$(ICU_LDADD) \ $(ICU_LDADD) \
libsystem.a \ libsystem.a \
libutil.a \
$(GLIB_LIBS) $(GLIB_LIBS)
test_visit_archive_SOURCES = test/visit_archive.cxx \ test_visit_archive_SOURCES = test/visit_archive.cxx \
test/ScopeIOThread.hxx \ test/ScopeIOThread.hxx \

View File

@ -87,7 +87,7 @@ tag_file_scan(Path path_fs, const tag_handler &handler, void *handler_ctx)
/* check if there's a suffix and a plugin */ /* check if there's a suffix and a plugin */
const char *suffix = uri_get_suffix(path_fs.c_str()); const char *suffix = path_fs.GetSuffix();
if (suffix == nullptr) if (suffix == nullptr)
return false; return false;

View File

@ -20,9 +20,16 @@
#include "config.h" #include "config.h"
#include "Path.hxx" #include "Path.hxx"
#include "Charset.hxx" #include "Charset.hxx"
#include "util/UriUtil.hxx"
std::string std::string
Path::ToUTF8() const Path::ToUTF8() const
{ {
return ::PathToUTF8(c_str()); return ::PathToUTF8(c_str());
} }
const char *
Path::GetSuffix() const
{
return uri_get_suffix(c_str());
}

View File

@ -161,6 +161,9 @@ public:
bool IsAbsolute() const { bool IsAbsolute() const {
return PathTraitsFS::IsAbsolute(c_str()); return PathTraitsFS::IsAbsolute(c_str());
} }
gcc_pure
const char *GetSuffix() const;
}; };
#endif #endif

View File

@ -35,7 +35,7 @@ playlist_open_path_suffix(Path path, Mutex &mutex, Cond &cond)
{ {
assert(!path.IsNull()); assert(!path.IsNull());
const char *suffix = uri_get_suffix(path.c_str()); const char *suffix = path.GetSuffix();
if (suffix == nullptr || !playlist_suffix_supported(suffix)) if (suffix == nullptr || !playlist_suffix_supported(suffix))
return nullptr; return nullptr;