fs/Path: add operator/(Path,Path)
Modeled after std::filesystem::operator/() from C++17.
This commit is contained in:
@@ -53,8 +53,7 @@ CreateConfiguredDatabase(EventLoop &main_event_loop, EventLoop &io_event_loop,
|
||||
if (cache_dir.IsNull())
|
||||
return nullptr;
|
||||
|
||||
const auto db_file = AllocatedPath::Build(cache_dir,
|
||||
PATH_LITERAL("mpd.db"));
|
||||
const auto db_file = cache_dir / Path::FromFS(PATH_LITERAL("mpd.db"));
|
||||
const auto db_file_utf8 = db_file.ToUTF8();
|
||||
if (db_file_utf8.empty())
|
||||
return nullptr;
|
||||
|
@@ -428,8 +428,7 @@ SimpleDatabase::Mount(const char *local_uri, const char *storage_uri)
|
||||
#ifndef ENABLE_ZLIB
|
||||
constexpr bool compress = false;
|
||||
#endif
|
||||
auto db = new SimpleDatabase(AllocatedPath::Build(cache_path,
|
||||
name_fs.c_str()),
|
||||
auto db = new SimpleDatabase(cache_path / name_fs,
|
||||
compress);
|
||||
try {
|
||||
db->Open();
|
||||
|
@@ -141,7 +141,7 @@ WatchDirectory::GetUriFS() const noexcept
|
||||
if (uri.IsNull())
|
||||
return name;
|
||||
|
||||
return AllocatedPath::Build(uri, name);
|
||||
return uri / name;
|
||||
}
|
||||
|
||||
/* we don't look at "." / ".." nor files with newlines in their name */
|
||||
@@ -181,8 +181,8 @@ recursive_watch_subdirectories(WatchDirectory *directory,
|
||||
if (skip_path(ent->d_name))
|
||||
continue;
|
||||
|
||||
const auto child_path_fs =
|
||||
AllocatedPath::Build(path_fs, ent->d_name);
|
||||
const auto name_fs = Path::FromFS(ent->d_name);
|
||||
const auto child_path_fs = path_fs / name_fs;
|
||||
|
||||
FileInfo fi;
|
||||
try {
|
||||
@@ -211,7 +211,7 @@ recursive_watch_subdirectories(WatchDirectory *directory,
|
||||
continue;
|
||||
|
||||
directory->children.emplace_front(directory,
|
||||
AllocatedPath::FromFS(ent->d_name),
|
||||
name_fs,
|
||||
ret);
|
||||
child = &directory->children.front();
|
||||
|
||||
@@ -262,7 +262,7 @@ mpd_inotify_callback(int wd, unsigned mask,
|
||||
|
||||
const auto path_fs = uri_fs.IsNull()
|
||||
? root
|
||||
: AllocatedPath::Build(root, uri_fs.c_str());
|
||||
: (root / uri_fs);
|
||||
|
||||
recursive_watch_subdirectories(directory, path_fs,
|
||||
directory->GetDepth());
|
||||
|
Reference in New Issue
Block a user