diff options
author | louie <lshprung@yahoo.com> | 2020-06-26 19:43:29 -0700 |
---|---|---|
committer | louie <lshprung@yahoo.com> | 2020-06-26 19:43:29 -0700 |
commit | 0eb46442f5541f365ebb327375b9e5992194fbd8 (patch) | |
tree | f3dc085d59fbace14ef4f4b5f60e5c4e22596591 /entry.c | |
parent | 7985c945cf11c50559daa8bdb03f9a023deb2da3 (diff) |
Added compatability for spaces in filename
Diffstat (limited to 'entry.c')
-rw-r--r-- | entry.c | 17 |
1 files changed, 14 insertions, 3 deletions
@@ -22,17 +22,28 @@ char *get_epath(ENTRY *e); ENTRY *create_entry(char *new_name, char *new_path){ ENTRY *new; + char adjusted_path[BUF_LEN]; //double check if file exists if(access(new_path, F_OK) == -1){ - printf("Error: Invalid File Name \"%s\"\n", new_path); - return NULL; + //try to adjust the path, in case of lingering quotes + strcpy(adjusted_path, &new_path[1]); + adjusted_path[strlen(adjusted_path)-1] = '\0'; + + if(access(adjusted_path, F_OK) == -1){ + printf("Error: Invalid File Name \"%s\"\n", new_path); + return NULL; + } } + else strcpy(adjusted_path, new_path); + new = malloc(sizeof(ENTRY)); strcpy(new->name, new_name); - strcpy(new->path, new_path); + strcpy(new->path, adjusted_path); + printf("1 DEBUG: %s\n", adjusted_path); + printf("2 DEBUG: %s\n", adjusted_path); new->next = NULL; return new; |