blob: c769b882db1e1ed412f385fc40d2cf2261e13204 [file] [log] [blame]
Andrew Top2a796462018-06-29 09:04:04 -07001// Copyright 2017 The Cobalt Authors. All Rights Reserved.
Andrew Topc2b40892017-01-19 14:03:49 -08002//
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
27namespace starboard {
28namespace shared {
29namespace posix {
30namespace impl {
31
32int64_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_