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
9067da2d
Commit
9067da2d
authored
Oct 14, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mapper: map_fs_to_utf8() returns std::string
Avoid the conversion to an allocated char*, let the caller decide.
parent
8cf2f52f
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
14 deletions
+11
-14
Mapper.cxx
src/Mapper.cxx
+2
-6
Mapper.hxx
src/Mapper.hxx
+6
-3
PlaylistFile.cxx
src/PlaylistFile.cxx
+3
-5
No files found.
src/Mapper.cxx
View file @
9067da2d
...
...
@@ -248,7 +248,7 @@ map_song_fs(const Song *song)
return
Path
::
FromUTF8
(
song
->
uri
);
}
char
*
std
::
string
map_fs_to_utf8
(
const
char
*
path_fs
)
{
if
(
!
music_dir_fs
.
IsNull
()
&&
...
...
@@ -263,11 +263,7 @@ map_fs_to_utf8(const char *path_fs)
while
(
path_fs
[
0
]
==
G_DIR_SEPARATOR
)
++
path_fs
;
const
std
::
string
path_utf8
=
Path
::
ToUTF8
(
path_fs
);
if
(
path_utf8
.
empty
())
return
nullptr
;
return
g_strdup
(
path_utf8
.
c_str
());
return
Path
::
ToUTF8
(
path_fs
);
}
const
Path
&
...
...
src/Mapper.hxx
View file @
9067da2d
...
...
@@ -24,6 +24,8 @@
#ifndef MPD_MAPPER_HXX
#define MPD_MAPPER_HXX
#include <string>
#include "gcc.h"
#define PLAYLIST_FILE_SUFFIX ".m3u"
...
...
@@ -118,10 +120,11 @@ map_song_fs(const Song *song);
* absolute) to a relative path in UTF-8 encoding.
*
* @param path_fs a path in file system encoding
* @return the relative path in UTF-8, or nullptr if mapping failed
* @return the relative path in UTF-8, or an empty string if mapping
* failed
*/
gcc_
malloc
char
*
gcc_
pure
std
::
string
map_fs_to_utf8
(
const
char
*
path_fs
);
/**
...
...
src/PlaylistFile.cxx
View file @
9067da2d
...
...
@@ -248,13 +248,11 @@ LoadPlaylistFile(const char *utf8path, Error &error)
s
=
g_strconcat
(
"file://"
,
path
.
c_str
(),
NULL
);
}
else
if
(
!
uri_has_scheme
(
s
))
{
char
*
path_utf8
;
path_utf8
=
map_fs_to_utf8
(
s
);
if
(
path_utf8
==
nullptr
)
const
auto
path
=
map_fs_to_utf8
(
s
);
if
(
path
.
empty
())
continue
;
s
=
path_utf8
;
s
=
g_strdup
(
path
.
c_str
())
;
}
else
{
const
auto
path
=
Path
::
ToUTF8
(
s
);
if
(
path
.
empty
())
...
...
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