mirror of
https://github.com/xorgy/mediafire-fuse
synced 2026-01-13 13:14:29 -08:00
remove "myfiles" as a moniker for the root. Use NULL or empty string instead
This commit is contained in:
@@ -37,19 +37,18 @@ int mfshell_cmd_chdir(mfshell * mfshell, int argc, char *const argv[])
|
||||
if (mfshell == NULL)
|
||||
return -1;
|
||||
|
||||
if (argc != 2) {
|
||||
fprintf(stderr, "Invalid number of arguments\n");
|
||||
return -1;
|
||||
switch (argc) {
|
||||
case 1:
|
||||
folderkey = NULL;
|
||||
break;
|
||||
case 2:
|
||||
folderkey = argv[1];
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "Invalid number of arguments\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
folderkey = argv[1];
|
||||
if (folderkey == NULL)
|
||||
return -1;
|
||||
|
||||
// change to root
|
||||
if (strcmp(folderkey, "/") == 0)
|
||||
folderkey = "myfiles";
|
||||
|
||||
// user wants to navigate up a level
|
||||
if (strcmp(folderkey, "..") == 0) {
|
||||
// do several sanity checks to see if we're already at the root
|
||||
@@ -57,8 +56,6 @@ int mfshell_cmd_chdir(mfshell * mfshell, int argc, char *const argv[])
|
||||
|
||||
if (folder_curr == NULL)
|
||||
return 0;
|
||||
if (strcmp(folder_curr, "myfiles") == 0)
|
||||
return 0;
|
||||
|
||||
folder_parent = folder_get_parent(mfshell->folder_curr);
|
||||
|
||||
@@ -69,17 +66,15 @@ int mfshell_cmd_chdir(mfshell * mfshell, int argc, char *const argv[])
|
||||
folderkey = folder_parent;
|
||||
}
|
||||
// check the lenght of the key
|
||||
if (strlen(folderkey) != 13) {
|
||||
// as a folder moniker, "myfiles" is an exception
|
||||
if (strcmp(folderkey, "myfiles") != 0)
|
||||
return -1;
|
||||
if (folderkey != NULL && strlen(folderkey) != 13) {
|
||||
return -1;
|
||||
}
|
||||
// create a new folder object to store the results
|
||||
folder_new = folder_alloc();
|
||||
|
||||
// navigate to root is a special case
|
||||
if (strcmp(folderkey, "myfiles") == 0) {
|
||||
folder_set_key(folder_new, "myfiles");
|
||||
if (folderkey == NULL) {
|
||||
folder_set_key(folder_new, NULL);
|
||||
retval = 0;
|
||||
} else {
|
||||
retval = mfconn_api_folder_get_info(mfshell->conn,
|
||||
|
||||
@@ -41,14 +41,6 @@ int mfshell_cmd_list(mfshell * mfshell, int argc, char *const argv[])
|
||||
|
||||
folder_curr = folder_get_key(mfshell->folder_curr);
|
||||
|
||||
// safety check... this should never happen
|
||||
if (folder_curr == NULL)
|
||||
folder_set_key(mfshell->folder_curr, "myfiles");
|
||||
|
||||
// safety check... this should never happen
|
||||
if (folder_curr[0] == '\0')
|
||||
folder_set_key(mfshell->folder_curr, "myfiles");
|
||||
|
||||
// first folders
|
||||
retval =
|
||||
mfconn_api_folder_get_content(mfshell->conn, 0, mfshell->folder_curr);
|
||||
|
||||
@@ -45,19 +45,10 @@ int mfshell_cmd_mkdir(mfshell * mfshell, int argc, char *const argv[])
|
||||
|
||||
folder_curr = folder_get_key(mfshell->folder_curr);
|
||||
|
||||
// safety check... this should never happen
|
||||
if (folder_curr == NULL)
|
||||
folder_set_key(mfshell->folder_curr, "myfiles");
|
||||
|
||||
// safety check... this should never happen
|
||||
if (folder_curr[0] == '\0')
|
||||
folder_set_key(mfshell->folder_curr, "myfiles");
|
||||
|
||||
folder_curr = folder_get_key(mfshell->folder_curr);
|
||||
|
||||
retval =
|
||||
mfconn_api_folder_create(mfshell->conn, (char *)folder_curr,
|
||||
(char *)name);
|
||||
retval = mfconn_api_folder_create(mfshell->conn, folder_curr,
|
||||
(char *)name);
|
||||
mfconn_update_secret_key(mfshell->conn);
|
||||
|
||||
return retval;
|
||||
|
||||
@@ -35,7 +35,7 @@ struct mfcmd commands[] = {
|
||||
{"whoami", "", "show basic user info", mfshell_cmd_whoami},
|
||||
{"ls", "", "show contents of active folder",
|
||||
mfshell_cmd_list},
|
||||
{"cd", "[folderkey]", "change active folder", mfshell_cmd_chdir},
|
||||
{"cd", "<folderkey>", "change active folder (default: root)", mfshell_cmd_chdir},
|
||||
{"pwd", "", "show the active folder", mfshell_cmd_pwd},
|
||||
{"lpwd", "", "show the local working directory",
|
||||
mfshell_cmd_lpwd},
|
||||
@@ -43,6 +43,7 @@ struct mfcmd commands[] = {
|
||||
mfshell_cmd_lcd},
|
||||
{"mkdir", "[folder name]", "create a new folder", mfshell_cmd_mkdir},
|
||||
{"file", "[quickkey]", "show file information", mfshell_cmd_file},
|
||||
{"folder", "<folderkey>", "show folder information (default:root)", mfshell_cmd_folder},
|
||||
{"links", "[quickkey]", "show access urls for the file",
|
||||
mfshell_cmd_links},
|
||||
{"get", "[quickkey]", "download a file", mfshell_cmd_get},
|
||||
@@ -79,7 +80,8 @@ mfshell *mfshell_create(int app_id, char *app_key, char *server)
|
||||
|
||||
// object to track folder location
|
||||
shell->folder_curr = folder_alloc();
|
||||
folder_set_key(shell->folder_curr, "myfiles");
|
||||
// set current folder to root
|
||||
folder_set_key(shell->folder_curr, NULL);
|
||||
|
||||
// shell commands
|
||||
shell->commands = commands;
|
||||
|
||||
Reference in New Issue
Block a user