-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdefaults.h
More file actions
38 lines (30 loc) · 962 Bytes
/
defaults.h
File metadata and controls
38 lines (30 loc) · 962 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#ifndef DEFAULTS_H
#define DEFAULTS_H
#include <string>
#include <cstdlib>
#include <sys/stat.h>
// Default directory: $HOME/.z-vector-search/
// Default store: $HOME/.z-vector-search/store.db
// Default model: $HOME/.z-vector-search/model.gguf
inline std::string get_default_dir() {
const char *home = getenv("HOME");
if (!home) home = ".";
return std::string(home) + "/.z-vector-search";
}
inline std::string get_default_store() {
return get_default_dir() + "/store.db";
}
inline std::string get_default_model() {
return get_default_dir() + "/model.gguf";
}
inline std::string get_default_ibm_messages_db() {
return get_default_dir() + "/ibm-messages.db";
}
// Ensure the default directory exists. Returns true on success.
inline bool ensure_default_dir() {
std::string dir = get_default_dir();
struct stat st;
if (stat(dir.c_str(), &st) == 0) return true;
return mkdir(dir.c_str(), 0755) == 0;
}
#endif