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
00b0f6ad
Commit
00b0f6ad
authored
Feb 25, 2015
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fs/io/File{Reader,OutputStream}: convert path to UTF-8 for error message
parent
fe1e467a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
7 deletions
+18
-7
FileOutputStream.cxx
src/fs/io/FileOutputStream.cxx
+11
-4
FileReader.cxx
src/fs/io/FileReader.cxx
+7
-3
No files found.
src/fs/io/FileOutputStream.cxx
View file @
00b0f6ad
...
...
@@ -43,8 +43,11 @@ FileOutputStream::FileOutputStream(Path _path, Error &error)
FILE_ATTRIBUTE_NORMAL
|
FILE_FLAG_WRITE_THROUGH
,
nullptr
))
{
if
(
handle
==
INVALID_HANDLE_VALUE
)
error
.
FormatLastError
(
"Failed to create %s"
,
path
.
c_str
());
if
(
handle
==
INVALID_HANDLE_VALUE
)
{
const
auto
path_utf8
=
path
.
ToUTF8
();
error
.
FormatLastError
(
"Failed to create %s"
,
path_utf8
.
c_str
());
}
}
bool
...
...
@@ -54,13 +57,17 @@ FileOutputStream::Write(const void *data, size_t size, Error &error)
DWORD
nbytes
;
if
(
!
WriteFile
(
handle
,
data
,
size
,
&
nbytes
,
nullptr
))
{
error
.
FormatLastError
(
"Failed to write to %s"
,
path
.
c_str
());
const
auto
path_utf8
=
path
.
ToUTF8
();
error
.
FormatLastError
(
"Failed to write to %s"
,
path_utf8
.
c_str
());
return
false
;
}
if
(
size_t
(
nbytes
)
!=
size
)
{
const
auto
path_utf8
=
path
.
ToUTF8
();
error
.
FormatLastError
(
ERROR_DISK_FULL
,
"Failed to write to %s"
,
path
.
c_str
());
"Failed to write to %s"
,
path_utf8
.
c_str
());
return
false
;
}
...
...
src/fs/io/FileReader.cxx
View file @
00b0f6ad
...
...
@@ -30,8 +30,10 @@ FileReader::FileReader(Path _path, Error &error)
nullptr
,
OPEN_EXISTING
,
FILE_ATTRIBUTE_NORMAL
,
nullptr
))
{
if
(
handle
==
INVALID_HANDLE_VALUE
)
error
.
FormatLastError
(
"Failed to open %s"
,
path
.
c_str
());
if
(
handle
==
INVALID_HANDLE_VALUE
)
{
const
auto
path_utf8
=
path
.
ToUTF8
();
error
.
FormatLastError
(
"Failed to open %s"
,
path_utf8
.
c_str
());
}
}
size_t
...
...
@@ -41,7 +43,9 @@ FileReader::Read(void *data, size_t size, Error &error)
DWORD
nbytes
;
if
(
!
ReadFile
(
handle
,
data
,
size
,
&
nbytes
,
nullptr
))
{
error
.
FormatLastError
(
"Failed to read from %s"
,
path
.
c_str
());
const
auto
path_utf8
=
path
.
ToUTF8
();
error
.
FormatLastError
(
"Failed to read from %s"
,
path_utf8
.
c_str
());
nbytes
=
0
;
}
...
...
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