fs.h 4.0 KB
Newer Older
D
dongdaxiang 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
// Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#pragma once

17
#include <stdint.h>
D
dongdaxiang 已提交
18
#include <stdio.h>
19

20
#include <memory>
D
dongdaxiang 已提交
21 22
#include <string>
#include <vector>
W
wanghuancoder 已提交
23

D
dongdaxiang 已提交
24
#include "glog/logging.h"
25 26
#include "paddle/fluid/framework/io/shell.h"
#include "paddle/fluid/string/string_helper.h"
D
dongdaxiang 已提交
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55

namespace paddle {
namespace framework {

int fs_select_internal(const std::string& path);

// localfs
extern size_t localfs_buffer_size();

extern void localfs_set_buffer_size(size_t x);

extern std::shared_ptr<FILE> localfs_open_read(std::string path,
                                               const std::string& converter);

extern std::shared_ptr<FILE> localfs_open_write(std::string path,
                                                const std::string& converter);

extern int64_t localfs_file_size(const std::string& path);

extern void localfs_remove(const std::string& path);

extern std::vector<std::string> localfs_list(const std::string& path);

extern std::string localfs_tail(const std::string& path);

extern bool localfs_exists(const std::string& path);

extern void localfs_mkdir(const std::string& path);

56 57
extern void localfs_mv(const std::string& src, const std::string& dest);

D
dongdaxiang 已提交
58 59 60 61 62 63 64 65 66
// hdfs
extern size_t hdfs_buffer_size();

extern void hdfs_set_buffer_size(size_t x);

extern const std::string& hdfs_command();

extern void hdfs_set_command(const std::string& x);

67 68 69 70
extern const std::string& dataset_hdfs_command();

extern void dataset_hdfs_set_command(const std::string& x);

71 72 73 74
extern const std::string& download_cmd();

extern void set_download_command(const std::string& x);

75 76
extern std::shared_ptr<FILE> hdfs_open_read(std::string path,
                                            int* err_no,
77 78
                                            const std::string& converter,
                                            bool read_data);
D
dongdaxiang 已提交
79

80 81
extern std::shared_ptr<FILE> hdfs_open_write(std::string path,
                                             int* err_no,
D
dongdaxiang 已提交
82 83 84 85 86 87 88 89 90 91 92 93
                                             const std::string& converter);

extern void hdfs_remove(const std::string& path);

extern std::vector<std::string> hdfs_list(const std::string& path);

extern std::string hdfs_tail(const std::string& path);

extern bool hdfs_exists(const std::string& path);

extern void hdfs_mkdir(const std::string& path);

94 95
extern void hdfs_mv(const std::string& src, const std::string& dest);

D
dongdaxiang 已提交
96
// aut-detect fs
97 98
extern std::shared_ptr<FILE> fs_open_read(const std::string& path,
                                          int* err_no,
99 100
                                          const std::string& converter,
                                          bool read_data = false);
D
dongdaxiang 已提交
101

102 103
extern std::shared_ptr<FILE> fs_open_write(const std::string& path,
                                           int* err_no,
D
dongdaxiang 已提交
104 105 106
                                           const std::string& converter);

extern std::shared_ptr<FILE> fs_open(const std::string& path,
107 108
                                     const std::string& mode,
                                     int* err_no,
D
dongdaxiang 已提交
109 110 111 112 113 114 115 116 117 118 119 120 121
                                     const std::string& converter = "");

extern int64_t fs_file_size(const std::string& path);

extern void fs_remove(const std::string& path);

extern std::vector<std::string> fs_list(const std::string& path);

extern std::string fs_tail(const std::string& path);

extern bool fs_exists(const std::string& path);

extern void fs_mkdir(const std::string& path);
122 123 124

extern void fs_mv(const std::string& src, const std::string& dest);

D
dongdaxiang 已提交
125 126
}  // namespace framework
}  // namespace paddle