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
1ee6a78c
Commit
1ee6a78c
authored
Sep 12, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Path: add FromUTF8() overload that returns an Error
parent
bf4ee48e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
8 deletions
+26
-8
ConfigPath.cxx
src/ConfigPath.cxx
+2
-6
Main.cxx
src/Main.cxx
+6
-2
Path.cxx
src/fs/Path.cxx
+13
-0
Path.hxx
src/fs/Path.hxx
+5
-0
No files found.
src/ConfigPath.cxx
View file @
1ee6a78c
...
...
@@ -53,13 +53,9 @@ ParsePath(const char *path, Error &error)
{
assert
(
path
!=
nullptr
);
Path
path2
=
Path
::
FromUTF8
(
path
);
if
(
path2
.
IsNull
())
{
error
.
Format
(
path_domain
,
"Failed to convert path to file system charset: %s"
,
path
);
Path
path2
=
Path
::
FromUTF8
(
path
,
error
);
if
(
path2
.
IsNull
())
return
Path
::
Null
();
}
#ifndef WIN32
if
(
!
g_path_is_absolute
(
path
)
&&
path
[
0
]
!=
'~'
)
{
...
...
src/Main.cxx
View file @
1ee6a78c
...
...
@@ -138,8 +138,12 @@ glue_mapper_init(Error &error)
if
(
playlist_dir
.
IsNull
()
&&
error
.
IsDefined
())
return
false
;
if
(
music_dir
.
IsNull
())
music_dir
=
Path
::
FromUTF8
(
g_get_user_special_dir
(
G_USER_DIRECTORY_MUSIC
));
if
(
music_dir
.
IsNull
())
{
music_dir
=
Path
::
FromUTF8
(
g_get_user_special_dir
(
G_USER_DIRECTORY_MUSIC
),
error
);
if
(
music_dir
.
IsNull
())
return
false
;
}
mapper_init
(
std
::
move
(
music_dir
),
std
::
move
(
playlist_dir
));
return
true
;
...
...
src/fs/Path.cxx
View file @
1ee6a78c
...
...
@@ -21,6 +21,7 @@
#include "fs/Path.hxx"
#include "ConfigGlobal.hxx"
#include "system/FatalError.hxx"
#include "util/Error.hxx"
#include "util/Domain.hxx"
#include "gcc.h"
...
...
@@ -89,6 +90,18 @@ Path Path::FromUTF8(const char *path_utf8)
return
Path
(
Donate
(),
p
);
}
Path
Path
::
FromUTF8
(
const
char
*
path_utf8
,
Error
&
error
)
{
Path
path
=
FromUTF8
(
path_utf8
);
if
(
path
.
IsNull
())
error
.
Format
(
path_domain
,
"Failed to convert to file system charset: %s"
,
path_utf8
);
return
path
;
}
gcc_pure
static
bool
IsSupportedCharset
(
const
char
*
charset
)
...
...
src/fs/Path.hxx
View file @
1ee6a78c
...
...
@@ -44,6 +44,8 @@
# endif
#endif
class
Error
;
extern
const
class
Domain
path_domain
;
/**
...
...
@@ -151,6 +153,9 @@ public:
gcc_pure
static
Path
FromUTF8
(
const
char
*
path_utf8
);
gcc_pure
static
Path
FromUTF8
(
const
char
*
path_utf8
,
Error
&
error
);
/**
* Convert the path to UTF-8.
* Returns empty string on error or if #path_fs is null pointer.
...
...
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