mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-03-03 07:29:23 +00:00
redbean: allow symlinks for -D path (#372)
Previously ProgramDirectory called isdirectory which returns false for symlinks. instead just check directory with stat, and allow user to pass `-D /tmp/foo/`, where /tmp/foo might be a symlink.
This commit is contained in:
parent
5e8ae2d5bc
commit
f78f2fcac3
1 changed files with 8 additions and 4 deletions
|
@ -938,12 +938,16 @@ static bool HasString(struct Strings *l, const char *s, size_t n) {
|
|||
static void ProgramDirectory(const char *path) {
|
||||
char *s;
|
||||
size_t n;
|
||||
struct stat st;
|
||||
|
||||
if(stat(path, &st) == -1 || !S_ISDIR(st.st_mode)) {
|
||||
DIEF("(cfg) error: not a directory: %`'s", path);
|
||||
}
|
||||
|
||||
s = strdup(path);
|
||||
n = strlen(s);
|
||||
while (n && (s[n - 1] == '/' || s[n - 1] == '\\')) s[--n] = 0;
|
||||
if (!n || !isdirectory(s)) {
|
||||
DIEF("(cfg) error: not a directory: %`'s", s);
|
||||
}
|
||||
|
||||
INFOF("(cfg) program directory: %s", s);
|
||||
AddString(&stagedirs, s, n);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue