Signed-off-by: Adrien Gallouët <redacted>
#include <windows.h>
#else
#define HOME_DIR "HOME"
+#include <unistd.h>
+#include <pwd.h>
#endif
namespace hf_cache {
return entry.path.empty() ? base : base / entry.path;
}
}
+#ifndef _WIN32
+ const struct passwd * pw = getpwuid(getuid());
+
+ if (pw->pw_dir && *pw->pw_dir) {
+ return fs::path(pw->pw_dir) / ".cache" / "huggingface" / "hub";
+ }
+#endif
throw std::runtime_error("Failed to determine HF cache directory");
}();