David Ghandehari | 0ffd5ad | 2017-05-12 21:39:37 -0700 | [diff] [blame] | 1 | // Copyright 2017 Google Inc. All Rights Reserved. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | #include "starboard/file.h" |
| 16 | |
| 17 | #include "starboard/shared/win32/file_internal.h" |
| 18 | |
| 19 | SbFile SbFileOpen(const char* path, |
| 20 | int flags, |
| 21 | bool* out_created, |
| 22 | SbFileError* out_error) { |
| 23 | if ((path == nullptr) || (path[0] == '\0')) { |
| 24 | if (out_created) { |
| 25 | *out_created = false; |
| 26 | } |
| 27 | if (out_error) { |
| 28 | *out_error = kSbFileErrorNotAFile; |
| 29 | } |
| 30 | return kSbFileInvalid; |
| 31 | } |
| 32 | |
| 33 | HANDLE file_handle = |
| 34 | starboard::shared::win32::OpenFileOrDirectory(path, flags, out_created, out_error); |
| 35 | |
| 36 | if (!starboard::shared::win32::IsValidHandle(file_handle)) { |
| 37 | return kSbFileInvalid; |
| 38 | } |
| 39 | |
| 40 | return new SbFilePrivate(file_handle); |
| 41 | } |