some little update
This commit is contained in:
1 parent
716e7df03a
commit
05dc4c299f
4 files changed
+10
-5
No files matched your search
@@ -71,7 +71,7 @@ static void list_files(int ssl, char *directory) {
|
||||
snprintf(path, sizeof(path), "%s/%s", directory, entry->d_name);
|
||||
// if (stat(path, &st) < 0 || S_ISDIR(st.st_mode)) continue;
|
||||
pos += snprintf(buf + pos, sizeof(buf) - pos,
|
||||
"<li><a href=\"%s/%s\">%s</a></li>", directory, entry->d_name, entry->d_name);
|
||||
"<li><a href=\"/%s/%s\">%s</a></li>", directory, entry->d_name, entry->d_name);
|
||||
}
|
||||
closedir(dir);
|
||||
|
||||
|
||||
+1
-1
@@ -65,7 +65,7 @@ static void list_files(int ssl, char *directory) {
|
||||
snprintf(path, sizeof(path), "%s/%s", directory, entry->d_name);
|
||||
// if (stat(path, &st) < 0 || S_ISDIR(st.st_mode)) continue;
|
||||
pos += snprintf(buf + pos, sizeof(buf) - pos,
|
||||
"<li><a href=\"%s/%s\">%s</a></li>", directory, entry->d_name, entry->d_name);
|
||||
"<li><a href=\"/%s/%s\">%s</a></li>", directory, entry->d_name, entry->d_name);
|
||||
}
|
||||
closedir(dir);
|
||||
|
||||
|
||||
+7
-2
@@ -73,7 +73,7 @@ static void list_files(SSL *ssl, char *directory) {
|
||||
char path[MAX_PATH];
|
||||
snprintf(path, sizeof(path), "%s/%s", directory, entry->d_name);
|
||||
pos += snprintf(buf + pos, sizeof(buf) - pos,
|
||||
"<li><a href=\"%s/%s\">%s</a></li>", directory, entry->d_name, entry->d_name);
|
||||
"<li><a href=\"/%s/%s\">%s</a></li>", directory, entry->d_name, entry->d_name);
|
||||
}
|
||||
closedir(dir);
|
||||
|
||||
@@ -129,7 +129,12 @@ void *handle_request(void *param) {
|
||||
|
||||
char file_path[MAX_PATH];
|
||||
snprintf(file_path, sizeof(file_path), "%s/%s", ROOT_DIR, path[0] == '/' ? path + 1 : path);
|
||||
|
||||
if (file_path[0] == "." && file_path[1] == "/") {
|
||||
for (int i = 2; i < MAX_PATH -1; i++) {
|
||||
file_path[i-2] = file_path[i];
|
||||
}
|
||||
}
|
||||
https://localhost:8081/home/tola/Pictures/home/tola/Pictures/wallpaper/3d-tech.jpg
|
||||
struct stat st;
|
||||
if (stat(file_path, &st) < 0 || S_ISDIR(st.st_mode)) {
|
||||
if (S_ISDIR(st.st_mode)) {
|
||||
|
||||
+1
-1
@@ -67,7 +67,7 @@ static void list_files(SSL *ssl, char *directory) {
|
||||
snprintf(path, sizeof(path), "%s/%s", directory, entry->d_name);
|
||||
// if (stat(path, &st) < 0 || S_ISDIR(st.st_mode)) continue;
|
||||
pos += snprintf(buf + pos, sizeof(buf) - pos,
|
||||
"<li><a href=\"%s/%s\">%s</a></li>", directory, entry->d_name, entry->d_name);
|
||||
"<li><a href=\"/%s/%s\">%s</a></li>", directory, entry->d_name, entry->d_name);
|
||||
}
|
||||
closedir(dir);
|
||||
|
||||
|
||||
Reference in new issue
Block a user