common utils headers
More...
Go to the source code of this file.
common utils headers
- Author
- Alee Amini (alee@.nosp@m.hype.nosp@m.rdbg..nosp@m.org)
-
Sina Karvandi (sina@.nosp@m.hype.nosp@m.rdbg..nosp@m.org)
- Version
- 0.1
- Date
- 2021-06-10
- Copyright
- This project is released under the GNU Public License v3.
◆ CreateDirectoryRecursive()
BOOLEAN CreateDirectoryRecursive |
( |
const std::string & | Path | ) |
|
create a directory recursively
- Parameters
-
- Returns
- BOOLEAN
55{
56 size_t Pos = 0;
57 do
58 {
59 Pos = Path.find_first_of("\\/", Pos + 1);
60 CreateDirectoryA(Path.substr(0, Pos).c_str(), NULL);
61
62 } while (Pos != std::string::npos && Pos <= Path.size());
63
66
68}
#define TRUE
Definition BasicTypes.h:55
#define FALSE
Definition BasicTypes.h:54
BOOLEAN IsDirExists(const std::string &DirPath)
check if a path exist or not
Definition common-utils.cpp:34
◆ IsDirExists()
BOOLEAN IsDirExists |
( |
const std::string & | DirPath | ) |
|
check if a path exist or not
- Parameters
-
- Returns
- BOOLEAN shows whether the file exist or not
35{
36 DWORD Ftyp = GetFileAttributesA(DirPath.c_str());
37 if (Ftyp == INVALID_FILE_ATTRIBUTES)
39
40 if (Ftyp & FILE_ATTRIBUTE_DIRECTORY)
42
44}
unsigned long DWORD
Definition BasicTypes.h:22
◆ IsFileExists()
BOOLEAN IsFileExists |
( |
const std::string & | FileName | ) |
|
check if a file exist or not
- Parameters
-
- Returns
- BOOLEAN shows whether the file exist or not
23{
24 struct stat buffer;
25 return (stat(FileName.c_str(), &buffer) == 0);
26}
◆ Split()
const std::vector< std::string > Split |
( |
const std::string & | s, |
|
|
const char & | c ) |
general split command
- Parameters
-
s | target string |
c | splitter (delimiter) |
- Returns
- const vector<string>
79{
80 string buff {""};
81 vector<string> v;
82
83 for (auto n : s)
84 {
85 if (n != c)
86 buff += n;
87 else if (n == c && !buff.empty())
88 {
89 v.push_back(buff);
90 buff.clear();
91 }
92 }
93 if (!buff.empty())
94 v.push_back(buff);
95
96 return v;
97}