This commit is contained in:
+7
-2
@@ -18,7 +18,11 @@ char * file_completion(const char *path) {
|
||||
struct dirent *entry;
|
||||
char directory[128];
|
||||
char predict[128];
|
||||
size_t predict_len;
|
||||
int predict_len = 0;
|
||||
|
||||
if (path[strlen(path) - 1] == '/') {
|
||||
return path;
|
||||
}
|
||||
|
||||
// Find dir name
|
||||
char * last_slash = strrchr(path, '/');
|
||||
@@ -28,12 +32,13 @@ char * file_completion(const char *path) {
|
||||
predict_len = strlen(path) - dir_len - 1;
|
||||
strncpy(predict, last_slash + 1, predict_len);
|
||||
directory[dir_len] = '\0';
|
||||
fprintf(stderr, "%s %s\n", directory, predict);
|
||||
predict[predict_len] = '\0';
|
||||
fprintf(stderr, "%s %s\n", directory, predict);
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
dir = opendir(directory);
|
||||
if (!dir)
|
||||
return NULL;
|
||||
|
||||
Reference in New Issue
Block a user