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
196ec256
Commit
196ec256
authored
Oct 17, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mapper: use std::string
parent
c85af12d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
16 deletions
+11
-16
Mapper.cxx
src/Mapper.cxx
+11
-16
No files found.
src/Mapper.cxx
View file @
196ec256
...
...
@@ -31,8 +31,6 @@
#include "util/Domain.hxx"
#include "Log.hxx"
#include <glib.h>
#include <assert.h>
#include <string.h>
#include <sys/stat.h>
...
...
@@ -45,7 +43,7 @@ static constexpr Domain mapper_domain("mapper");
/**
* The absolute path of the music directory encoded in UTF-8.
*/
static
char
*
music_dir_utf8
;
static
std
::
string
music_dir_utf8
;
static
size_t
music_dir_utf8_length
;
/**
...
...
@@ -99,11 +97,10 @@ mapper_set_music_dir(Path &&path)
music_dir_fs
=
std
::
move
(
path
);
music_dir_fs
.
ChopSeparators
();
const
auto
utf8
=
music_dir_fs
.
ToUTF8
();
music_dir_utf8
=
g_strdup
(
utf8
.
c_str
());
music_dir_utf8_length
=
strlen
(
music_dir_utf8
);
music_dir_utf8
=
music_dir_fs
.
ToUTF8
();
music_dir_utf8_length
=
music_dir_utf8
.
length
();
check_directory
(
music_dir_utf8
,
music_dir_fs
);
check_directory
(
music_dir_utf8
.
c_str
()
,
music_dir_fs
);
}
static
void
...
...
@@ -129,13 +126,12 @@ mapper_init(Path &&_music_dir, Path &&_playlist_dir)
void
mapper_finish
(
void
)
{
g_free
(
music_dir_utf8
);
}
const
char
*
mapper_get_music_directory_utf8
(
void
)
{
return
music_dir_utf8
;
return
music_dir_utf8
.
c_str
()
;
}
const
Path
&
...
...
@@ -147,8 +143,8 @@ mapper_get_music_directory_fs(void)
const
char
*
map_to_relative_path
(
const
char
*
path_utf8
)
{
return
music_dir_utf8
!=
NULL
&&
memcmp
(
path_utf8
,
music_dir_utf8
,
return
!
music_dir_utf8
.
empty
()
&&
memcmp
(
path_utf8
,
music_dir_utf8
.
c_str
()
,
music_dir_utf8_length
)
==
0
&&
Path
::
IsSeparatorUTF8
(
path_utf8
[
music_dir_utf8_length
])
?
path_utf8
+
music_dir_utf8_length
+
1
...
...
@@ -174,7 +170,6 @@ map_uri_fs(const char *uri)
Path
map_directory_fs
(
const
Directory
*
directory
)
{
assert
(
music_dir_utf8
!=
NULL
);
assert
(
!
music_dir_fs
.
IsNull
());
if
(
directory
->
IsRoot
())
...
...
@@ -186,7 +181,6 @@ map_directory_fs(const Directory *directory)
Path
map_directory_child_fs
(
const
Directory
*
directory
,
const
char
*
name
)
{
assert
(
music_dir_utf8
!=
NULL
);
assert
(
!
music_dir_fs
.
IsNull
());
/* check for invalid or unauthorized base names */
...
...
@@ -257,9 +251,10 @@ map_spl_utf8_to_fs(const char *name)
if
(
playlist_dir_fs
.
IsNull
())
return
Path
::
Null
();
char
*
filename_utf8
=
g_strconcat
(
name
,
PLAYLIST_FILE_SUFFIX
,
NULL
);
const
Path
filename_fs
=
Path
::
FromUTF8
(
filename_utf8
);
g_free
(
filename_utf8
);
std
::
string
filename_utf8
=
name
;
filename_utf8
.
append
(
PLAYLIST_FILE_SUFFIX
);
const
Path
filename_fs
=
Path
::
FromUTF8
(
filename_utf8
.
c_str
());
if
(
filename_fs
.
IsNull
())
return
Path
::
Null
();
...
...
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