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
7a58b8c3
Commit
7a58b8c3
authored
Apr 03, 2020
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fs/AllocatedPath: pass std::string_view to FromUTF8()
parent
56b4b010
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
16 additions
and
19 deletions
+16
-19
Mapper.cxx
src/Mapper.cxx
+1
-1
SimpleDatabasePlugin.cxx
src/db/plugins/simple/SimpleDatabasePlugin.cxx
+1
-1
Walk.cxx
src/db/update/Walk.cxx
+1
-1
AllocatedPath.cxx
src/fs/AllocatedPath.cxx
+2
-2
AllocatedPath.hxx
src/fs/AllocatedPath.hxx
+7
-4
Charset.cxx
src/fs/Charset.cxx
+2
-7
Charset.hxx
src/fs/Charset.hxx
+1
-2
NfsStorage.cxx
src/storage/plugins/NfsStorage.cxx
+1
-1
No files found.
src/Mapper.cxx
View file @
7a58b8c3
...
...
@@ -119,7 +119,7 @@ map_spl_utf8_to_fs(const char *name) noexcept
filename_utf8
.
append
(
PLAYLIST_FILE_SUFFIX
);
const
auto
filename_fs
=
AllocatedPath
::
FromUTF8
(
filename_utf8
.
c_str
()
);
AllocatedPath
::
FromUTF8
(
filename_utf8
);
if
(
filename_fs
.
IsNull
())
return
nullptr
;
...
...
src/db/plugins/simple/SimpleDatabasePlugin.cxx
View file @
7a58b8c3
...
...
@@ -436,7 +436,7 @@ SimpleDatabase::Mount(const char *local_uri, const char *storage_uri)
std
::
string
name
(
storage_uri
);
std
::
replace_if
(
name
.
begin
(),
name
.
end
(),
IsUnsafeChar
,
'_'
);
const
auto
name_fs
=
AllocatedPath
::
FromUTF8Throw
(
name
.
c_str
()
);
const
auto
name_fs
=
AllocatedPath
::
FromUTF8Throw
(
name
);
#ifndef ENABLE_ZLIB
constexpr
bool
compress
=
false
;
...
...
src/db/update/Walk.cxx
View file @
7a58b8c3
...
...
@@ -81,7 +81,7 @@ UpdateWalk::RemoveExcludedFromDirectory(Directory &directory,
directory
.
ForEachSongSafe
([
&
](
Song
&
song
){
assert
(
&
song
.
parent
==
&
directory
);
const
auto
name_fs
=
AllocatedPath
::
FromUTF8
(
song
.
filename
.
c_str
()
);
const
auto
name_fs
=
AllocatedPath
::
FromUTF8
(
song
.
filename
);
if
(
name_fs
.
IsNull
()
||
exclude_list
.
Check
(
name_fs
))
{
editor
.
DeleteSong
(
directory
,
&
song
);
modified
=
true
;
...
...
src/fs/AllocatedPath.cxx
View file @
7a58b8c3
...
...
@@ -25,7 +25,7 @@
AllocatedPath
::~
AllocatedPath
()
noexcept
=
default
;
AllocatedPath
AllocatedPath
::
FromUTF8
(
const
char
*
path_utf8
)
noexcept
AllocatedPath
::
FromUTF8
(
std
::
string_view
path_utf8
)
noexcept
{
#ifdef FS_CHARSET_ALWAYS_UTF8
return
FromFS
(
path_utf8
);
...
...
@@ -39,7 +39,7 @@ AllocatedPath::FromUTF8(const char *path_utf8) noexcept
}
AllocatedPath
AllocatedPath
::
FromUTF8Throw
(
const
char
*
path_utf8
)
AllocatedPath
::
FromUTF8Throw
(
std
::
string_view
path_utf8
)
{
#ifdef FS_CHARSET_ALWAYS_UTF8
return
FromFS
(
path_utf8
);
...
...
src/fs/AllocatedPath.hxx
View file @
7a58b8c3
...
...
@@ -173,15 +173,18 @@ public:
* Convert a UTF-8 C string to an #AllocatedPath instance.
* Returns return a "nulled" instance on error.
*/
gcc_pure
gcc_nonnull_all
static
AllocatedPath
FromUTF8
(
const
char
*
path_utf8
)
noexcept
;
gcc_pure
static
AllocatedPath
FromUTF8
(
std
::
string_view
path_utf8
)
noexcept
;
static
AllocatedPath
FromUTF8
(
const
char
*
path_utf8
)
noexcept
{
return
FromUTF8
(
std
::
string_view
(
path_utf8
));
}
/**
* Convert a UTF-8 C string to an #AllocatedPath instance.
* Throws a std::runtime_error on error.
*/
gcc_nonnull_all
static
AllocatedPath
FromUTF8Throw
(
const
char
*
path_utf8
);
static
AllocatedPath
FromUTF8Throw
(
std
::
string_view
path_utf8
);
/**
* Copy an #AllocatedPath object.
...
...
src/fs/Charset.cxx
View file @
7a58b8c3
...
...
@@ -118,19 +118,14 @@ PathToUTF8(PathTraitsFS::const_pointer path_fs)
#if defined(HAVE_FS_CHARSET) || defined(_WIN32)
PathTraitsFS
::
string
PathFromUTF8
(
PathTraitsUTF8
::
const_pointer
path_utf8
)
PathFromUTF8
(
PathTraitsUTF8
::
string_view
path_utf8
)
{
#if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */
assert
(
path_utf8
!=
nullptr
);
#endif
#ifdef _WIN32
const
auto
buffer
=
MultiByteToWideChar
(
CP_UTF8
,
path_utf8
);
return
PathTraitsFS
::
string
(
buffer
);
#else
if
(
fs_converter
==
nullptr
)
return
path_utf8
;
return
PathTraitsFS
::
string
(
path_utf8
)
;
const
auto
buffer
=
fs_converter
->
FromUTF8
(
path_utf8
);
return
PathTraitsFS
::
string
(
buffer
);
...
...
src/fs/Charset.hxx
View file @
7a58b8c3
...
...
@@ -53,8 +53,7 @@ PathToUTF8(PathTraitsFS::const_pointer path_fs);
*
* Throws std::runtime_error on error.
*/
gcc_nonnull_all
PathTraitsFS
::
string
PathFromUTF8
(
PathTraitsUTF8
::
const_pointer
path_utf8
);
PathFromUTF8
(
PathTraitsUTF8
::
string_view
path_utf8
);
#endif
src/storage/plugins/NfsStorage.cxx
View file @
7a58b8c3
...
...
@@ -228,7 +228,7 @@ UriToNfsPath(const char *_uri_utf8)
/* assume UTF-8 when accessing NFS from Windows */
return
uri_utf8
;
#else
return
AllocatedPath
::
FromUTF8Throw
(
uri_utf8
.
c_str
()
).
Steal
();
return
AllocatedPath
::
FromUTF8Throw
(
uri_utf8
).
Steal
();
#endif
}
...
...
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