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
0b27ac2f
Commit
0b27ac2f
authored
Oct 14, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fs/Path: add method RelativeFS()
Move code from map_fs_to_utf8().
parent
6fd481df
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
11 deletions
+36
-11
Mapper.cxx
src/Mapper.cxx
+5
-11
Path.cxx
src/fs/Path.cxx
+22
-0
Path.hxx
src/fs/Path.hxx
+9
-0
No files found.
src/Mapper.cxx
View file @
0b27ac2f
...
...
@@ -251,17 +251,11 @@ map_song_fs(const Song *song)
std
::
string
map_fs_to_utf8
(
const
char
*
path_fs
)
{
if
(
!
music_dir_fs
.
IsNull
()
&&
memcmp
(
path_fs
,
music_dir_fs
.
data
(),
music_dir_fs_length
)
==
0
&&
G_IS_DIR_SEPARATOR
(
path_fs
[
music_dir_fs_length
]))
/* remove musicDir prefix */
path_fs
+=
music_dir_fs_length
+
1
;
else
if
(
G_IS_DIR_SEPARATOR
(
path_fs
[
0
]))
/* not within musicDir */
return
NULL
;
while
(
path_fs
[
0
]
==
G_DIR_SEPARATOR
)
++
path_fs
;
if
(
G_IS_DIR_SEPARATOR
(
path_fs
[
0
]))
{
path_fs
=
music_dir_fs
.
RelativeFS
(
path_fs
);
if
(
path_fs
==
nullptr
||
*
path_fs
==
0
)
return
std
::
string
();
}
return
Path
::
ToUTF8
(
path_fs
);
}
...
...
src/fs/Path.cxx
View file @
0b27ac2f
...
...
@@ -184,3 +184,25 @@ void Path::GlobalInit()
SetFSCharset
(
"ISO-8859-1"
);
}
}
const
char
*
Path
::
RelativeFS
(
const
char
*
other_fs
)
const
{
const
size_t
l
=
length
();
if
(
memcmp
(
data
(),
other_fs
,
l
)
!=
0
)
return
nullptr
;
other_fs
+=
l
;
if
(
*
other_fs
!=
0
)
{
if
(
!
G_IS_DIR_SEPARATOR
(
*
other_fs
))
/* mismatch */
return
nullptr
;
/* skip remaining path separators */
do
{
++
other_fs
;
}
while
(
G_IS_DIR_SEPARATOR
(
*
other_fs
));
}
return
other_fs
;
}
src/fs/Path.hxx
View file @
0b27ac2f
...
...
@@ -223,6 +223,15 @@ public:
*/
gcc_pure
Path
GetDirectoryName
()
const
;
/**
* Determine the relative part of the given path to this
* object, not including the directory separator. Returns an
* empty string if the given path equals this object or
* nullptr on mismatch.
*/
gcc_pure
const
char
*
RelativeFS
(
const
char
*
other_fs
)
const
;
};
#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