Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
99d5b616
Commit
99d5b616
authored
Jul 17, 2018
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fs/Path: add operator/(Path,Path)
Modeled after std::filesystem::operator/() from C++17.
parent
79e89eb2
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
40 additions
and
32 deletions
+40
-32
CommandLine.cxx
src/CommandLine.cxx
+1
-1
Main.cxx
src/Main.cxx
+2
-2
Mapper.cxx
src/Mapper.cxx
+2
-2
PlaylistFile.cxx
src/PlaylistFile.cxx
+1
-1
FileCommands.cxx
src/command/FileCommands.cxx
+1
-2
Path.cxx
src/config/Path.cxx
+1
-1
Configured.cxx
src/db/Configured.cxx
+1
-2
SimpleDatabasePlugin.cxx
src/db/plugins/simple/SimpleDatabasePlugin.cxx
+1
-2
InotifyUpdate.cxx
src/db/update/InotifyUpdate.cxx
+5
-5
CheckFile.cxx
src/fs/CheckFile.cxx
+1
-2
Path.hxx
src/fs/Path.hxx
+9
-1
Path2.cxx
src/fs/Path2.cxx
+7
-1
StandardDirectory.cxx
src/fs/StandardDirectory.cxx
+6
-7
LocalStorage.cxx
src/storage/plugins/LocalStorage.cxx
+2
-3
No files found.
src/CommandLine.cxx
View file @
99d5b616
...
...
@@ -310,7 +310,7 @@ bool ConfigLoader::TryFile(const AllocatedPath &base_path, Path path)
{
if
(
base_path
.
IsNull
())
return
false
;
auto
full_path
=
AllocatedPath
::
Build
(
base_path
,
path
)
;
auto
full_path
=
base_path
/
path
;
return
TryFile
(
full_path
);
}
...
...
src/Main.cxx
View file @
99d5b616
...
...
@@ -260,7 +260,7 @@ glue_state_file_init()
if
(
cache_dir
.
IsNull
())
return
;
path_fs
=
AllocatedPath
::
Build
(
cache_dir
,
"state"
);
path_fs
=
cache_dir
/
Path
::
FromFS
(
"state"
);
#else
return
;
#endif
...
...
@@ -486,7 +486,7 @@ try {
const
auto
sdcard
=
Environment
::
getExternalStorageDirectory
();
if
(
!
sdcard
.
IsNull
())
{
const
auto
config_path
=
AllocatedPath
::
Build
(
sdcard
,
"mpd.conf"
);
sdcard
/
Path
::
FromFS
(
"mpd.conf"
);
if
(
FileExists
(
config_path
))
ReadConfigFile
(
config_path
);
}
...
...
src/Mapper.cxx
View file @
99d5b616
...
...
@@ -82,7 +82,7 @@ map_uri_fs(const char *uri) noexcept
if
(
uri_fs
.
IsNull
())
return
nullptr
;
return
AllocatedPath
::
Build
(
music_dir_fs
,
uri_fs
)
;
return
music_dir_fs
/
uri_fs
;
}
std
::
string
...
...
@@ -128,5 +128,5 @@ map_spl_utf8_to_fs(const char *name) noexcept
if
(
filename_fs
.
IsNull
())
return
nullptr
;
return
AllocatedPath
::
Build
(
playlist_dir_fs
,
filename_fs
)
;
return
playlist_dir_fs
/
filename_fs
;
}
src/PlaylistFile.cxx
View file @
99d5b616
...
...
@@ -138,7 +138,7 @@ LoadPlaylistFileInfo(PlaylistInfo &info,
return
false
;
FileInfo
fi
;
if
(
!
GetFileInfo
(
AllocatedPath
::
Build
(
parent_path_fs
,
name_fs
)
,
fi
)
||
if
(
!
GetFileInfo
(
parent_path_fs
/
name_fs
,
fi
)
||
!
fi
.
IsRegular
())
return
false
;
...
...
src/command/FileCommands.cxx
View file @
99d5b616
...
...
@@ -81,8 +81,7 @@ handle_listfiles_local(Response &r, Path path_fs)
if
(
name_utf8
.
empty
())
continue
;
const
AllocatedPath
full_fs
=
AllocatedPath
::
Build
(
path_fs
,
name_fs
);
const
auto
full_fs
=
path_fs
/
name_fs
;
FileInfo
fi
;
if
(
!
GetFileInfo
(
full_fs
,
fi
,
false
))
continue
;
...
...
src/config/Path.cxx
View file @
99d5b616
...
...
@@ -113,7 +113,7 @@ ParsePath(const char *path)
if
(
path2
.
IsNull
())
return
nullptr
;
return
AllocatedPath
::
Build
(
home
,
path2
)
;
return
home
/
path2
;
}
else
if
(
!
PathTraitsUTF8
::
IsAbsolute
(
path
))
{
throw
FormatRuntimeError
(
"not an absolute path: %s"
,
path
);
}
else
{
...
...
src/db/Configured.cxx
View file @
99d5b616
...
...
@@ -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
;
...
...
src/db/plugins/simple/SimpleDatabasePlugin.cxx
View file @
99d5b616
...
...
@@ -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
();
...
...
src/db/update/InotifyUpdate.cxx
View file @
99d5b616
...
...
@@ -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
());
...
...
src/fs/CheckFile.cxx
View file @
99d5b616
...
...
@@ -43,8 +43,7 @@ try {
#ifndef _WIN32
try
{
const
auto
x
=
AllocatedPath
::
Build
(
path_fs
,
PathTraitsFS
::
CURRENT_DIRECTORY
);
const
auto
x
=
path_fs
/
Path
::
FromFS
(
PathTraitsFS
::
CURRENT_DIRECTORY
);
const
FileInfo
fi2
(
x
);
}
catch
(
const
std
::
system_error
&
e
)
{
if
(
IsAccessDenied
(
e
))
...
...
src/fs/Path.hxx
View file @
99d5b616
/*
* Copyright 2003-201
7
The Music Player Daemon Project
* Copyright 2003-201
8
The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
...
...
@@ -169,4 +169,12 @@ public:
const_pointer_type
GetSuffix
()
const
noexcept
;
};
/**
* Concatenate two path components using the directory separator.
*
* Wrapper for AllocatedPath::Build().
*/
AllocatedPath
operator
/
(
Path
a
,
Path
b
)
noexcept
;
#endif
src/fs/Path2.cxx
View file @
99d5b616
/*
* Copyright 2003-201
7
The Music Player Daemon Project
* Copyright 2003-201
8
The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
...
...
@@ -26,3 +26,9 @@ Path::GetDirectoryName() const noexcept
{
return
AllocatedPath
::
FromFS
(
PathTraitsFS
::
GetParent
(
c_str
()));
}
AllocatedPath
operator
/
(
Path
a
,
Path
b
)
noexcept
{
return
AllocatedPath
::
Build
(
a
,
b
);
}
src/fs/StandardDirectory.cxx
View file @
99d5b616
...
...
@@ -183,16 +183,16 @@ ParseConfigLine(char *line, const char *dir_name, AllocatedPath &result_dir)
*
line_end
=
0
;
// build the result path
const
char
*
path
=
line
;
const
auto
path_fs
=
Path
::
FromFS
(
line
)
;
AllocatedPath
result
=
nullptr
;
if
(
home_relative
)
{
auto
home
=
GetHomeDir
();
if
(
home
.
IsNull
())
return
true
;
result
=
AllocatedPath
::
Build
(
home
,
path
)
;
result
=
home
/
path_fs
;
}
else
{
result
=
AllocatedPath
::
FromFS
(
path
);
result
=
AllocatedPath
(
path_fs
);
}
if
(
IsValidDir
(
result
.
c_str
()))
{
...
...
@@ -209,9 +209,8 @@ try {
auto
config_dir
=
GetUserConfigDir
();
if
(
config_dir
.
IsNull
())
return
result
;
auto
dirs_file
=
AllocatedPath
::
Build
(
config_dir
,
"user-dirs.dirs"
);
TextFile
input
(
dirs_file
);
TextFile
input
(
config_dir
/
Path
::
FromFS
(
"user-dirs.dirs"
)
);
char
*
line
;
while
((
line
=
input
.
ReadLine
())
!=
nullptr
)
if
(
ParseConfigLine
(
line
,
name
,
result
))
...
...
@@ -237,7 +236,7 @@ GetUserConfigDir() noexcept
// Check for $HOME/.config
auto
home
=
GetHomeDir
();
if
(
!
home
.
IsNull
())
{
AllocatedPath
fallback
=
AllocatedPath
::
Build
(
home
,
".config"
);
auto
fallback
=
home
/
Path
::
FromFS
(
".config"
);
if
(
IsValidDir
(
fallback
.
c_str
()))
return
fallback
;
}
...
...
@@ -274,7 +273,7 @@ GetUserCacheDir() noexcept
// Check for $HOME/.cache
auto
home
=
GetHomeDir
();
if
(
!
home
.
IsNull
())
{
AllocatedPath
fallback
=
AllocatedPath
::
Build
(
home
,
".cache"
);
auto
fallback
=
home
/
Path
::
FromFS
(
".cache"
);
if
(
IsValidDir
(
fallback
.
c_str
()))
return
fallback
;
}
...
...
src/storage/plugins/LocalStorage.cxx
View file @
99d5b616
...
...
@@ -114,8 +114,7 @@ LocalStorage::MapFSOrThrow(const char *uri_utf8) const
if
(
StringIsEmpty
(
uri_utf8
))
return
base_fs
;
return
AllocatedPath
::
Build
(
base_fs
,
AllocatedPath
::
FromUTF8Throw
(
uri_utf8
));
return
base_fs
/
AllocatedPath
::
FromUTF8Throw
(
uri_utf8
);
}
AllocatedPath
...
...
@@ -176,7 +175,7 @@ LocalDirectoryReader::Read() noexcept
StorageFileInfo
LocalDirectoryReader
::
GetInfo
(
bool
follow
)
{
return
Stat
(
AllocatedPath
::
Build
(
base_fs
,
reader
.
GetEntry
()
),
follow
);
return
Stat
(
base_fs
/
reader
.
GetEntry
(
),
follow
);
}
std
::
unique_ptr
<
Storage
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment