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
32290d5e
Commit
32290d5e
authored
Jul 18, 2018
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fs/Path: add method ToUTF8Throw()
parent
f87265a4
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
42 additions
and
28 deletions
+42
-28
PlaylistFile.cxx
src/PlaylistFile.cxx
+5
-3
PlaylistSave.cxx
src/PlaylistSave.cxx
+4
-1
AllocatedPath.hxx
src/fs/AllocatedPath.hxx
+4
-0
Path.cxx
src/fs/Path.cxx
+7
-1
Path.hxx
src/fs/Path.hxx
+5
-0
FileInputPlugin.cxx
src/input/plugins/FileInputPlugin.cxx
+1
-1
PlaylistStream.cxx
src/playlist/PlaylistStream.cxx
+3
-5
LocalStorage.cxx
src/storage/plugins/LocalStorage.cxx
+6
-6
NfsStorage.cxx
src/storage/plugins/NfsStorage.cxx
+5
-6
ContainerScan.cxx
test/ContainerScan.cxx
+2
-5
No files found.
src/PlaylistFile.cxx
View file @
32290d5e
...
@@ -143,11 +143,13 @@ LoadPlaylistFileInfo(PlaylistInfo &info,
...
@@ -143,11 +143,13 @@ LoadPlaylistFileInfo(PlaylistInfo &info,
return
false
;
return
false
;
const
auto
name
=
AllocatedPath
::
FromFS
(
name_fs_str
,
name_fs_end
);
const
auto
name
=
AllocatedPath
::
FromFS
(
name_fs_str
,
name_fs_end
);
std
::
string
name_utf8
=
name
.
ToUTF8
();
if
(
name_utf8
.
empty
())
try
{
info
.
name
=
name
.
ToUTF8Throw
();
}
catch
(...)
{
return
false
;
return
false
;
}
info
.
name
=
std
::
move
(
name_utf8
);
info
.
mtime
=
fi
.
GetModificationTime
();
info
.
mtime
=
fi
.
GetModificationTime
();
return
true
;
return
true
;
}
}
...
...
src/PlaylistSave.cxx
View file @
32290d5e
...
@@ -41,7 +41,10 @@ playlist_print_path(BufferedOutputStream &os, const Path path)
...
@@ -41,7 +41,10 @@ playlist_print_path(BufferedOutputStream &os, const Path path)
/* on Windows, playlists always contain UTF-8, because its
/* on Windows, playlists always contain UTF-8, because its
"narrow" charset (i.e. CP_ACP) is incapable of storing all
"narrow" charset (i.e. CP_ACP) is incapable of storing all
Unicode paths */
Unicode paths */
os
.
Format
(
"%s
\n
"
,
path
.
ToUTF8
().
c_str
());
try
{
os
.
Format
(
"%s
\n
"
,
path
.
ToUTF8Throw
().
c_str
());
}
catch
(...)
{
}
#else
#else
os
.
Format
(
"%s
\n
"
,
path
.
c_str
());
os
.
Format
(
"%s
\n
"
,
path
.
c_str
());
#endif
#endif
...
...
src/fs/AllocatedPath.hxx
View file @
32290d5e
...
@@ -253,6 +253,10 @@ public:
...
@@ -253,6 +253,10 @@ public:
return
((
Path
)
*
this
).
ToUTF8
();
return
((
Path
)
*
this
).
ToUTF8
();
}
}
std
::
string
ToUTF8Throw
()
const
{
return
((
Path
)
*
this
).
ToUTF8Throw
();
}
/**
/**
* Gets directory name of this path.
* Gets directory name of this path.
* Returns a "nulled" instance on error.
* Returns a "nulled" instance on error.
...
...
src/fs/Path.cxx
View file @
32290d5e
...
@@ -25,12 +25,18 @@ std::string
...
@@ -25,12 +25,18 @@ std::string
Path
::
ToUTF8
()
const
noexcept
Path
::
ToUTF8
()
const
noexcept
{
{
try
{
try
{
return
::
PathToUTF8
(
c_str
()
);
return
ToUTF8Throw
(
);
}
catch
(...)
{
}
catch
(...)
{
return
std
::
string
();
return
std
::
string
();
}
}
}
}
std
::
string
Path
::
ToUTF8Throw
()
const
{
return
::
PathToUTF8
(
c_str
());
}
Path
::
const_pointer_type
Path
::
const_pointer_type
Path
::
GetSuffix
()
const
noexcept
Path
::
GetSuffix
()
const
noexcept
{
{
...
...
src/fs/Path.hxx
View file @
32290d5e
...
@@ -135,6 +135,11 @@ public:
...
@@ -135,6 +135,11 @@ public:
std
::
string
ToUTF8
()
const
noexcept
;
std
::
string
ToUTF8
()
const
noexcept
;
/**
/**
* Like ToUTF8(), but throws on error.
*/
std
::
string
ToUTF8Throw
()
const
;
/**
* Determine the "base" file name.
* Determine the "base" file name.
* The return value points inside this object.
* The return value points inside this object.
*/
*/
...
...
src/input/plugins/FileInputPlugin.cxx
View file @
32290d5e
...
@@ -72,7 +72,7 @@ OpenFileInputStream(Path path, Mutex &mutex)
...
@@ -72,7 +72,7 @@ OpenFileInputStream(Path path, Mutex &mutex)
#endif
#endif
#endif
#endif
return
std
::
make_unique
<
FileInputStream
>
(
path
.
ToUTF8
().
c_str
(),
return
std
::
make_unique
<
FileInputStream
>
(
path
.
ToUTF8
Throw
().
c_str
(),
std
::
move
(
reader
),
info
.
GetSize
(),
std
::
move
(
reader
),
info
.
GetSize
(),
mutex
);
mutex
);
}
}
...
...
src/playlist/PlaylistStream.cxx
View file @
32290d5e
...
@@ -40,7 +40,7 @@ try {
...
@@ -40,7 +40,7 @@ try {
if
(
suffix
==
nullptr
)
if
(
suffix
==
nullptr
)
return
nullptr
;
return
nullptr
;
const
auto
suffix_utf8
=
Path
::
FromFS
(
suffix
).
ToUTF8
();
const
auto
suffix_utf8
=
Path
::
FromFS
(
suffix
).
ToUTF8
Throw
();
if
(
!
playlist_suffix_supported
(
suffix_utf8
.
c_str
()))
if
(
!
playlist_suffix_supported
(
suffix_utf8
.
c_str
()))
return
nullptr
;
return
nullptr
;
...
@@ -57,10 +57,8 @@ playlist_open_path(Path path, Mutex &mutex)
...
@@ -57,10 +57,8 @@ playlist_open_path(Path path, Mutex &mutex)
try
{
try
{
assert
(
!
path
.
IsNull
());
assert
(
!
path
.
IsNull
());
const
std
::
string
uri_utf8
=
path
.
ToUTF8
();
const
std
::
string
uri_utf8
=
path
.
ToUTF8Throw
();
auto
playlist
=
!
uri_utf8
.
empty
()
auto
playlist
=
playlist_list_open_uri
(
uri_utf8
.
c_str
(),
mutex
);
?
playlist_list_open_uri
(
uri_utf8
.
c_str
(),
mutex
)
:
nullptr
;
if
(
playlist
==
nullptr
)
if
(
playlist
==
nullptr
)
playlist
=
playlist_open_path_suffix
(
path
,
mutex
);
playlist
=
playlist_open_path_suffix
(
path
,
mutex
);
...
...
src/storage/plugins/LocalStorage.cxx
View file @
32290d5e
...
@@ -51,7 +51,7 @@ class LocalStorage final : public Storage {
...
@@ -51,7 +51,7 @@ class LocalStorage final : public Storage {
public
:
public
:
explicit
LocalStorage
(
Path
_base_fs
)
explicit
LocalStorage
(
Path
_base_fs
)
:
base_fs
(
_base_fs
),
base_utf8
(
base_fs
.
ToUTF8
())
{
:
base_fs
(
_base_fs
),
base_utf8
(
base_fs
.
ToUTF8
Throw
())
{
assert
(
!
base_fs
.
IsNull
());
assert
(
!
base_fs
.
IsNull
());
assert
(
!
base_utf8
.
empty
());
assert
(
!
base_utf8
.
empty
());
}
}
...
@@ -162,11 +162,11 @@ LocalDirectoryReader::Read() noexcept
...
@@ -162,11 +162,11 @@ LocalDirectoryReader::Read() noexcept
if
(
SkipNameFS
(
name_fs
.
c_str
()))
if
(
SkipNameFS
(
name_fs
.
c_str
()))
continue
;
continue
;
name_utf8
=
name_fs
.
ToUTF8
();
try
{
if
(
name_utf8
.
empty
())
name_utf8
=
name_fs
.
ToUTF8Throw
();
continue
;
return
name_utf8
.
c_str
()
;
}
catch
(...)
{
return
name_utf8
.
c_str
();
}
}
}
return
nullptr
;
return
nullptr
;
...
...
src/storage/plugins/NfsStorage.cxx
View file @
32290d5e
...
@@ -378,14 +378,13 @@ NfsListDirectoryOperation::CollectEntries(struct nfsdir *dir)
...
@@ -378,14 +378,13 @@ NfsListDirectoryOperation::CollectEntries(struct nfsdir *dir)
if
(
SkipNameFS
(
name_fs
.
c_str
()))
if
(
SkipNameFS
(
name_fs
.
c_str
()))
continue
;
continue
;
std
::
string
name_utf8
=
name_fs
.
ToUTF8
();
try
{
if
(
name_utf8
.
empty
())
entries
.
emplace_front
(
name_fs
.
ToUTF8Throw
());
Copy
(
entries
.
front
().
info
,
*
ent
);
}
catch
(...)
{
/* ignore files whose name cannot be converted
/* ignore files whose name cannot be converted
to UTF-8 */
to UTF-8 */
continue
;
}
entries
.
emplace_front
(
std
::
move
(
name_utf8
));
Copy
(
entries
.
front
().
info
,
*
ent
);
}
}
}
}
...
...
test/ContainerScan.cxx
View file @
32290d5e
...
@@ -48,12 +48,9 @@ FindContainerDecoderPlugin(const char *suffix)
...
@@ -48,12 +48,9 @@ FindContainerDecoderPlugin(const char *suffix)
static
const
DecoderPlugin
*
static
const
DecoderPlugin
*
FindContainerDecoderPlugin
(
Path
path
)
FindContainerDecoderPlugin
(
Path
path
)
{
{
const
auto
utf8
=
path
.
ToUTF8
();
if
(
utf8
.
empty
())
return
nullptr
;
UriSuffixBuffer
suffix_buffer
;
UriSuffixBuffer
suffix_buffer
;
const
char
*
const
suffix
=
uri_get_suffix
(
utf8
.
c_str
(),
suffix_buffer
);
const
char
*
const
suffix
=
uri_get_suffix
(
path
.
ToUTF8Throw
().
c_str
(),
suffix_buffer
);
if
(
suffix
==
nullptr
)
if
(
suffix
==
nullptr
)
return
nullptr
;
return
nullptr
;
...
...
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