sd: sync to master-417-43a70e8 (#1889)

* sd: sync to master-417-43a70e8

* fix sdmain build

* switch to upstream apply_loras()

* refactor u8 path conversions and add it to the gguf reader
This commit is contained in:
Wagner Bruna
2025-12-16 05:16:48 -03:00
committed by GitHub
parent bca0258c2a
commit 78bbe89956
22 changed files with 2462 additions and 1842 deletions
+7 -30
View File
@@ -3,6 +3,7 @@
#include <cmath>
#include <codecvt>
#include <cstdarg>
#include <filesystem>
#include <fstream>
#include <locale>
#include <regex>
@@ -98,18 +99,9 @@ bool is_directory(const std::string& path) {
return (attributes != INVALID_FILE_ATTRIBUTES && (attributes & FILE_ATTRIBUTE_DIRECTORY));
}
std::string get_full_path(const std::string& dir, const std::string& filename) {
std::string full_path = dir + "\\" + filename;
WIN32_FIND_DATA find_file_data;
HANDLE hFind = FindFirstFile(full_path.c_str(), &find_file_data);
if (hFind != INVALID_HANDLE_VALUE) {
FindClose(hFind);
return full_path;
} else {
return "";
}
std::string sd_get_u8path(const std::string& file_path)
{
return std::filesystem::u8path(file_path).string();
}
#else // Unix
@@ -126,24 +118,9 @@ bool is_directory(const std::string& path) {
return (stat(path.c_str(), &buffer) == 0 && S_ISDIR(buffer.st_mode));
}
// TODO: add windows version
std::string get_full_path(const std::string& dir, const std::string& filename) {
DIR* dp = opendir(dir.c_str());
if (dp != nullptr) {
struct dirent* entry;
while ((entry = readdir(dp)) != nullptr) {
if (strcasecmp(entry->d_name, filename.c_str()) == 0) {
closedir(dp);
return dir + "/" + entry->d_name;
}
}
closedir(dp);
}
return "";
std::string sd_get_u8path(const std::string& file_path)
{
return std::filesystem::path(file_path).string();
}
#endif