mirror of
https://github.com/korenkonder/ReDIVA.git
synced 2026-10-12 09:08:11 +03:00
Temp commit. Sound
This commit is contained in:
+137
-270
@@ -9,7 +9,7 @@
|
||||
bool path_check_path_exists(const char* path) {
|
||||
wchar_t* path_temp = utf8_to_utf16(path);
|
||||
DWORD ftyp = GetFileAttributesW(path_temp);
|
||||
free(path_temp);
|
||||
free_def(path_temp);
|
||||
if (ftyp == INVALID_FILE_ATTRIBUTES)
|
||||
return false;
|
||||
else
|
||||
@@ -27,7 +27,7 @@ bool path_check_path_exists(const wchar_t* path) {
|
||||
bool path_check_file_exists(const char* path) {
|
||||
wchar_t* path_temp = utf8_to_utf16(path);
|
||||
DWORD ftyp = GetFileAttributesW(path_temp);
|
||||
free(path_temp);
|
||||
free_def(path_temp);
|
||||
if (ftyp == INVALID_FILE_ATTRIBUTES)
|
||||
return false;
|
||||
else
|
||||
@@ -45,7 +45,7 @@ bool path_check_file_exists(const wchar_t* path) {
|
||||
bool path_check_directory_exists(const char* path) {
|
||||
wchar_t* path_temp = utf8_to_utf16(path);
|
||||
DWORD ftyp = GetFileAttributesW(path_temp);
|
||||
free(path_temp);
|
||||
free_def(path_temp);
|
||||
if (ftyp == INVALID_FILE_ATTRIBUTES)
|
||||
return false;
|
||||
else
|
||||
@@ -60,136 +60,89 @@ bool path_check_directory_exists(const wchar_t* path) {
|
||||
return ftyp & FILE_ATTRIBUTE_DIRECTORY ? true : false;
|
||||
}
|
||||
|
||||
void path_get_files(std::vector<std::string>* files, const char* path) {
|
||||
files->clear();
|
||||
files->shrink_to_fit();
|
||||
|
||||
std::vector<std::string> path_get_files(const char* path) {
|
||||
wchar_t* dir_temp = utf8_to_utf16(path);
|
||||
size_t dir_len = utf16_length(dir_temp);
|
||||
if (!dir_temp)
|
||||
return;
|
||||
return {};
|
||||
|
||||
wchar_t* dir;
|
||||
if (dir_temp[dir_len - 1] != L'\\') {
|
||||
dir = force_malloc_s(wchar_t, dir_len + 3);
|
||||
memcpy(dir, dir_temp, sizeof(wchar_t) * dir_len);
|
||||
dir[dir_len] = L'\\';
|
||||
dir[dir_len + 1] = L'*';
|
||||
dir[dir_len + 2] = 0;
|
||||
}
|
||||
else {
|
||||
dir = force_malloc_s(wchar_t, dir_len + 2);
|
||||
memcpy(dir, dir_temp, sizeof(wchar_t) * dir_len);
|
||||
dir[dir_len] = L'*';
|
||||
dir[dir_len + 1] = 0;
|
||||
}
|
||||
free(dir_temp);
|
||||
std::wstring dir;
|
||||
dir.assign(dir_temp, dir_len);
|
||||
if (dir.size() && dir.back() != L'\\')
|
||||
dir.push_back(L'\\');
|
||||
dir.push_back(L'*');
|
||||
free_def(dir_temp);
|
||||
|
||||
WIN32_FIND_DATAW fdata;
|
||||
memset(&fdata, 0, sizeof(WIN32_FIND_DATAW));
|
||||
HANDLE h = FindFirstFileW(dir, &fdata);
|
||||
if (h == INVALID_HANDLE_VALUE) {
|
||||
free(dir);
|
||||
return;
|
||||
}
|
||||
HANDLE h = FindFirstFileW(dir.c_str(), &fdata);
|
||||
if (h == INVALID_HANDLE_VALUE)
|
||||
return {};
|
||||
|
||||
std::vector<std::string> files;
|
||||
do {
|
||||
if (fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||
continue;
|
||||
|
||||
char* file_temp = utf16_to_utf8(fdata.cFileName);
|
||||
if (file_temp)
|
||||
files->push_back(file_temp);
|
||||
free(file_temp);
|
||||
if (file_temp) {
|
||||
files.push_back(file_temp);
|
||||
free(file_temp);
|
||||
}
|
||||
} while (FindNextFileW(h, &fdata));
|
||||
FindClose(h);
|
||||
free(dir);
|
||||
return files;
|
||||
}
|
||||
|
||||
void path_get_files(std::vector<std::wstring>* files, const wchar_t* path) {
|
||||
files->clear();
|
||||
files->shrink_to_fit();
|
||||
|
||||
std::vector<std::wstring> path_get_files(const wchar_t* path) {
|
||||
size_t dir_len = utf16_length(path);
|
||||
|
||||
wchar_t* dir;
|
||||
if (path[dir_len - 1] != L'\\') {
|
||||
dir = force_malloc_s(wchar_t, dir_len + 3);
|
||||
memcpy(dir, path, sizeof(wchar_t) * dir_len);
|
||||
dir[dir_len] = L'\\';
|
||||
dir[dir_len + 1] = L'*';
|
||||
dir[dir_len + 2] = 0;
|
||||
}
|
||||
else {
|
||||
dir = force_malloc_s(wchar_t, dir_len + 2);
|
||||
memcpy(dir, path, sizeof(wchar_t) * dir_len);
|
||||
dir[dir_len] = L'*';
|
||||
dir[dir_len + 1] = 0;
|
||||
}
|
||||
std::wstring dir;
|
||||
dir.assign(path, dir_len);
|
||||
if (dir.size() && dir.back() != L'\\')
|
||||
dir.push_back(L'\\');
|
||||
dir.push_back(L'*');
|
||||
|
||||
WIN32_FIND_DATAW fdata;
|
||||
memset(&fdata, 0, sizeof(WIN32_FIND_DATAW));
|
||||
HANDLE h = FindFirstFileW(dir, &fdata);
|
||||
if (h == INVALID_HANDLE_VALUE) {
|
||||
free(dir);
|
||||
return;
|
||||
}
|
||||
HANDLE h = FindFirstFileW(dir.c_str(), &fdata);
|
||||
if (h == INVALID_HANDLE_VALUE)
|
||||
return {};
|
||||
|
||||
std::vector<std::wstring> files;
|
||||
do {
|
||||
if (fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||
continue;
|
||||
|
||||
std::wstring file = std::wstring(fdata.cFileName);
|
||||
files->push_back(file);
|
||||
files.push_back(fdata.cFileName);
|
||||
} while (FindNextFileW(h, &fdata));
|
||||
FindClose(h);
|
||||
free(dir);
|
||||
return files;
|
||||
}
|
||||
|
||||
void path_get_directories(std::vector<std::string>* directories,
|
||||
const char* path, char** exclude_list, size_t exclude_count) {
|
||||
directories->clear();
|
||||
directories->shrink_to_fit();
|
||||
|
||||
std::vector<std::string> path_get_directories(
|
||||
const char* path, const char** exclude_list, size_t exclude_count) {
|
||||
wchar_t* dir_temp = utf8_to_utf16(path);
|
||||
size_t dir_len = utf16_length(dir_temp);
|
||||
if (!dir_temp)
|
||||
return;
|
||||
return {};
|
||||
|
||||
wchar_t* dir;
|
||||
wchar_t* temp;
|
||||
if (dir_temp[dir_len - 1] != L'\\') {
|
||||
dir = force_malloc_s(wchar_t, dir_len + 3);
|
||||
memcpy(dir, dir_temp, sizeof(wchar_t) * dir_len);
|
||||
dir[dir_len] = L'\\';
|
||||
dir[dir_len + 1] = L'*';
|
||||
dir[dir_len + 2] = 0;
|
||||
|
||||
temp = force_malloc_s(wchar_t, dir_len + 2 + MAX_PATH);
|
||||
memcpy(temp, dir_temp, sizeof(wchar_t) * dir_len);
|
||||
temp[dir_len] = L'\\';
|
||||
dir_len++;
|
||||
}
|
||||
else {
|
||||
dir = force_malloc_s(wchar_t, dir_len + 2);
|
||||
memcpy(dir, dir_temp, sizeof(wchar_t) * dir_len);
|
||||
dir[dir_len] = L'*';
|
||||
dir[dir_len + 1] = 0;
|
||||
|
||||
temp = force_malloc_s(wchar_t, dir_len + 1 + MAX_PATH);
|
||||
memcpy(temp, dir_temp, sizeof(wchar_t) * dir_len);
|
||||
}
|
||||
free(dir_temp);
|
||||
std::wstring dir;
|
||||
std::wstring temp;
|
||||
dir.assign(dir_temp, dir_len);
|
||||
if (dir.size() && dir.back() != L'\\')
|
||||
dir.push_back(L'\\');
|
||||
temp.assign(dir);
|
||||
dir.push_back(L'*');
|
||||
free_def(dir_temp);
|
||||
|
||||
WIN32_FIND_DATAW fdata;
|
||||
memset(&fdata, 0, sizeof(WIN32_FIND_DATAW));
|
||||
HANDLE h = FindFirstFileW(dir, &fdata);
|
||||
if (h == INVALID_HANDLE_VALUE) {
|
||||
free(dir);
|
||||
free(temp);
|
||||
return;
|
||||
}
|
||||
HANDLE h = FindFirstFileW(dir.c_str(), &fdata);
|
||||
if (h == INVALID_HANDLE_VALUE)
|
||||
return {};
|
||||
|
||||
std::vector<std::string> directories;
|
||||
do {
|
||||
if (~fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||
continue;
|
||||
@@ -199,17 +152,16 @@ void path_get_directories(std::vector<std::string>* directories,
|
||||
|
||||
if (exclude_list && exclude_count) {
|
||||
size_t len = utf16_length(fdata.cFileName);
|
||||
memcpy(temp + dir_len, fdata.cFileName, sizeof(wchar_t) * len);
|
||||
temp[dir_len + len] = L'\0';
|
||||
temp.append(fdata.cFileName, len);
|
||||
std::string temp_utf8 = utf16_to_utf8(temp);
|
||||
|
||||
bool exclude = false;
|
||||
char* temp_utf8 = utf16_to_utf8(temp);
|
||||
for (size_t i = 0; i < exclude_count; i++)
|
||||
if (!str_utils_compare(exclude_list[i], temp_utf8)) {
|
||||
if (!temp_utf8.compare(exclude_list[i])) {
|
||||
exclude = true;
|
||||
break;
|
||||
}
|
||||
free(temp_utf8);
|
||||
temp.resize(temp.size() - len);
|
||||
|
||||
if (exclude)
|
||||
continue;
|
||||
@@ -217,54 +169,32 @@ void path_get_directories(std::vector<std::string>* directories,
|
||||
|
||||
char* directory_temp = utf16_to_utf8(fdata.cFileName);
|
||||
if (directory_temp)
|
||||
directories->push_back(directory_temp);
|
||||
free(directory_temp);
|
||||
directories.push_back(directory_temp);
|
||||
free_def(directory_temp);
|
||||
} while (FindNextFileW(h, &fdata));
|
||||
FindClose(h);
|
||||
free(temp);
|
||||
free(dir);
|
||||
return directories;
|
||||
}
|
||||
|
||||
void path_get_directories(std::vector<std::wstring>* directories,
|
||||
std::vector<std::wstring> path_get_directories(
|
||||
const wchar_t* path, wchar_t** exclude_list, size_t exclude_count) {
|
||||
directories->clear();
|
||||
directories->shrink_to_fit();
|
||||
|
||||
size_t dir_len = utf16_length(path);
|
||||
|
||||
wchar_t* dir;
|
||||
wchar_t* temp;
|
||||
if (path[dir_len - 1] != L'\\') {
|
||||
dir = force_malloc_s(wchar_t, dir_len + 3);
|
||||
memcpy(dir, path, sizeof(wchar_t) * dir_len);
|
||||
dir[dir_len] = L'\\';
|
||||
dir[dir_len + 1] = L'*';
|
||||
dir[dir_len + 2] = 0;
|
||||
|
||||
temp = force_malloc_s(wchar_t, dir_len + 2 + MAX_PATH);
|
||||
memcpy(temp, path, sizeof(wchar_t) * dir_len);
|
||||
temp[dir_len] = L'\\';
|
||||
dir_len++;
|
||||
}
|
||||
else {
|
||||
dir = force_malloc_s(wchar_t, dir_len + 2);
|
||||
memcpy(dir, path, sizeof(wchar_t) * dir_len);
|
||||
dir[dir_len] = L'*';
|
||||
dir[dir_len + 1] = 0;
|
||||
|
||||
temp = force_malloc_s(wchar_t, dir_len + 1 + MAX_PATH);
|
||||
memcpy(temp, path, sizeof(wchar_t) * dir_len);
|
||||
}
|
||||
std::wstring dir;
|
||||
std::wstring temp;
|
||||
dir.assign(path, dir_len);
|
||||
if (dir.size() && dir.back() != L'\\')
|
||||
dir.push_back(L'\\');
|
||||
temp.assign(dir);
|
||||
dir.push_back(L'*');
|
||||
|
||||
WIN32_FIND_DATAW fdata;
|
||||
memset(&fdata, 0, sizeof(WIN32_FIND_DATAW));
|
||||
HANDLE h = FindFirstFileW(dir, &fdata);
|
||||
if (h == INVALID_HANDLE_VALUE) {
|
||||
free(dir);
|
||||
free(temp);
|
||||
return;
|
||||
}
|
||||
HANDLE h = FindFirstFileW(dir.c_str(), &fdata);
|
||||
if (h == INVALID_HANDLE_VALUE)
|
||||
return {};
|
||||
|
||||
std::vector<std::wstring> directories;
|
||||
do {
|
||||
if (~fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||
continue;
|
||||
@@ -274,71 +204,47 @@ void path_get_directories(std::vector<std::wstring>* directories,
|
||||
|
||||
if (exclude_list && exclude_count) {
|
||||
size_t len = utf16_length(fdata.cFileName);
|
||||
memcpy(temp + dir_len + 1, fdata.cFileName, sizeof(wchar_t) * len);
|
||||
temp[dir_len + 1 + len] = L'\0';
|
||||
temp.append(fdata.cFileName, len);
|
||||
|
||||
bool exclude = false;
|
||||
for (size_t i = 0; i < exclude_count; i++)
|
||||
if (!str_utils_compare(exclude_list[i], temp)) {
|
||||
if (!temp.compare(exclude_list[i])) {
|
||||
exclude = true;
|
||||
break;
|
||||
}
|
||||
temp.resize(temp.size() - len);
|
||||
|
||||
if (exclude)
|
||||
continue;
|
||||
}
|
||||
|
||||
std::wstring directory = std::wstring(fdata.cFileName);
|
||||
directories->push_back(directory);
|
||||
directories.push_back(fdata.cFileName);
|
||||
} while (FindNextFileW(h, &fdata));
|
||||
FindClose(h);
|
||||
free(temp);
|
||||
free(dir);
|
||||
return directories;
|
||||
}
|
||||
|
||||
void path_get_directories_recursive(std::vector<std::string>* directories,
|
||||
const char* path, char** exclude_list, size_t exclude_count) {
|
||||
directories->clear();
|
||||
directories->shrink_to_fit();
|
||||
|
||||
std::vector<std::string> path_get_directories_recursive(
|
||||
const char* path, const char** exclude_list, size_t exclude_count) {
|
||||
wchar_t* dir_temp = utf8_to_utf16(path);
|
||||
size_t dir_len = utf16_length(dir_temp);
|
||||
if (!dir_temp)
|
||||
return;
|
||||
return {};
|
||||
|
||||
wchar_t* dir;
|
||||
wchar_t* temp;
|
||||
if (dir_temp[dir_len - 1] != L'\\') {
|
||||
dir = force_malloc_s(wchar_t, dir_len + 3);
|
||||
memcpy(dir, dir_temp, sizeof(wchar_t) * dir_len);
|
||||
dir[dir_len] = L'\\';
|
||||
dir[dir_len + 1] = L'*';
|
||||
dir[dir_len + 2] = 0;
|
||||
|
||||
temp = force_malloc_s(wchar_t, dir_len + 2 + MAX_PATH);
|
||||
memcpy(temp, dir_temp, sizeof(wchar_t) * dir_len);
|
||||
temp[dir_len] = L'\\';
|
||||
dir_len++;
|
||||
}
|
||||
else {
|
||||
dir = force_malloc_s(wchar_t, dir_len + 2);
|
||||
memcpy(dir, dir_temp, sizeof(wchar_t) * dir_len);
|
||||
dir[dir_len] = L'*';
|
||||
dir[dir_len + 1] = 0;
|
||||
|
||||
temp = force_malloc_s(wchar_t, dir_len + 1 + MAX_PATH);
|
||||
memcpy(temp, dir_temp, sizeof(wchar_t) * dir_len);
|
||||
}
|
||||
free(dir_temp);
|
||||
std::wstring dir;
|
||||
std::wstring temp;
|
||||
dir.assign(dir_temp, dir_len);
|
||||
if (dir.size() && dir.back() != L'\\')
|
||||
dir.push_back(L'\\');
|
||||
temp.assign(dir);
|
||||
dir.push_back(L'*');
|
||||
free_def(dir_temp);
|
||||
|
||||
WIN32_FIND_DATAW fdata;
|
||||
memset(&fdata, 0, sizeof(WIN32_FIND_DATAW));
|
||||
HANDLE h = FindFirstFileW(dir, &fdata);
|
||||
if (h == INVALID_HANDLE_VALUE) {
|
||||
free(dir);
|
||||
free(temp);
|
||||
return;
|
||||
}
|
||||
HANDLE h = FindFirstFileW(dir.c_str(), &fdata);
|
||||
if (h == INVALID_HANDLE_VALUE)
|
||||
return {};
|
||||
|
||||
std::vector<std::string> temp_vec;
|
||||
do {
|
||||
@@ -350,17 +256,16 @@ void path_get_directories_recursive(std::vector<std::string>* directories,
|
||||
|
||||
if (exclude_list && exclude_count) {
|
||||
size_t len = utf16_length(fdata.cFileName);
|
||||
memcpy(temp + dir_len + 1, fdata.cFileName, sizeof(wchar_t) * len);
|
||||
temp[dir_len + 1 + len] = L'\0';
|
||||
temp.append(fdata.cFileName, len);
|
||||
std::string temp_utf8 = utf16_to_utf8(temp);
|
||||
|
||||
bool exclude = false;
|
||||
char* temp_utf8 = utf16_to_utf8(temp);
|
||||
for (size_t i = 0; i < exclude_count; i++)
|
||||
if (!str_utils_compare(exclude_list[i], temp_utf8)) {
|
||||
if (!temp_utf8.compare(exclude_list[i])) {
|
||||
exclude = true;
|
||||
break;
|
||||
}
|
||||
free(temp_utf8);
|
||||
temp.resize(temp.size() - len);
|
||||
|
||||
if (exclude)
|
||||
continue;
|
||||
@@ -368,11 +273,9 @@ void path_get_directories_recursive(std::vector<std::string>* directories,
|
||||
|
||||
char* directory_temp = utf16_to_utf8(fdata.cFileName);
|
||||
temp_vec.push_back(directory_temp);
|
||||
free(directory_temp);
|
||||
free_def(directory_temp);
|
||||
} while (FindNextFileW(h, &fdata));
|
||||
FindClose(h);
|
||||
free(temp);
|
||||
free(dir);
|
||||
|
||||
size_t max_len = 0;
|
||||
for (std::string& i : temp_vec) {
|
||||
@@ -381,17 +284,17 @@ void path_get_directories_recursive(std::vector<std::string>* directories,
|
||||
max_len = len;
|
||||
}
|
||||
|
||||
size_t path_length = utf8_length(path);
|
||||
char* path_temp = force_malloc_s(char, path_length + max_len + 2);
|
||||
memcpy(path_temp, path, path_length);
|
||||
path_temp[path_length] = '\\';
|
||||
std::vector<std::string> directories;
|
||||
std::string path_temp;
|
||||
path_temp.assign(path);
|
||||
path_temp += '\\';
|
||||
for (std::string& i : temp_vec) {
|
||||
memcpy(&path_temp[path_length + 1], i.c_str(), i.size() + 1);
|
||||
path_temp.append(i);
|
||||
std::vector<std::string> temp = path_get_directories_recursive(
|
||||
path_temp.c_str(), exclude_list, exclude_count);
|
||||
path_temp.resize(path_temp.size() - i.size());
|
||||
|
||||
std::vector<std::string> temp;
|
||||
path_get_directories_recursive(&temp, path_temp, exclude_list, exclude_count);
|
||||
|
||||
directories->push_back(i);
|
||||
directories.push_back(i);
|
||||
|
||||
if (temp.size() < 1)
|
||||
continue;
|
||||
@@ -403,62 +306,34 @@ void path_get_directories_recursive(std::vector<std::string>* directories,
|
||||
max_len = len;
|
||||
}
|
||||
|
||||
size_t sub_path_length = i.size();
|
||||
char* sub_path_temp = force_malloc_s(char, sub_path_length + max_len + 1);
|
||||
if (sub_path_temp) {
|
||||
memcpy(sub_path_temp, i.c_str(), sub_path_length);
|
||||
sub_path_temp[sub_path_length] = '\\';
|
||||
for (std::string& j : temp) {
|
||||
memcpy(&sub_path_temp[sub_path_length + 1], j.c_str(), j.size());
|
||||
|
||||
std::string directory = std::string(sub_path_temp, sub_path_length + 1 + j.size());
|
||||
temp_vec.push_back(directory);
|
||||
}
|
||||
if (i.size()) {
|
||||
std::string sub_path_temp;
|
||||
sub_path_temp.assign(i);
|
||||
sub_path_temp += '\\';
|
||||
for (std::string& j : temp)
|
||||
directories.push_back(sub_path_temp + j);
|
||||
}
|
||||
free(sub_path_temp);
|
||||
}
|
||||
free(path_temp);
|
||||
return directories;
|
||||
}
|
||||
|
||||
void path_get_directories_recursive(std::vector<std::wstring>* directories,
|
||||
const wchar_t* path, wchar_t** exclude_list, size_t exclude_count) {
|
||||
directories->clear();
|
||||
directories->shrink_to_fit();
|
||||
|
||||
std::vector<std::wstring> path_get_directories_recursive(
|
||||
const wchar_t* path, const wchar_t** exclude_list, size_t exclude_count) {
|
||||
size_t dir_len = utf16_length(path);
|
||||
|
||||
wchar_t* dir;
|
||||
wchar_t* temp;
|
||||
if (path[dir_len - 1] != L'\\') {
|
||||
dir = force_malloc_s(wchar_t, dir_len + 3);
|
||||
memcpy(dir, path, sizeof(wchar_t) * dir_len);
|
||||
dir[dir_len] = L'\\';
|
||||
dir[dir_len + 1] = L'*';
|
||||
dir[dir_len + 2] = 0;
|
||||
|
||||
temp = force_malloc_s(wchar_t, dir_len + 2 + MAX_PATH);
|
||||
memcpy(temp, path, sizeof(wchar_t) * dir_len);
|
||||
temp[dir_len] = L'\\';
|
||||
dir_len++;
|
||||
}
|
||||
else {
|
||||
dir = force_malloc_s(wchar_t, dir_len + 2);
|
||||
memcpy(dir, path, sizeof(wchar_t) * dir_len);
|
||||
dir[dir_len] = L'*';
|
||||
dir[dir_len + 1] = 0;
|
||||
|
||||
temp = force_malloc_s(wchar_t, dir_len + 1 + MAX_PATH);
|
||||
memcpy(temp, path, sizeof(wchar_t) * dir_len);
|
||||
}
|
||||
std::wstring dir;
|
||||
std::wstring temp;
|
||||
dir.assign(path, dir_len);
|
||||
if (dir.size() && dir.back() != L'\\')
|
||||
dir.push_back(L'\\');
|
||||
temp.assign(dir);
|
||||
dir.push_back(L'*');
|
||||
|
||||
WIN32_FIND_DATAW fdata;
|
||||
memset(&fdata, 0, sizeof(WIN32_FIND_DATAW));
|
||||
HANDLE h = FindFirstFileW(dir, &fdata);
|
||||
if (h == INVALID_HANDLE_VALUE) {
|
||||
free(dir);
|
||||
free(temp);
|
||||
return;
|
||||
}
|
||||
HANDLE h = FindFirstFileW(dir.c_str(), &fdata);
|
||||
if (h == INVALID_HANDLE_VALUE)
|
||||
return {};
|
||||
|
||||
std::vector<std::wstring> temp_vec;
|
||||
do {
|
||||
@@ -470,15 +345,15 @@ void path_get_directories_recursive(std::vector<std::wstring>* directories,
|
||||
|
||||
if (exclude_list && exclude_count) {
|
||||
size_t len = utf16_length(fdata.cFileName);
|
||||
memcpy(temp + dir_len + 1, fdata.cFileName, sizeof(wchar_t) * len);
|
||||
temp[dir_len + 1 + len] = L'\0';
|
||||
temp.append(fdata.cFileName, len);
|
||||
|
||||
bool exclude = false;
|
||||
for (size_t i = 0; i < exclude_count; i++)
|
||||
if (!str_utils_compare(exclude_list[i], temp)) {
|
||||
if (!temp.compare(exclude_list[i])) {
|
||||
exclude = true;
|
||||
break;
|
||||
}
|
||||
temp.resize(temp.size() - len);
|
||||
|
||||
if (exclude)
|
||||
continue;
|
||||
@@ -488,8 +363,6 @@ void path_get_directories_recursive(std::vector<std::wstring>* directories,
|
||||
temp_vec.push_back(directory);
|
||||
} while (FindNextFileW(h, &fdata));
|
||||
FindClose(h);
|
||||
free(temp);
|
||||
free(dir);
|
||||
|
||||
size_t max_len = 0;
|
||||
for (std::wstring& i : temp_vec) {
|
||||
@@ -498,17 +371,17 @@ void path_get_directories_recursive(std::vector<std::wstring>* directories,
|
||||
max_len = len;
|
||||
}
|
||||
|
||||
size_t path_length = utf16_length(path);
|
||||
wchar_t* path_temp = force_malloc_s(wchar_t, path_length + max_len + 2);
|
||||
memcpy(path_temp, path, sizeof(wchar_t) * path_length);
|
||||
path_temp[path_length] = '\\';
|
||||
std::vector<std::wstring> directories;
|
||||
std::wstring path_temp;
|
||||
path_temp.assign(path);
|
||||
path_temp.push_back(L'\\');
|
||||
for (std::wstring& i : temp_vec) {
|
||||
memcpy(&path_temp[path_length + 1], i.c_str(), sizeof(wchar_t) * (i.size() + 1));
|
||||
path_temp.append(i);
|
||||
std::vector<std::wstring> temp = path_get_directories_recursive(
|
||||
path_temp.c_str(), exclude_list, exclude_count);
|
||||
path_temp.resize(path_temp.size() - i.size());
|
||||
|
||||
std::vector<std::wstring> temp;
|
||||
path_get_directories_recursive(&temp, path_temp, exclude_list, exclude_count);
|
||||
|
||||
directories->push_back(i);
|
||||
directories.push_back(i);
|
||||
|
||||
if (temp.size() < 1)
|
||||
continue;
|
||||
@@ -520,19 +393,13 @@ void path_get_directories_recursive(std::vector<std::wstring>* directories,
|
||||
max_len = len;
|
||||
}
|
||||
|
||||
size_t sub_path_length = i.size();
|
||||
wchar_t* sub_path_temp = force_malloc_s(wchar_t, sub_path_length + max_len + 1);
|
||||
if (sub_path_temp) {
|
||||
memcpy(sub_path_temp, i.c_str(), sizeof(wchar_t) * sub_path_length);
|
||||
sub_path_temp[sub_path_length] = '\\';
|
||||
for (std::wstring& j : temp) {
|
||||
memcpy(&sub_path_temp[sub_path_length + 1], j.c_str(), sizeof(wchar_t) * j.size());
|
||||
|
||||
std::wstring directory = std::wstring(sub_path_temp, sub_path_length + 1 + j.size());
|
||||
directories->push_back(directory);
|
||||
}
|
||||
if (i.size()) {
|
||||
std::wstring sub_path_temp;
|
||||
sub_path_temp.assign(i);
|
||||
sub_path_temp.push_back(L'\\');
|
||||
for (std::wstring& j : temp)
|
||||
directories.push_back(sub_path_temp + j);
|
||||
}
|
||||
free(sub_path_temp);
|
||||
}
|
||||
free(path_temp);
|
||||
return directories;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user