MiniOB 1
MiniOB is one mini database, helping developers to learn how database works.
载入中...
搜索中...
未找到
persist.h
1/* Copyright (c) 2021 OceanBase and/or its affiliates. All rights reserved.
2miniob is licensed under Mulan PSL v2.
3You can use this software according to the terms and conditions of the Mulan PSL v2.
4You may obtain a copy of Mulan PSL v2 at:
5 http://license.coscl.org.cn/MulanPSL2
6THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
7EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
8MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
9See the Mulan PSL v2 for more details. */
10
11//
12// Created by qiling on 2021/4/13.
13//
14#pragma once
15
16#include <sys/types.h>
17#include <sys/stat.h>
18#include <fcntl.h>
19#include <stdint.h>
20#include <stdio.h>
21#include <stdlib.h>
22#include <string.h>
23#include <string>
24
25#include "common/rc.h"
26
28{
29public:
32
34 RC create_file(const char *file_name);
35
37 RC open_file(const char *file_name = nullptr);
38
40 RC close_file();
41
43 RC remove_file(const char *file_name = nullptr);
44
46 RC write_file(int size, const char *data, int64_t *out_size = nullptr);
47
49 RC write_at(uint64_t offset, int size, const char *data, int64_t *out_size = nullptr);
50
52 RC append(int size, const char *data, int64_t *out_size = nullptr);
53
55 RC read_file(int size, char *data, int64_t *out_size = nullptr);
56
58 RC read_at(uint64_t offset, int size, char *data, int64_t *out_size = nullptr);
59
61 RC seek(uint64_t offset);
62
63private:
64 std::string file_name_;
65 int file_desc_ = -1;
66};
Definition: persist.h:28
RC close_file()
Definition: persist.cpp:90
RC remove_file(const char *file_name=nullptr)
Definition: persist.cpp:106
RC open_file(const char *file_name=nullptr)
Definition: persist.cpp:54
RC seek(uint64_t offset)
Definition: persist.cpp:285
RC write_file(int size, const char *data, int64_t *out_size=nullptr)
Definition: persist.cpp:131
RC append(int size, const char *data, int64_t *out_size=nullptr)
Definition: persist.cpp:195
RC write_at(uint64_t offset, int size, const char *data, int64_t *out_size=nullptr)
Definition: persist.cpp:158
RC read_at(uint64_t offset, int size, char *data, int64_t *out_size=nullptr)
Definition: persist.cpp:251
RC create_file(const char *file_name)
Definition: persist.cpp:29
RC read_file(int size, char *data, int64_t *out_size=nullptr)
Definition: persist.cpp:228