This repository was archived by the owner on Jul 4, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed
Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change 66#include < drogon/HttpResponse.h>
77#include < iostream>
88#include < ostream>
9+ // Include platform-specific headers
10+ #ifdef _WIN32
11+ #include < windows.h>
12+ #else
13+ #include < dirent.h>
14+ #endif
915
1016namespace nitro_utils {
1117
18+ inline std::string models_folder = " ./models" ;
19+
20+ inline std::vector<std::string> listFilesInDir (const std::string &path) {
21+ std::vector<std::string> files;
22+
23+ #ifdef _WIN32
24+ // Windows-specific code
25+ WIN32_FIND_DATA findFileData;
26+ HANDLE hFind = FindFirstFile ((path + " \\ *" ).c_str (), &findFileData);
27+
28+ if (hFind != INVALID_HANDLE_VALUE) {
29+ do {
30+ if (!(findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
31+ files.push_back (findFileData.cFileName );
32+ }
33+ } while (FindNextFile (hFind, &findFileData) != 0 );
34+ FindClose (hFind);
35+ }
36+ #else
37+ // POSIX-specific code (Linux, Unix, MacOS)
38+ DIR *dir;
39+ struct dirent *ent;
40+
41+ if ((dir = opendir (path.c_str ())) != NULL ) {
42+ while ((ent = readdir (dir)) != NULL ) {
43+ if (ent->d_type == DT_REG) { // Check if it's a regular file
44+ files.push_back (ent->d_name );
45+ }
46+ }
47+ closedir (dir);
48+ }
49+ #endif
50+
51+ return files;
52+ }
53+
1254inline std::string rtrim (const std::string &str) {
1355 size_t end = str.find_last_not_of (" \n\t " );
1456 return (end == std::string::npos) ? " " : str.substr (0 , end + 1 );
You can’t perform that action at this time.
0 commit comments