Skip to content

Commit

Permalink
Merge pull request varnamproject#162 from subins2000/vst-lookup-user-…
Browse files Browse the repository at this point in the history
…dir-first

First order preference to user folder for searching VST
  • Loading branch information
navaneeth authored Nov 24, 2020
2 parents 6a81517 + 4cb9ba7 commit 04fab19
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions varnam.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,42 @@ static const char* symbolsFileSearchPath[] = {
const char*
varnam_find_symbols_file_directory()
{
char *tmp;
strbuf *user_path;
int i;

if (varnam_symbols_dir != NULL && is_directory(strbuf_to_s (varnam_symbols_dir))) {
return strbuf_to_s(varnam_symbols_dir);
}

user_path = strbuf_init (20);

#if defined(WIN32) || defined(_WIN32) || defined(__WIN32)
tmp = getenv ("APPDATA");
if (tmp != NULL) {
strbuf_addf (user_path, "%s\\varnam\\vst\\", tmp);
}
#else
tmp = getenv ("XDG_DATA_HOME");
if (tmp == NULL) {
tmp = getenv ("HOME");
if (tmp != NULL) {
strbuf_addf (user_path, "%s/.local/share/varnam/vst/", tmp);
}
}
else {
strbuf_addf (user_path, "%s/varnam/vst/", tmp);
}
#endif

if (!strbuf_is_blank (user_path)) {
if (is_path_exists (strbuf_to_s (user_path))) {
if (is_directory (strbuf_to_s (user_path))) {
return strbuf_to_s (user_path);
}
}
}

for (i = 0; i < ARRAY_SIZE (symbolsFileSearchPath); i++) {
if (is_directory (symbolsFileSearchPath[i]))
return symbolsFileSearchPath[i];
Expand Down

0 comments on commit 04fab19

Please sign in to comment.