OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "files/public/c/lib/util.h" | 5 #include "files/public/c/lib/util.h" |
6 | 6 |
7 #include <assert.h> | 7 #include <assert.h> |
8 #include <errno.h> | 8 #include <errno.h> |
9 | 9 |
10 namespace mojio { | 10 namespace mojio { |
11 | 11 |
12 int ErrorToErrno(mojo::files::Error error) { | 12 int ErrorToErrno(mojo::files::Error error) { |
13 switch (error) { | 13 switch (error) { |
14 // TODO(vtl): Real errno encodings.... | 14 // TODO(vtl): Real errno encodings.... |
15 case mojo::files::ERROR_OK: | 15 case mojo::files::Error::OK: |
16 return 0; | 16 return 0; |
17 case mojo::files::ERROR_UNKNOWN: | 17 case mojo::files::Error::UNKNOWN: |
18 // TODO(vtl): Something better? | 18 // TODO(vtl): Something better? |
19 return EIO; | 19 return EIO; |
20 case mojo::files::ERROR_INVALID_ARGUMENT: | 20 case mojo::files::Error::INVALID_ARGUMENT: |
21 return EINVAL; | 21 return EINVAL; |
22 case mojo::files::ERROR_PERMISSION_DENIED: | 22 case mojo::files::Error::PERMISSION_DENIED: |
23 return EACCES; | 23 return EACCES; |
24 case mojo::files::ERROR_OUT_OF_RANGE: | 24 case mojo::files::Error::OUT_OF_RANGE: |
25 // TODO(vtl): But sometimes it might be E2BIG or EDOM or ENAMETOOLONG, | 25 // TODO(vtl): But sometimes it might be E2BIG or EDOM or ENAMETOOLONG, |
26 // etc.? | 26 // etc.? |
27 return EINVAL; | 27 return EINVAL; |
28 case mojo::files::ERROR_UNIMPLEMENTED: | 28 case mojo::files::Error::UNIMPLEMENTED: |
29 // TODO(vtl): Sometimes ENOTSUP? | 29 // TODO(vtl): Sometimes ENOTSUP? |
30 return ENOSYS; | 30 return ENOSYS; |
31 case mojo::files::ERROR_CLOSED: | 31 case mojo::files::Error::CLOSED: |
32 return EBADF; | 32 return EBADF; |
33 case mojo::files::ERROR_UNAVAILABLE: | 33 case mojo::files::Error::UNAVAILABLE: |
34 // TODO(vtl): May sometimes be EAGAIN? | 34 // TODO(vtl): May sometimes be EAGAIN? |
35 return EACCES; | 35 return EACCES; |
36 case mojo::files::ERROR_INTERNAL: | 36 case mojo::files::Error::INTERNAL: |
37 // TODO(vtl): Something better? | 37 // TODO(vtl): Something better? |
38 return EIO; | 38 return EIO; |
39 } | 39 } |
40 assert(false); | 40 assert(false); |
41 // TODO(vtl): Something better? | 41 // TODO(vtl): Something better? |
42 return EIO; | 42 return EIO; |
43 } | 43 } |
44 | 44 |
45 } // namespace mojio | 45 } // namespace mojio |
OLD | NEW |