Coverage Report

Created: 2026-03-12 14:13

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/io/fs/file_system.cpp
Line
Count
Source
1
// Licensed to the Apache Software Foundation (ASF) under one
2
// or more contributor license agreements.  See the NOTICE file
3
// distributed with this work for additional information
4
// regarding copyright ownership.  The ASF licenses this file
5
// to you under the Apache License, Version 2.0 (the
6
// "License"); you may not use this file except in compliance
7
// with the License.  You may obtain a copy of the License at
8
//
9
//   http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing,
12
// software distributed under the License is distributed on an
13
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
// KIND, either express or implied.  See the License for the
15
// specific language governing permissions and limitations
16
// under the License.
17
18
#include "io/fs/file_system.h"
19
20
#include "io/fs/file_reader.h"
21
#include "util/async_io.h" // IWYU pragma: keep
22
23
namespace doris {
24
namespace io {
25
26
Status FileSystem::create_file(const Path& file, FileWriterPtr* writer,
27
209k
                               const FileWriterOptions* opts) {
28
209k
    Path path;
29
209k
    RETURN_IF_ERROR(absolute_path(file, path));
30
209k
    FILESYSTEM_M(create_file_impl(path, writer, opts));
31
0
}
32
33
Status FileSystem::open_file(const Path& file, FileReaderSPtr* reader,
34
1.91M
                             const FileReaderOptions* opts) {
35
1.91M
    Path path;
36
1.91M
    RETURN_IF_ERROR(absolute_path(file, path));
37
1.91M
    FILESYSTEM_M(open_file_impl(path, reader, opts));
38
0
}
39
40
223k
Status FileSystem::create_directory(const Path& dir, bool failed_if_exists) {
41
223k
    Path path;
42
223k
    RETURN_IF_ERROR(absolute_path(dir, path));
43
223k
    FILESYSTEM_M(create_directory_impl(path, failed_if_exists));
44
0
}
45
46
235k
Status FileSystem::delete_file(const Path& file) {
47
235k
    Path path;
48
235k
    RETURN_IF_ERROR(absolute_path(file, path));
49
235k
    FILESYSTEM_M(delete_file_impl(path));
50
0
}
51
52
177k
Status FileSystem::delete_directory(const Path& dir) {
53
177k
    Path path;
54
177k
    RETURN_IF_ERROR(absolute_path(dir, path));
55
177k
    FILESYSTEM_M(delete_directory_impl(path));
56
0
}
57
58
0
Status FileSystem::batch_delete(const std::vector<Path>& files) {
59
0
    std::vector<Path> abs_files;
60
0
    for (auto& file : files) {
61
0
        Path abs_file;
62
0
        RETURN_IF_ERROR(absolute_path(file, abs_file));
63
0
        abs_files.push_back(abs_file);
64
0
    }
65
0
    FILESYSTEM_M(batch_delete_impl(abs_files));
66
0
}
67
68
413k
Status FileSystem::exists(const Path& path, bool* res) const {
69
413k
    Path fs_path;
70
413k
    RETURN_IF_ERROR(absolute_path(path, fs_path));
71
413k
    FILESYSTEM_M(exists_impl(fs_path, res));
72
0
}
73
74
1.28k
Status FileSystem::file_size(const Path& file, int64_t* file_size) const {
75
1.28k
    Path path;
76
1.28k
    RETURN_IF_ERROR(absolute_path(file, path));
77
1.28k
    FILESYSTEM_M(file_size_impl(path, file_size));
78
0
}
79
80
Status FileSystem::list(const Path& dir, bool only_file, std::vector<FileInfo>* files,
81
818k
                        bool* exists) {
82
818k
    Path path;
83
818k
    RETURN_IF_ERROR(absolute_path(dir, path));
84
818k
    FILESYSTEM_M(list_impl(path, only_file, files, exists));
85
0
}
86
87
119k
Status FileSystem::rename(const Path& orig_name, const Path& new_name) {
88
119k
    Path orig_path;
89
119k
    RETURN_IF_ERROR(absolute_path(orig_name, orig_path));
90
119k
    Path new_path;
91
119k
    RETURN_IF_ERROR(absolute_path(new_name, new_path));
92
119k
    FILESYSTEM_M(rename_impl(orig_path, new_path));
93
0
}
94
95
} // namespace io
96
} // namespace doris