Apollo 10.0
自动驾驶开放平台
record_file_base.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
16
18
19#include <sys/types.h>
20#include <unistd.h>
21
22#include "cyber/common/log.h"
23
24namespace apollo {
25namespace cyber {
26namespace record {
27
29 off_t pos = lseek(fd_, 0, SEEK_CUR);
30 if (pos < 0) {
31 AERROR << "lseek failed, file: " << path_ << ", fd: " << fd_
32 << ", offset: 0, whence: SEEK_CUR"
33 << ", position: " << pos << ", errno: " << errno;
34 }
35 return pos;
36}
37
38bool RecordFileBase::SetPosition(int64_t position) {
39 off_t pos = lseek(fd_, position, SEEK_SET);
40 if (pos < 0) {
41 AERROR << "lseek failed, file: " << path_ << ", fd: " << fd_
42 << ", offset: 0, whence: SEEK_SET"
43 << ", position: " << pos << ", errno: " << errno;
44 return false;
45 }
46 return true;
47}
48
49} // namespace record
50} // namespace cyber
51} // namespace apollo
#define AERROR
Definition log.h:44
class register implement
Definition arena_queue.h:37