* Fix fs prompt:

- Added Unknown command
- Chop root path
This commit is contained in:
earada 2011-02-18 22:34:50 +01:00
parent 4cb8868ecc
commit 4b86cadf91

View File

@ -225,6 +225,7 @@ R_API int r_fs_prompt (RFS *fs, char *root) {
RListIter *iter; RListIter *iter;
RFSFile *file; RFSFile *file;
r_str_chop_path (root);
strncpy (path, root, sizeof (path)-1); strncpy (path, root, sizeof (path)-1);
for (;;) { for (;;) {
@ -252,6 +253,8 @@ R_API int r_fs_prompt (RFS *fs, char *root) {
strcat (path, "/"); strcat (path, "/");
strcat (path, input); strcat (path, input);
r_str_chop_path (path); r_str_chop_path (path);
if (strlen (path) < strlen (root))
strncpy (path, root, sizeof (path)-1);
list = r_fs_dir (fs, path); list = r_fs_dir (fs, path);
if (!r_list_empty (list)) if (!r_list_empty (list))
r_list_free (list); r_list_free (list);
@ -300,6 +303,8 @@ R_API int r_fs_prompt (RFS *fs, char *root) {
" q/exit ; leave prompt mode\n" " q/exit ; leave prompt mode\n"
" ?/help ; show this help\n" " ?/help ; show this help\n"
); );
} else {
printf ("Unknown command %s\n", buf);
} }
} }
clearerr (stdin); clearerr (stdin);