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
9508ea98
Commit
9508ea98
authored
Oct 14, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fs/Path: add method IsAbsolute()
parent
47d655ea
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
47 additions
and
12 deletions
+47
-12
ConfigPath.cxx
src/ConfigPath.cxx
+1
-1
DecoderThread.cxx
src/DecoderThread.cxx
+1
-1
PlaylistFile.cxx
src/PlaylistFile.cxx
+1
-1
PlaylistSave.cxx
src/PlaylistSave.cxx
+1
-1
PlaylistSong.cxx
src/PlaylistSong.cxx
+2
-2
QueueSave.cxx
src/QueueSave.cxx
+2
-1
SongUpdate.cxx
src/SongUpdate.cxx
+1
-1
UpdateWalk.cxx
src/UpdateWalk.cxx
+1
-1
Path.hxx
src/fs/Path.hxx
+31
-0
ArchiveInputPlugin.cxx
src/input/ArchiveInputPlugin.cxx
+2
-1
FileInputPlugin.cxx
src/input/FileInputPlugin.cxx
+2
-1
EmbeddedCuePlaylistPlugin.cxx
src/playlist/EmbeddedCuePlaylistPlugin.cxx
+2
-1
No files found.
src/ConfigPath.cxx
View file @
9508ea98
...
...
@@ -118,7 +118,7 @@ ParsePath(const char *path, Error &error)
return
Path
::
Null
();
return
Path
::
Build
(
home
,
path2
);
}
else
if
(
!
g_path_is_absolute
(
path
))
{
}
else
if
(
!
Path
::
IsAbsoluteUTF8
(
path
))
{
error
.
Format
(
path_domain
,
"not an absolute path: %s"
,
path
);
return
Path
::
Null
();
...
...
src/DecoderThread.cxx
View file @
9508ea98
...
...
@@ -153,7 +153,7 @@ decoder_file_decode(const struct decoder_plugin *plugin,
assert
(
decoder
->
stream_tag
==
NULL
);
assert
(
decoder
->
decoder_tag
==
NULL
);
assert
(
path
!=
NULL
);
assert
(
g_path_is_absolute
(
path
));
assert
(
Path
::
IsAbsoluteFS
(
path
));
assert
(
decoder
->
dc
->
state
==
DecoderState
::
START
);
FormatDebug
(
decoder_thread_domain
,
"probing plugin %s"
,
plugin
->
name
);
...
...
src/PlaylistFile.cxx
View file @
9508ea98
...
...
@@ -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
(
g_path_is_absolute
(
s
))
{
if
(
Path
::
IsAbsoluteFS
(
s
))
{
uri_utf8
=
Path
::
ToUTF8
(
s
);
if
(
uri_utf8
.
empty
())
continue
;
...
...
src/PlaylistSave.cxx
View file @
9508ea98
...
...
@@ -56,7 +56,7 @@ void
playlist_print_uri
(
FILE
*
file
,
const
char
*
uri
)
{
Path
path
=
playlist_saveAbsolutePaths
&&
!
uri_has_scheme
(
uri
)
&&
!
g_path_is_absolute
(
uri
)
!
Path
::
IsAbsoluteUTF8
(
uri
)
?
map_uri_fs
(
uri
)
:
Path
::
FromUTF8
(
uri
);
...
...
src/PlaylistSong.cxx
View file @
9508ea98
...
...
@@ -98,7 +98,7 @@ playlist_check_load_song(const Song *song, const char *uri, bool secure)
if
(
uri_has_scheme
(
uri
))
{
dest
=
Song
::
NewRemote
(
uri
);
}
else
if
(
g_path_is_absolute
(
uri
)
&&
secure
)
{
}
else
if
(
Path
::
IsAbsoluteUTF8
(
uri
)
&&
secure
)
{
dest
=
Song
::
LoadFile
(
uri
,
nullptr
);
if
(
dest
==
nullptr
)
return
nullptr
;
...
...
@@ -147,7 +147,7 @@ playlist_check_translate_song(Song *song, const char *base_uri,
functions */
base_uri
=
nullptr
;
if
(
g_path_is_absolute
(
uri
))
{
if
(
Path
::
IsAbsoluteUTF8
(
uri
))
{
/* XXX fs_charset vs utf8? */
const
char
*
suffix
=
map_to_relative_path
(
uri
);
assert
(
suffix
!=
nullptr
);
...
...
src/QueueSave.cxx
View file @
9508ea98
...
...
@@ -28,6 +28,7 @@
#include "TextFile.hxx"
#include "util/UriUtil.hxx"
#include "util/Error.hxx"
#include "fs/Path.hxx"
#include "Log.hxx"
#include <glib.h>
...
...
@@ -92,7 +93,7 @@ queue_load_song(TextFile &file, const char *line, queue *queue)
if
(
g_str_has_prefix
(
line
,
SONG_BEGIN
))
{
const
char
*
uri
=
line
+
sizeof
(
SONG_BEGIN
)
-
1
;
if
(
!
uri_has_scheme
(
uri
)
&&
!
g_path_is_absolute
(
uri
))
if
(
!
uri_has_scheme
(
uri
)
&&
!
Path
::
IsAbsoluteUTF8
(
uri
))
return
;
Error
error
;
...
...
src/SongUpdate.cxx
View file @
9508ea98
...
...
@@ -47,7 +47,7 @@ Song::LoadFile(const char *path_utf8, Directory *parent)
Song
*
song
;
bool
ret
;
assert
((
parent
==
NULL
)
==
g_path_is_absolute
(
path_utf8
));
assert
((
parent
==
NULL
)
==
Path
::
IsAbsoluteUTF8
(
path_utf8
));
assert
(
!
uri_has_scheme
(
path_utf8
));
assert
(
strchr
(
path_utf8
,
'\n'
)
==
NULL
);
...
...
src/UpdateWalk.cxx
View file @
9508ea98
...
...
@@ -295,7 +295,7 @@ skip_symlink(const Directory *directory, const char *utf8_name)
const
char
*
target_str
=
target
.
c_str
();
if
(
g_path_is_absolute
(
target_str
))
{
if
(
Path
::
IsAbsoluteFS
(
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
);
...
...
src/fs/Path.hxx
View file @
9508ea98
...
...
@@ -23,6 +23,10 @@
#include "check.h"
#include "gcc.h"
#ifdef WIN32
#include <glib.h>
#endif
#include <algorithm>
#include <string>
...
...
@@ -261,6 +265,33 @@ public:
#endif
ch
==
SEPARATOR_UTF8
;
}
gcc_pure
static
bool
IsAbsoluteFS
(
const_pointer
p
)
{
assert
(
p
!=
nullptr
);
#ifdef WIN32
return
g_path_is_absolute
(
p
);
#else
return
IsSeparatorFS
(
*
p
);
#endif
}
gcc_pure
static
bool
IsAbsoluteUTF8
(
const
char
*
p
)
{
assert
(
p
!=
nullptr
);
#ifdef WIN32
return
g_path_is_absolute
(
p
);
#else
return
IsSeparatorUTF8
(
*
p
);
#endif
}
gcc_pure
bool
IsAbsolute
()
{
return
IsAbsoluteFS
(
c_str
());
}
};
#endif
src/input/ArchiveInputPlugin.cxx
View file @
9508ea98
...
...
@@ -26,6 +26,7 @@
#include "InputPlugin.hxx"
#include "util/Error.hxx"
#include "util/Domain.hxx"
#include "fs/Path.hxx"
#include "Log.hxx"
#include <glib.h>
...
...
@@ -49,7 +50,7 @@ input_archive_open(const char *pathname,
char
*
archive
,
*
filename
,
*
suffix
,
*
pname
;
struct
input_stream
*
is
;
if
(
!
g_path_is_absolute
(
pathname
))
if
(
!
Path
::
IsAbsoluteFS
(
pathname
))
return
NULL
;
pname
=
g_strdup
(
pathname
);
...
...
src/input/FileInputPlugin.cxx
View file @
9508ea98
...
...
@@ -24,6 +24,7 @@
#include "InputPlugin.hxx"
#include "util/Error.hxx"
#include "util/Domain.hxx"
#include "fs/Path.hxx"
#include "system/fd_util.h"
#include "open.h"
...
...
@@ -62,7 +63,7 @@ input_file_open(const char *filename,
int
fd
,
ret
;
struct
stat
st
;
if
(
!
g_path_is_absolute
(
filename
))
if
(
!
Path
::
IsAbsoluteFS
(
filename
))
return
nullptr
;
fd
=
open_cloexec
(
filename
,
O_RDONLY
|
O_BINARY
,
0
);
...
...
src/playlist/EmbeddedCuePlaylistPlugin.cxx
View file @
9508ea98
...
...
@@ -34,6 +34,7 @@
#include "Song.hxx"
#include "TagFile.hxx"
#include "cue/CueParser.hxx"
#include "fs/Path.hxx"
#include <glib.h>
#include <assert.h>
...
...
@@ -95,7 +96,7 @@ embcue_playlist_open_uri(const char *uri,
gcc_unused
Mutex
&
mutex
,
gcc_unused
Cond
&
cond
)
{
if
(
!
g_path_is_absolute
(
uri
))
if
(
!
Path
::
IsAbsoluteUTF8
(
uri
))
/* only local files supported */
return
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