File: file_util.hpp

package info (click to toggle)
toppic 1.3.0%2Bdfsg1-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 44,588 kB
  • sloc: cpp: 61,030; javascript: 33,937; xml: 8,121; ansic: 2,437; python: 755; sh: 76; makefile: 20
file content (80 lines) | stat: -rw-r--r-- 2,248 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//Copyright (c) 2014 - 2019, The Trustees of Indiana University.
//
//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.

#ifndef TOPPIC_COMMON_UTIL_FILE_UTIL_HPP_
#define TOPPIC_COMMON_UTIL_FILE_UTIL_HPP_

#include <string>

#include "config.h"

namespace toppic {

namespace file_util {

std::string getExecutiveDir(const std::string &argv_0);

std::string getFileSeparator();

std::string basename(const std::string &s);

std::string directory(const std::string &s);

std::string absoluteDir(const std::string &s);

std::string absoluteName(const std::string &s);

void createFolder(const std::string &folder_name);

void copyFile(const std::string &file_name, const std::string &path,
              bool over_write);

bool copyDir(const std::string &source, 
             const std::string &destination);

bool copyJsonDir(const std::string &src_name,
                 const std::string &des_name,
                 int id_base);

void createLink(const std::string &a_link, 
		const std::string &a_dir,
		const std::string &b);

bool exists(const std::string &path);

void delDir(const std::string &path);

void delFile(const std::string &path);

void rename(const std::string &ori_name, 
            const std::string &new_name);

void cleanPrefix(const std::string & ref_name, 
                 const std::string & prefix);

void cleanTempFiles(const std::string & ref_name, 
                    const std::string & ext_prefix);

void moveFile(std::string &file_name, std::string &folder_name);

inline std::string getToppicResourceDirName() {return "toppic_resources";}

inline std::string getDataDirName() {return TOPPIC_DATA_DIR;}

std::string getResourceDir(const std::string &exec_dir);

}  // namespace file_util

}  // namespace toppic
#endif