|
33 | 33 | #include "cpprest/fileio.h"
|
34 | 34 |
|
35 | 35 | using namespace boost::asio;
|
| 36 | +using namespace Concurrency::streams::details; |
36 | 37 |
|
37 | 38 | namespace Concurrency { namespace streams { namespace details {
|
38 | 39 |
|
@@ -124,7 +125,6 @@ std::shared_ptr<io_scheduler> get_scheduler()
|
124 | 125 | * =-=-=-
|
125 | 126 | ****/
|
126 | 127 |
|
127 |
| - |
128 | 128 | /// <summary>
|
129 | 129 | /// The public parts of the file information record contain only what is implementation-
|
130 | 130 | /// independent. The actual allocated record is larger and has details that the implementation
|
@@ -165,8 +165,6 @@ struct _file_info_impl : _file_info
|
165 | 165 |
|
166 | 166 | }}}
|
167 | 167 |
|
168 |
| -using namespace Concurrency::streams::details; |
169 |
| - |
170 | 168 | /// <summary>
|
171 | 169 | /// Perform post-CreateFile processing.
|
172 | 170 | /// </summary>
|
@@ -204,12 +202,7 @@ bool _finish_create(int fh, _filestream_callback *callback, std::ios_base::openm
|
204 | 202 | }
|
205 | 203 | else
|
206 | 204 | {
|
207 |
| -#ifdef __APPLE__ |
208 |
| - auto exptr = std::make_exception_ptr(std::ios_base::failure("failed to create file", std::make_error_code(std::errc::no_such_file_or_directory))); |
209 |
| -#else |
210 |
| - auto exptr = std::make_exception_ptr(std::ios_base::failure("failed to create file")); |
211 |
| -#endif |
212 |
| - callback->on_error(exptr); |
| 205 | + callback->on_error(std::make_exception_ptr(utility::details::create_system_error(errno))); |
213 | 206 | return false;
|
214 | 207 | }
|
215 | 208 | }
|
@@ -326,8 +319,7 @@ bool _close_fsb_nolock(_file_info **info, Concurrency::streams::details::_filest
|
326 | 319 | }
|
327 | 320 | else
|
328 | 321 | {
|
329 |
| - auto exptr = std::make_exception_ptr(std::ios_base::failure("failed to close file")); |
330 |
| - callback->on_error(exptr); |
| 322 | + callback->on_error(std::make_exception_ptr(utility::details::create_system_error(errno))); |
331 | 323 | }
|
332 | 324 | });
|
333 | 325 |
|
@@ -383,9 +375,7 @@ size_t _write_file_async(Concurrency::streams::details::_file_info_impl *fInfo,
|
383 | 375 | auto bytes_written = pwrite(fInfo->m_handle, ptr, count, abs_position);
|
384 | 376 | if (bytes_written == -1)
|
385 | 377 | {
|
386 |
| - auto exptr = std::make_exception_ptr(std::ios_base::failure("failed to write file")); |
387 |
| - callback->on_error(exptr); |
388 |
| - perror("failed to write"); |
| 378 | + callback->on_error(std::make_exception_ptr(utility::details::create_system_error(errno))); |
389 | 379 | }
|
390 | 380 |
|
391 | 381 | if(must_restore_pos)
|
@@ -437,8 +427,7 @@ size_t _read_file_async(Concurrency::streams::details::_file_info_impl *fInfo, C
|
437 | 427 | auto bytes_read = pread(fInfo->m_handle, ptr, count, offset);
|
438 | 428 | if (bytes_read < 0)
|
439 | 429 | {
|
440 |
| - auto exptr = std::make_exception_ptr(std::ios_base::failure("failed to read file")); |
441 |
| - callback->on_error(exptr); |
| 430 | + callback->on_error(std::make_exception_ptr(utility::details::create_system_error(errno))); |
442 | 431 | }
|
443 | 432 | else
|
444 | 433 | {
|
|
0 commit comments