951e62e51be267c693098cb824786625e0c06e09
7 std::vector
<std::string
> getFilesInDirectory(std::string folder
) {
8 std::vector
<std::string
> names
;
9 std::string search_path
= folder
+ "/*.*";
11 HANDLE hFind
= ::FindFirstFile(search_path
.c_str(), &fd
);
12 if (hFind
!= INVALID_HANDLE_VALUE
) {
14 if (!(fd
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)) {
15 names
.push_back(folder
+ "\\" + fd
.cFileName
);
17 } while (::FindNextFile(hFind
, &fd
));
20 for (auto && s
: names
) s
= s
.substr(s
.size());
25 std::vector
<std::string
> getFilesInDirectoryRecursive(std::string folder
, std::vector
<std::string
>* vec
= NULL
) {
26 std::vector
<std::string
>* v
= vec
;
28 std::vector
<std::string
> names
;
29 if (v
== NULL
) // First iteration
32 std::string search_path
= folder
+ "/*.*";
34 HANDLE hFind
= ::FindFirstFile(search_path
.c_str(), &fd
);
35 if (hFind
!= INVALID_HANDLE_VALUE
) {
37 if (!(fd
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)) {
38 v
->push_back(folder
+ "\\" + fd
.cFileName
);
41 if ((std::string(fd
.cFileName
) != ".") && (std::string(fd
.cFileName
) != ".."))
42 getFilesInDirectoryRecursive(folder
+ "\\" + fd
.cFileName
, v
);
44 } while (::FindNextFile(hFind
, &fd
));
48 for (auto && s
: names
) s
= s
.substr(folder
.size());
53 void copyFile(std::string src
, std::string dst
) {
54 std::ifstream
_src(src
, std::ios::binary
);
55 std::ofstream
_dst(dst
, std::ios::binary
);
61 bool dirExists(const std::string
& dirName_in
) {
62 DWORD ftyp
= GetFileAttributesA(dirName_in
.c_str());
63 if (ftyp
== INVALID_FILE_ATTRIBUTES
)
64 return false; //something is wrong with your path!
66 if (ftyp
& FILE_ATTRIBUTE_DIRECTORY
)
67 return true; // this is a directory!
69 return false; // this is not a directory!
72 std::string
getDirName(std::string f
) {
73 return f
.substr(0, f
.size() - split(sutil::ReplaceAll(f
, "/", "\\"), '\\').back().size());