-
Notifications
You must be signed in to change notification settings - Fork 5.5k
filesystem: add Windows implementation #6072
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
b71a376
5071a3c
a8bfaaa
d2f321e
08f5e47
7a4cd3a
f69fe09
4edccb5
5a4f87f
21c24e4
aa19af7
9c0dbc1
17fe009
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| #include "common/filesystem/io_file_error.h" | ||
|
|
||
| #include <cstring> | ||
|
|
||
| namespace Envoy { | ||
| namespace Filesystem { | ||
|
|
||
| Api::IoError::IoErrorCode IoFileError::errorCode() const { | ||
| switch (errno_) { | ||
| case EBADF: | ||
| return IoErrorCode::BadHandle; | ||
| default: | ||
| return IoErrorCode::UnknownError; | ||
| } | ||
| } | ||
|
|
||
| std::string IoFileError::errorDetails() const { return ::strerror(errno_); } | ||
|
|
||
| } // namespace Filesystem | ||
| } // namespace Envoy |
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -0,0 +1,40 @@ | ||||
| #pragma once | ||||
|
|
||||
| #include <string> | ||||
|
|
||||
| #include "envoy/api/io_error.h" | ||||
|
|
||||
| #include "common/common/assert.h" | ||||
|
|
||||
| namespace Envoy { | ||||
| namespace Filesystem { | ||||
|
|
||||
| class IoFileError : public Api::IoError { | ||||
| public: | ||||
| explicit IoFileError(int sys_errno) : errno_(sys_errno) {} | ||||
|
|
||||
| ~IoFileError() override {} | ||||
|
|
||||
| private: | ||||
| IoErrorCode errorCode() const override; | ||||
|
dnoe marked this conversation as resolved.
Outdated
|
||||
|
|
||||
| std::string errorDetails() const override; | ||||
|
|
||||
| int errno_; | ||||
|
dnoe marked this conversation as resolved.
Outdated
|
||||
| }; | ||||
|
|
||||
| using IoFileErrorPtr = std::unique_ptr<IoFileError, Api::IoErrorDeleterType>; | ||||
|
|
||||
| template <typename T> Api::IoCallResult<T> resultFailure(T result, int sys_errno) { | ||||
| return {result, IoFileErrorPtr(new IoFileError(sys_errno), [](Api::IoError* err) { | ||||
| ASSERT(err != nullptr); | ||||
| delete err; | ||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bare news and deletes are always a bit concerning. Can you elaborate on why they are needed here?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The implementations of Api::IoError need to use a custom deleter, see
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like we don't need to cover the |
||||
| })}; | ||||
| } | ||||
|
|
||||
| template <typename T> Api::IoCallResult<T> resultSuccess(T result) { | ||||
| return {result, IoFileErrorPtr(nullptr, [](Api::IoError*) { NOT_REACHED_GCOVR_EXCL_LINE; })}; | ||||
| } | ||||
|
|
||||
| } // namespace Filesystem | ||||
| } // namespace Envoy | ||||
Uh oh!
There was an error while loading. Please reload this page.