charon-core  0.3.1
FileTool.h
Go to the documentation of this file.
1 /* This file is part of Charon.
2 
3  Charon is free software: you can redistribute it and/or modify
4  it under the terms of the GNU Lesser General Public License as published by
5  the Free Software Foundation, either version 3 of the License, or
6  (at your option) any later version.
7 
8  Charon is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU Lesser General Public License for more details.
12 
13  You should have received a copy of the GNU Lesser General Public License
14  along with Charon. If not, see <http://www.gnu.org/licenses/>.
15 */
24 #ifndef _FileTool_H_
25 #define _FileTool_H_
26 
27 #include <string>
28 #include <vector>
29 #include "DllEx.h"
30 
32 
34 namespace FileTool {
36  extern const char charon_core_DLL_PUBLIC slash;
37 
42  int charon_core_DLL_PUBLIC makePath(std::string& path);
43 
47  int charon_core_DLL_PUBLIC makeDir(const std::string& dir);
48 
52  int charon_core_DLL_PUBLIC changeDir(const std::string& dir);
53 
57 
59 
64  std::vector<std::string> charon_core_DLL_PUBLIC getFilesWithSuffix(
65  std::string suffix);
66 
70  void charon_core_DLL_PUBLIC slashConvert(std::string& src);
71 
75  bool charon_core_DLL_PUBLIC exists(const std::string& file);
76 
80  int charon_core_DLL_PUBLIC remove(const std::string& file);
81 
87  const std::string& oldFile, const std::string& newFile);
88 
90 
94  std::string charon_core_DLL_PUBLIC readFile(const std::string & fName);
95 }
96 
97 #endif // _FileTool_H_
std::vector< std::string > charon_core_DLL_PUBLIC getFilesWithSuffix(std::string suffix)
Search files with given suffix.
Definition: FileTool.cpp:104
bool charon_core_DLL_PUBLIC exists(const std::string &file)
Check if file exists.
Definition: FileTool.cpp:154
int charon_core_DLL_PUBLIC makePath(std::string &path)
This function creates all directories contained in path provided they do not already exist...
Definition: FileTool.cpp:71
int charon_core_DLL_PUBLIC changeDir(const std::string &dir)
Change current working directory.
Definition: FileTool.cpp:91
std::string charon_core_DLL_PUBLIC readFile(const std::string &fName)
read file content into std::string
Definition: FileTool.cpp:167
#define charon_core_DLL_PUBLIC
Preprocessor macro to define this class/function as public visible, i.e.
Definition: DllEx.h:82
std::string charon_core_DLL_PUBLIC getCurrentDir()
Get current working directory.
Definition: FileTool.cpp:95
Dynamic library API import/export prprocessor macros.
const char charon_core_DLL_PUBLIC slash
Slash of current operating system ("/" or "\")
Definition: FileTool.cpp:68
void charon_core_DLL_PUBLIC slashConvert(std::string &src)
Convert unix to windows paths and reversed.
Definition: FileTool.cpp:145
int charon_core_DLL_PUBLIC makeDir(const std::string &dir)
Create a new directory using MODE 711 (in unix)
Definition: FileTool.cpp:87
int charon_core_DLL_PUBLIC rename(const std::string &oldFile, const std::string &newFile)
Rename file.
Definition: FileTool.cpp:163