Andrew Top | 2a79646 | 2018-06-29 09:04:04 -0700 | [diff] [blame] | 1 | // Copyright 2017 The Cobalt Authors. All Rights Reserved. |
Andrew Top | c2b4089 | 2017-01-19 14:03:49 -0800 | [diff] [blame] | 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 | // Adapted from base/platform_file_posix.cc |
| 16 | |
| 17 | #ifndef STARBOARD_SHARED_POSIX_IMPL_FILE_SEEK_H_ |
| 18 | #define STARBOARD_SHARED_POSIX_IMPL_FILE_SEEK_H_ |
| 19 | |
| 20 | #include "starboard/file.h" |
| 21 | |
| 22 | #include <unistd.h> |
| 23 | |
| 24 | #include "starboard/shared/internal_only.h" |
| 25 | #include "starboard/shared/posix/impl/file_impl.h" |
| 26 | |
| 27 | namespace starboard { |
| 28 | namespace shared { |
| 29 | namespace posix { |
| 30 | namespace impl { |
| 31 | |
| 32 | int64_t FileSeek(SbFile file, SbFileWhence whence, int64_t offset) { |
| 33 | if (!file || file->descriptor < 0) { |
| 34 | return -1; |
| 35 | } |
| 36 | |
| 37 | return lseek(file->descriptor, static_cast<off_t>(offset), |
| 38 | static_cast<int>(whence)); |
| 39 | } |
| 40 | |
| 41 | } // namespace impl |
| 42 | } // namespace posix |
| 43 | } // namespace shared |
| 44 | } // namespace starboard |
| 45 | |
| 46 | #endif // STARBOARD_SHARED_POSIX_IMPL_FILE_SEEK_H_ |