Scanner C++ API
fs.h
1 /* Copyright 2016 Carnegie Mellon University, NVIDIA Corporation
2  *
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 
16 #pragma once
17 
18 #include <glog/logging.h>
19 #include <libgen.h>
20 #include <stdio.h>
21 #include <sys/stat.h>
22 #include <cstring>
23 #include <sstream>
24 #include <string>
25 #include <vector>
26 
27 namespace scanner {
28 
31 inline std::string dirname_s(const std::string& path) {
32  char* path_copy = strdup(path.c_str());
33  char* dir = dirname(path_copy);
34  return std::string(dir);
35 }
36 
37 inline std::string basename_s(const std::string& path) {
38  char* path_copy = strdup(path.c_str());
39  char* base = basename(path_copy);
40  return std::string(base);
41 }
42 
43 int mkdir_p(const char* path, mode_t mode);
44 
45 void temp_file(FILE** file, std::string& name);
46 
47 void temp_file(std::string& name);
48 
49 void temp_dir(std::string& name);
50 
51 std::string done_file_path(const std::string& path);
52 
53 void download(const std::string& url, const std::string& local_path);
54 
55 std::string download_temp(const std::string& url);
56 
57 void delete_file(const std::string& path);
58 
59 std::vector<uint8_t> read_entire_file(const std::string& file_name);
60 
61 // Cached files
62 void cached_dir(const std::string& name, std::string& full_path);
63 
64 void download_if_uncached(const std::string& url,
65  const std::string& cache_path);
66 
67 
68 }
Definition: database.cpp:36