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
0a6c4c31
Commit
0a6c4c31
authored
Dec 05, 2013
by
Denis Krjuchkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fs/Traits: split PathTraits type into PathTraitsFS and PathTraitsUTF8
parent
02fcf184
Hide whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
95 additions
and
90 deletions
+95
-90
CommandLine.cxx
src/CommandLine.cxx
+1
-1
ConfigPath.cxx
src/ConfigPath.cxx
+1
-1
DecoderThread.cxx
src/DecoderThread.cxx
+1
-1
Directory.cxx
src/Directory.cxx
+1
-1
Mapper.cxx
src/Mapper.cxx
+2
-2
PlaylistFile.cxx
src/PlaylistFile.cxx
+1
-1
PlaylistPrint.cxx
src/PlaylistPrint.cxx
+1
-1
PlaylistQueue.cxx
src/PlaylistQueue.cxx
+1
-1
PlaylistSave.cxx
src/PlaylistSave.cxx
+1
-1
PlaylistSong.cxx
src/PlaylistSong.cxx
+3
-3
QueueSave.cxx
src/QueueSave.cxx
+1
-1
SongUpdate.cxx
src/SongUpdate.cxx
+1
-1
UpdateWalk.cxx
src/UpdateWalk.cxx
+4
-4
Bzip2ArchivePlugin.cxx
src/archive/Bzip2ArchivePlugin.cxx
+1
-1
AllocatedPath.cxx
src/fs/AllocatedPath.cxx
+3
-3
AllocatedPath.hxx
src/fs/AllocatedPath.hxx
+10
-10
FileSystem.hxx
src/fs/FileSystem.hxx
+7
-7
Path.cxx
src/fs/Path.cxx
+2
-2
Path.hxx
src/fs/Path.hxx
+4
-4
Traits.cxx
src/fs/Traits.cxx
+10
-10
Traits.hxx
src/fs/Traits.hxx
+35
-30
ArchiveInputPlugin.cxx
src/input/ArchiveInputPlugin.cxx
+1
-1
FileInputPlugin.cxx
src/input/FileInputPlugin.cxx
+1
-1
EmbeddedCuePlaylistPlugin.cxx
src/playlist/EmbeddedCuePlaylistPlugin.cxx
+2
-2
No files found.
src/CommandLine.cxx
View file @
0a6c4c31
...
...
@@ -188,7 +188,7 @@ static void help(void)
gcc_pure
static
AllocatedPath
PathBuildChecked
(
const
AllocatedPath
&
a
,
PathTraits
::
const_pointer
b
)
PathBuildChecked
(
const
AllocatedPath
&
a
,
PathTraits
FS
::
const_pointer
b
)
{
if
(
a
.
IsNull
())
return
AllocatedPath
::
Null
();
...
...
src/ConfigPath.cxx
View file @
0a6c4c31
...
...
@@ -119,7 +119,7 @@ ParsePath(const char *path, Error &error)
return
AllocatedPath
::
Null
();
return
AllocatedPath
::
Build
(
home
,
path2
);
}
else
if
(
!
PathTraits
::
IsAbsoluteUTF8
(
path
))
{
}
else
if
(
!
PathTraits
UTF8
::
IsAbsolute
(
path
))
{
error
.
Format
(
path_domain
,
"not an absolute path: %s"
,
path
);
return
AllocatedPath
::
Null
();
...
...
src/DecoderThread.cxx
View file @
0a6c4c31
...
...
@@ -145,7 +145,7 @@ decoder_file_decode(const DecoderPlugin &plugin,
assert
(
decoder
.
stream_tag
==
nullptr
);
assert
(
decoder
.
decoder_tag
==
nullptr
);
assert
(
path
!=
nullptr
);
assert
(
PathTraits
::
IsAbsoluteFS
(
path
));
assert
(
PathTraits
FS
::
IsAbsolute
(
path
));
assert
(
decoder
.
dc
.
state
==
DecoderState
::
START
);
FormatDebug
(
decoder_thread_domain
,
"probing plugin %s"
,
plugin
.
name
);
...
...
src/Directory.cxx
View file @
0a6c4c31
...
...
@@ -114,7 +114,7 @@ Directory::GetName() const
{
assert
(
!
IsRoot
());
return
PathTraits
::
GetBaseUTF8
(
path
);
return
PathTraits
UTF8
::
GetBase
(
path
);
}
Directory
*
...
...
src/Mapper.cxx
View file @
0a6c4c31
...
...
@@ -148,7 +148,7 @@ map_to_relative_path(const char *path_utf8)
return
!
music_dir_utf8
.
empty
()
&&
memcmp
(
path_utf8
,
music_dir_utf8
.
c_str
(),
music_dir_utf8_length
)
==
0
&&
PathTraits
::
IsSeparatorUTF8
(
path_utf8
[
music_dir_utf8_length
])
PathTraits
UTF8
::
IsSeparator
(
path_utf8
[
music_dir_utf8_length
])
?
path_utf8
+
music_dir_utf8_length
+
1
:
path_utf8
;
}
...
...
@@ -232,7 +232,7 @@ map_song_fs(const Song &song)
std
::
string
map_fs_to_utf8
(
const
char
*
path_fs
)
{
if
(
PathTraits
::
IsSeparatorFS
(
path_fs
[
0
]))
{
if
(
PathTraits
FS
::
IsSeparator
(
path_fs
[
0
]))
{
path_fs
=
music_dir_fs
.
RelativeFS
(
path_fs
);
if
(
path_fs
==
nullptr
||
*
path_fs
==
0
)
return
std
::
string
();
...
...
src/PlaylistFile.cxx
View file @
0a6c4c31
...
...
@@ -246,7 +246,7 @@ LoadPlaylistFile(const char *utf8path, Error &error)
if
(
!
uri_has_scheme
(
s
))
{
uri_utf8
=
map_fs_to_utf8
(
s
);
if
(
uri_utf8
.
empty
())
{
if
(
PathTraits
::
IsAbsoluteFS
(
s
))
{
if
(
PathTraits
FS
::
IsAbsolute
(
s
))
{
uri_utf8
=
PathToUTF8
(
s
);
if
(
uri_utf8
.
empty
())
continue
;
...
...
src/PlaylistPrint.cxx
View file @
0a6c4c31
...
...
@@ -148,7 +148,7 @@ playlist_provider_print(Client &client, const char *uri,
SongEnumerator
&
e
,
bool
detail
)
{
const
std
::
string
base_uri
=
uri
!=
nullptr
?
PathTraits
::
GetParentUTF8
(
uri
)
?
PathTraits
UTF8
::
GetParent
(
uri
)
:
std
::
string
(
"."
);
Song
*
song
;
...
...
src/PlaylistQueue.cxx
View file @
0a6c4c31
...
...
@@ -35,7 +35,7 @@ playlist_load_into_queue(const char *uri, SongEnumerator &e,
bool
secure
)
{
const
std
::
string
base_uri
=
uri
!=
nullptr
?
PathTraits
::
GetParentUTF8
(
uri
)
?
PathTraits
UTF8
::
GetParent
(
uri
)
:
std
::
string
(
"."
);
Song
*
song
;
...
...
src/PlaylistSave.cxx
View file @
0a6c4c31
...
...
@@ -56,7 +56,7 @@ void
playlist_print_uri
(
FILE
*
file
,
const
char
*
uri
)
{
auto
path
=
playlist_saveAbsolutePaths
&&
!
uri_has_scheme
(
uri
)
&&
!
PathTraits
::
IsAbsoluteUTF8
(
uri
)
!
PathTraits
UTF8
::
IsAbsolute
(
uri
)
?
map_uri_fs
(
uri
)
:
AllocatedPath
::
FromUTF8
(
uri
);
...
...
src/PlaylistSong.cxx
View file @
0a6c4c31
...
...
@@ -99,7 +99,7 @@ playlist_check_load_song(const Song *song, const char *uri, bool secure)
if
(
uri_has_scheme
(
uri
))
{
dest
=
Song
::
NewRemote
(
uri
);
}
else
if
(
PathTraits
::
IsAbsoluteUTF8
(
uri
)
&&
secure
)
{
}
else
if
(
PathTraits
UTF8
::
IsAbsolute
(
uri
)
&&
secure
)
{
dest
=
Song
::
LoadFile
(
uri
,
nullptr
);
if
(
dest
==
nullptr
)
return
nullptr
;
...
...
@@ -142,13 +142,13 @@ playlist_check_translate_song(Song *song, const char *base_uri,
}
if
(
base_uri
!=
nullptr
&&
strcmp
(
base_uri
,
"."
)
==
0
)
/* PathTraits
::GetParentUTF8
() returns "." when there
/* PathTraits
UTF8::GetParent
() returns "." when there
is no directory name in the given path; clear that
now, because it would break the database lookup
functions */
base_uri
=
nullptr
;
if
(
PathTraits
::
IsAbsoluteUTF8
(
uri
))
{
if
(
PathTraits
UTF8
::
IsAbsolute
(
uri
))
{
/* XXX fs_charset vs utf8? */
const
char
*
suffix
=
map_to_relative_path
(
uri
);
assert
(
suffix
!=
nullptr
);
...
...
src/QueueSave.cxx
View file @
0a6c4c31
...
...
@@ -90,7 +90,7 @@ queue_load_song(TextFile &file, const char *line, queue &queue)
if
(
StringStartsWith
(
line
,
SONG_BEGIN
))
{
const
char
*
uri
=
line
+
sizeof
(
SONG_BEGIN
)
-
1
;
if
(
!
uri_has_scheme
(
uri
)
&&
!
PathTraits
::
IsAbsoluteUTF8
(
uri
))
if
(
!
uri_has_scheme
(
uri
)
&&
!
PathTraits
UTF8
::
IsAbsolute
(
uri
))
return
;
Error
error
;
...
...
src/SongUpdate.cxx
View file @
0a6c4c31
...
...
@@ -43,7 +43,7 @@ Song::LoadFile(const char *path_utf8, Directory *parent)
Song
*
song
;
bool
ret
;
assert
((
parent
==
nullptr
)
==
PathTraits
::
IsAbsoluteUTF8
(
path_utf8
));
assert
((
parent
==
nullptr
)
==
PathTraits
UTF8
::
IsAbsolute
(
path_utf8
));
assert
(
!
uri_has_scheme
(
path_utf8
));
assert
(
strchr
(
path_utf8
,
'\n'
)
==
nullptr
);
...
...
src/UpdateWalk.cxx
View file @
0a6c4c31
...
...
@@ -290,7 +290,7 @@ skip_symlink(const Directory *directory, const char *utf8_name)
const
char
*
target_str
=
target
.
c_str
();
if
(
PathTraits
::
IsAbsoluteFS
(
target_str
))
{
if
(
PathTraits
FS
::
IsAbsolute
(
target_str
))
{
/* if the symlink points to an absolute path, see if
that path is inside the music directory */
const
char
*
relative
=
map_to_relative_path
(
target_str
);
...
...
@@ -301,7 +301,7 @@ skip_symlink(const Directory *directory, const char *utf8_name)
const
char
*
p
=
target_str
;
while
(
*
p
==
'.'
)
{
if
(
p
[
1
]
==
'.'
&&
PathTraits
::
IsSeparatorFS
(
p
[
2
]))
{
if
(
p
[
1
]
==
'.'
&&
PathTraits
FS
::
IsSeparator
(
p
[
2
]))
{
/* "../" moves to parent directory */
directory
=
directory
->
parent
;
if
(
directory
==
nullptr
)
{
...
...
@@ -311,7 +311,7 @@ skip_symlink(const Directory *directory, const char *utf8_name)
return
!
follow_outside_symlinks
;
}
p
+=
3
;
}
else
if
(
PathTraits
::
IsSeparatorFS
(
p
[
1
]))
}
else
if
(
PathTraits
FS
::
IsSeparator
(
p
[
1
]))
/* eliminate "./" */
p
+=
2
;
else
...
...
@@ -454,7 +454,7 @@ update_uri(const char *uri)
if
(
parent
==
nullptr
)
return
;
const
char
*
name
=
PathTraits
::
GetBaseUTF8
(
uri
);
const
char
*
name
=
PathTraits
UTF8
::
GetBase
(
uri
);
struct
stat
st
;
if
(
!
skip_symlink
(
parent
,
name
)
&&
...
...
src/archive/Bzip2ArchivePlugin.cxx
View file @
0a6c4c31
...
...
@@ -51,7 +51,7 @@ public:
Bzip2ArchiveFile
(
const
char
*
path
,
InputStream
*
_is
)
:
ArchiveFile
(
bz2_archive_plugin
),
name
(
PathTraits
::
GetBaseUTF8
(
path
)),
name
(
PathTraits
UTF8
::
GetBase
(
path
)),
istream
(
_is
)
{
// remove .bz2 suffix
const
size_t
len
=
name
.
length
();
...
...
src/fs/AllocatedPath.cxx
View file @
0a6c4c31
...
...
@@ -75,14 +75,14 @@ AllocatedPath::RelativeFS(const char *other_fs) const
other_fs
+=
l
;
if
(
*
other_fs
!=
0
)
{
if
(
!
PathTraits
::
IsSeparatorFS
(
*
other_fs
))
if
(
!
PathTraits
FS
::
IsSeparator
(
*
other_fs
))
/* mismatch */
return
nullptr
;
/* skip remaining path separators */
do
{
++
other_fs
;
}
while
(
PathTraits
::
IsSeparatorFS
(
*
other_fs
));
}
while
(
PathTraits
FS
::
IsSeparator
(
*
other_fs
));
}
return
other_fs
;
...
...
@@ -94,7 +94,7 @@ AllocatedPath::ChopSeparators()
size_t
l
=
length
();
const
char
*
p
=
data
();
while
(
l
>=
2
&&
PathTraits
::
IsSeparatorFS
(
p
[
l
-
1
]))
{
while
(
l
>=
2
&&
PathTraits
FS
::
IsSeparator
(
p
[
l
-
1
]))
{
--
l
;
#if GCC_CHECK_VERSION(4,7) && !defined(__clang__)
...
...
src/fs/AllocatedPath.hxx
View file @
0a6c4c31
...
...
@@ -37,10 +37,10 @@ class Error;
* stored.
*/
class
AllocatedPath
{
typedef
PathTraits
::
string
string
;
typedef
PathTraits
::
value_type
value_type
;
typedef
PathTraits
::
pointer
pointer
;
typedef
PathTraits
::
const_pointer
const_pointer
;
typedef
PathTraits
FS
::
string
string
;
typedef
PathTraits
FS
::
value_type
value_type
;
typedef
PathTraits
FS
::
pointer
pointer
;
typedef
PathTraits
FS
::
const_pointer
const_pointer
;
string
value
;
...
...
@@ -57,7 +57,7 @@ class AllocatedPath {
static
AllocatedPath
Build
(
const_pointer
a
,
size_t
a_size
,
const_pointer
b
,
size_t
b_size
)
{
return
AllocatedPath
(
PathTraits
::
BuildFS
(
a
,
a_size
,
b
,
b_size
));
return
AllocatedPath
(
PathTraits
FS
::
Build
(
a
,
a_size
,
b
,
b_size
));
}
public
:
/**
...
...
@@ -93,20 +93,20 @@ public:
*/
gcc_pure
gcc_nonnull_all
static
AllocatedPath
Build
(
const_pointer
a
,
const_pointer
b
)
{
return
Build
(
a
,
PathTraits
::
GetLengthFS
(
a
),
b
,
PathTraits
::
GetLengthFS
(
b
));
return
Build
(
a
,
PathTraits
FS
::
GetLength
(
a
),
b
,
PathTraits
FS
::
GetLength
(
b
));
}
gcc_pure
gcc_nonnull_all
static
AllocatedPath
Build
(
const_pointer
a
,
const
AllocatedPath
&
b
)
{
return
Build
(
a
,
PathTraits
::
GetLengthFS
(
a
),
return
Build
(
a
,
PathTraits
FS
::
GetLength
(
a
),
b
.
value
.
c_str
(),
b
.
value
.
size
());
}
gcc_pure
gcc_nonnull_all
static
AllocatedPath
Build
(
const
AllocatedPath
&
a
,
const_pointer
b
)
{
return
Build
(
a
.
value
.
c_str
(),
a
.
value
.
size
(),
b
,
PathTraits
::
GetLengthFS
(
b
));
b
,
PathTraits
FS
::
GetLength
(
b
));
}
gcc_pure
...
...
@@ -233,7 +233,7 @@ public:
gcc_pure
bool
IsAbsolute
()
{
return
PathTraits
::
IsAbsoluteFS
(
c_str
());
return
PathTraits
FS
::
IsAbsolute
(
c_str
());
}
};
...
...
src/fs/FileSystem.hxx
View file @
0a6c4c31
...
...
@@ -36,39 +36,39 @@ namespace FOpenMode {
/**
* Open mode for reading text files.
*/
constexpr
PathTraits
::
const_pointer
ReadText
=
"r"
;
constexpr
PathTraits
FS
::
const_pointer
ReadText
=
"r"
;
/**
* Open mode for reading binary files.
*/
constexpr
PathTraits
::
const_pointer
ReadBinary
=
"rb"
;
constexpr
PathTraits
FS
::
const_pointer
ReadBinary
=
"rb"
;
/**
* Open mode for writing text files.
*/
constexpr
PathTraits
::
const_pointer
WriteText
=
"w"
;
constexpr
PathTraits
FS
::
const_pointer
WriteText
=
"w"
;
/**
* Open mode for writing binary files.
*/
constexpr
PathTraits
::
const_pointer
WriteBinary
=
"wb"
;
constexpr
PathTraits
FS
::
const_pointer
WriteBinary
=
"wb"
;
/**
* Open mode for appending text files.
*/
constexpr
PathTraits
::
const_pointer
AppendText
=
"a"
;
constexpr
PathTraits
FS
::
const_pointer
AppendText
=
"a"
;
/**
* Open mode for appending binary files.
*/
constexpr
PathTraits
::
const_pointer
AppendBinary
=
"ab"
;
constexpr
PathTraits
FS
::
const_pointer
AppendBinary
=
"ab"
;
}
/**
* Wrapper for fopen() that uses #Path names.
*/
static
inline
FILE
*
FOpen
(
Path
file
,
PathTraits
::
const_pointer
mode
)
FOpen
(
Path
file
,
PathTraits
FS
::
const_pointer
mode
)
{
return
fopen
(
file
.
c_str
(),
mode
);
}
...
...
src/fs/Path.cxx
View file @
0a6c4c31
...
...
@@ -36,14 +36,14 @@ Path::RelativeFS(const char *other_fs) const
other_fs
+=
l
;
if
(
*
other_fs
!=
0
)
{
if
(
!
PathTraits
::
IsSeparatorFS
(
*
other_fs
))
if
(
!
PathTraits
FS
::
IsSeparator
(
*
other_fs
))
/* mismatch */
return
nullptr
;
/* skip remaining path separators */
do
{
++
other_fs
;
}
while
(
PathTraits
::
IsSeparatorFS
(
*
other_fs
));
}
while
(
PathTraits
FS
::
IsSeparator
(
*
other_fs
));
}
return
other_fs
;
...
...
src/fs/Path.hxx
View file @
0a6c4c31
...
...
@@ -36,9 +36,9 @@
* instance lives, the string must not be invalidated.
*/
class
Path
{
typedef
PathTraits
::
value_type
value_type
;
typedef
PathTraits
::
pointer
pointer
;
typedef
PathTraits
::
const_pointer
const_pointer
;
typedef
PathTraits
FS
::
value_type
value_type
;
typedef
PathTraits
FS
::
pointer
pointer
;
typedef
PathTraits
FS
::
const_pointer
const_pointer
;
const
char
*
value
;
...
...
@@ -139,7 +139,7 @@ public:
gcc_pure
bool
IsAbsolute
()
{
return
PathTraits
::
IsAbsoluteFS
(
c_str
());
return
PathTraits
FS
::
IsAbsolute
(
c_str
());
}
};
...
...
src/fs/Traits.cxx
View file @
0a6c4c31
...
...
@@ -22,9 +22,9 @@
#include <string.h>
PathTraits
::
string
PathTraits
::
BuildFS
(
PathTraits
::
const_pointer
a
,
size_t
a_size
,
PathTraits
::
const_pointer
b
,
size_t
b_size
)
PathTraits
FS
::
string
PathTraits
FS
::
Build
(
PathTraitsFS
::
const_pointer
a
,
size_t
a_size
,
PathTraits
FS
::
const_pointer
b
,
size_t
b_size
)
{
assert
(
a
!=
nullptr
);
assert
(
b
!=
nullptr
);
...
...
@@ -36,10 +36,10 @@ PathTraits::BuildFS(PathTraits::const_pointer a, size_t a_size,
string
result
(
a
,
a_size
);
if
(
!
IsSeparator
FS
(
a
[
a_size
-
1
]))
result
.
push_back
(
SEPARATOR
_FS
);
if
(
!
IsSeparator
(
a
[
a_size
-
1
]))
result
.
push_back
(
SEPARATOR
);
if
(
IsSeparator
FS
(
b
[
0
]))
if
(
IsSeparator
(
b
[
0
]))
result
.
append
(
b
+
1
,
b_size
-
1
);
else
result
.
append
(
b
,
b_size
);
...
...
@@ -48,22 +48,22 @@ PathTraits::BuildFS(PathTraits::const_pointer a, size_t a_size,
}
const
char
*
PathTraits
::
GetBaseUTF8
(
const
char
*
p
)
PathTraits
UTF8
::
GetBase
(
const
char
*
p
)
{
assert
(
p
!=
nullptr
);
const
char
*
slash
=
strrchr
(
p
,
SEPARATOR
_UTF8
);
const
char
*
slash
=
strrchr
(
p
,
SEPARATOR
);
return
slash
!=
nullptr
?
slash
+
1
:
p
;
}
std
::
string
PathTraits
::
GetParentUTF8
(
const
char
*
p
)
PathTraits
UTF8
::
GetParent
(
const
char
*
p
)
{
assert
(
p
!=
nullptr
);
const
char
*
slash
=
strrchr
(
p
,
SEPARATOR
_UTF8
);
const
char
*
slash
=
strrchr
(
p
,
SEPARATOR
);
return
slash
!=
nullptr
?
std
::
string
(
p
,
slash
)
:
std
::
string
(
"."
);
...
...
src/fs/Traits.hxx
View file @
0a6c4c31
...
...
@@ -33,56 +33,40 @@
#include <assert.h>
/**
* This class describes the nature of a filesystem path.
* This class describes the nature of a
native
filesystem path.
*/
struct
PathTraits
{
struct
PathTraits
FS
{
typedef
std
::
string
string
;
typedef
char
value_type
;
typedef
char
*
pointer
;
typedef
const
char
*
const_pointer
;
#ifdef WIN32
static
constexpr
value_type
SEPARATOR
_FS
=
'\\'
;
static
constexpr
value_type
SEPARATOR
=
'\\'
;
#else
static
constexpr
value_type
SEPARATOR
_FS
=
'/'
;
static
constexpr
value_type
SEPARATOR
=
'/'
;
#endif
static
constexpr
char
SEPARATOR_UTF8
=
'/'
;
static
constexpr
bool
IsSeparatorFS
(
value_type
ch
)
{
static
constexpr
bool
IsSeparator
(
value_type
ch
)
{
return
#ifdef WIN32
ch
==
'/'
||
#endif
ch
==
SEPARATOR_FS
;
}
static
constexpr
bool
IsSeparatorUTF8
(
char
ch
)
{
return
ch
==
SEPARATOR_UTF8
;
}
gcc_pure
static
bool
IsAbsoluteFS
(
const_pointer
p
)
{
assert
(
p
!=
nullptr
);
#ifdef WIN32
if
(
IsAlphaASCII
(
p
[
0
])
&&
p
[
1
]
==
':'
&&
IsSeparatorFS
(
p
[
2
]))
return
true
;
#endif
return
IsSeparatorFS
(
*
p
);
ch
==
SEPARATOR
;
}
gcc_pure
static
bool
IsAbsolute
UTF8
(
const
char
*
p
)
{
static
bool
IsAbsolute
(
const_pointer
p
)
{
assert
(
p
!=
nullptr
);
#ifdef WIN32
if
(
IsAlphaASCII
(
p
[
0
])
&&
p
[
1
]
==
':'
&&
IsSeparator
UTF8
(
p
[
2
]))
if
(
IsAlphaASCII
(
p
[
0
])
&&
p
[
1
]
==
':'
&&
IsSeparator
(
p
[
2
]))
return
true
;
#endif
return
IsSeparator
UTF8
(
*
p
);
return
IsSeparator
(
*
p
);
}
gcc_pure
static
size_t
GetLength
FS
(
const_pointer
p
)
{
static
size_t
GetLength
(
const_pointer
p
)
{
return
strlen
(
p
);
}
...
...
@@ -93,15 +77,36 @@ struct PathTraits {
* If both components are empty strings, empty string is returned.
*/
gcc_pure
gcc_nonnull_all
static
string
BuildFS
(
const_pointer
a
,
size_t
a_size
,
const_pointer
b
,
size_t
b_size
);
static
string
Build
(
const_pointer
a
,
size_t
a_size
,
const_pointer
b
,
size_t
b_size
);
};
/**
* This class describes the nature of a MPD internal filesystem path.
*/
struct
PathTraitsUTF8
{
static
constexpr
char
SEPARATOR
=
'/'
;
static
constexpr
bool
IsSeparator
(
char
ch
)
{
return
ch
==
SEPARATOR
;
}
gcc_pure
static
bool
IsAbsolute
(
const
char
*
p
)
{
assert
(
p
!=
nullptr
);
#ifdef WIN32
if
(
IsAlphaASCII
(
p
[
0
])
&&
p
[
1
]
==
':'
&&
IsSeparator
(
p
[
2
]))
return
true
;
#endif
return
IsSeparator
(
*
p
);
}
/**
* Determine the "base" file name of the given UTF-8 path.
* The return value points inside the given string.
*/
gcc_pure
gcc_nonnull_all
static
const
char
*
GetBase
UTF8
(
const
char
*
p
);
static
const
char
*
GetBase
(
const
char
*
p
);
/**
* Determine the "parent" file name of the given UTF-8 path.
...
...
@@ -109,7 +114,7 @@ struct PathTraits {
* separator in the given input string.
*/
gcc_pure
gcc_nonnull_all
static
std
::
string
GetParent
UTF8
(
const
char
*
p
);
static
std
::
string
GetParent
(
const
char
*
p
);
};
#endif
src/input/ArchiveInputPlugin.cxx
View file @
0a6c4c31
...
...
@@ -46,7 +46,7 @@ input_archive_open(const char *pathname,
const
struct
archive_plugin
*
arplug
;
InputStream
*
is
;
if
(
!
PathTraits
::
IsAbsoluteFS
(
pathname
))
if
(
!
PathTraits
FS
::
IsAbsolute
(
pathname
))
return
nullptr
;
char
*
pname
=
g_strdup
(
pathname
);
...
...
src/input/FileInputPlugin.cxx
View file @
0a6c4c31
...
...
@@ -60,7 +60,7 @@ input_file_open(const char *filename,
int
fd
,
ret
;
struct
stat
st
;
if
(
!
PathTraits
::
IsAbsoluteFS
(
filename
))
if
(
!
PathTraits
FS
::
IsAbsolute
(
filename
))
return
nullptr
;
fd
=
open_cloexec
(
filename
,
O_RDONLY
|
O_BINARY
,
0
);
...
...
src/playlist/EmbeddedCuePlaylistPlugin.cxx
View file @
0a6c4c31
...
...
@@ -93,7 +93,7 @@ embcue_playlist_open_uri(const char *uri,
gcc_unused
Mutex
&
mutex
,
gcc_unused
Cond
&
cond
)
{
if
(
!
PathTraits
::
IsAbsoluteUTF8
(
uri
))
if
(
!
PathTraits
UTF8
::
IsAbsolute
(
uri
))
/* only local files supported */
return
nullptr
;
...
...
@@ -116,7 +116,7 @@ embcue_playlist_open_uri(const char *uri,
return
nullptr
;
}
playlist
->
filename
=
PathTraits
::
GetBaseUTF8
(
uri
);
playlist
->
filename
=
PathTraits
UTF8
::
GetBase
(
uri
);
playlist
->
next
=
&
playlist
->
cuesheet
[
0
];
playlist
->
parser
=
new
CueParser
();
...
...
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