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
d551d408
Commit
d551d408
authored
Jun 23, 2015
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fs/NarrowPath: use the WideCharToMultiByte() wrapper
parent
aecfcaa8
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
14 deletions
+16
-14
NarrowPath.hxx
src/fs/NarrowPath.hxx
+16
-14
No files found.
src/fs/NarrowPath.hxx
View file @
d551d408
...
...
@@ -25,7 +25,11 @@
#include "util/Macros.hxx"
#ifdef _UNICODE
#include "lib/icu/Win32.hxx"
#include "util/AllocatedString.hxx"
#include <windows.h>
#else
#include "util/StringPointer.hxx"
#endif
/**
...
...
@@ -34,35 +38,33 @@
* that accepts only "const char *".
*/
class
NarrowPath
{
typedef
char
value_type
;
typedef
const
char
*
const_pointer
;
#ifdef _UNICODE
char
value
[
PATH_MAX
]
;
typedef
AllocatedString
<>
Value
;
#else
const_pointer
v
alue
;
typedef
StringPointer
<>
V
alue
;
#endif
typedef
typename
Value
::
const_pointer
const_pointer
;
Value
value
;
public
:
#ifdef _UNICODE
explicit
NarrowPath
(
Path
_path
)
{
auto
result
=
WideCharToMultiByte
(
CP_ACP
,
0
,
_path
.
c_str
(),
-
1
,
value
,
ARRAY_SIZE
(
value
),
nullptr
,
nullptr
);
if
(
result
<
0
)
value
[
0
]
=
0
;
explicit
NarrowPath
(
Path
_path
)
:
value
(
WideCharToMultiByte
(
CP_ACP
,
_path
.
c_str
()))
{
if
(
value
.
IsNull
())
/* fall back to empty string */
value
=
Value
::
Empty
();
}
#else
explicit
NarrowPath
(
Path
_path
)
:
value
(
_path
.
c_str
())
{}
#endif
operator
const_pointer
()
const
{
return
value
;
return
c_str
()
;
}
const_pointer
c_str
()
const
{
return
value
;
return
value
.
c_str
()
;
}
};
...
...
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