diff --git a/servefiles/servefiles.py b/servefiles/servefiles.py index 6725192..3d5ba38 100644 --- a/servefiles/servefiles.py +++ b/servefiles/servefiles.py @@ -12,13 +12,12 @@ import urllib try: from SimpleHTTPServer import SimpleHTTPRequestHandler from SocketServer import TCPServer - from urlparse import urljoin - from urllib import pathname2url, quote + from urllib import quote + input = raw_input except ImportError: from http.server import SimpleHTTPRequestHandler from socketserver import TCPServer - from urllib.parse import urljoin, quote - from urllib.request import pathname2url + from urllib.parse import quote interactive = False @@ -39,15 +38,15 @@ accepted_extension = ('.cia', '.tik', '.cetk') hostPort = 8080 # Default value if interactive: - target_ip = raw_input("The IP of your 3DS: ") - target_path = raw_input("The file you want to send (.cia, .tik, or .cetk): ") + target_ip = input("The IP of your 3DS: ") + target_path = input("The file you want to send (.cia, .tik, or .cetk): ") - hostIp = raw_input("Host IP (or press Enter to have the script detect host IP):") + hostIp = input("Host IP (or press Enter to have the script detect host IP):") if hostIp == '': print('Detecting host IP...') hostIp = [(s.connect(('8.8.8.8', 53)), s.getsockname()[0], s.close()) for s in [socket.socket(socket.AF_INET, socket.SOCK_DGRAM)]][0][1] else: - hostPort = raw_input("Host port (or press Enter to keep default, 8080):") + hostPort = input("Host port (or press Enter to keep default, 8080):") if hostPort == '': hostPort = 8080 # Default diff --git a/source/ui/section/action/pastecontents.c b/source/ui/section/action/pastecontents.c index 6518775..78324fb 100644 --- a/source/ui/section/action/pastecontents.c +++ b/source/ui/section/action/pastecontents.c @@ -78,8 +78,23 @@ static Result action_paste_contents_make_dst_directory(void* data, u32 index) { Handle dirHandle = 0; if(R_SUCCEEDED(FSUSER_OpenDirectory(&dirHandle, pasteData->target->archive, *fsPath))) { FSDIR_Close(dirHandle); - } else { - res = FSUSER_CreateDirectory(pasteData->target->archive, *fsPath, attributes); + } else if(R_SUCCEEDED(res = FSUSER_CreateDirectory(pasteData->target->archive, *fsPath, attributes))) { + char parentPath[FILE_PATH_MAX]; + util_get_parent_path(parentPath, dstPath, FILE_PATH_MAX); + + char baseDstPath[FILE_PATH_MAX]; + if(pasteData->target->attributes & FS_ATTRIBUTE_DIRECTORY) { + strncpy(baseDstPath, pasteData->target->path, FILE_PATH_MAX); + } else { + util_get_parent_path(baseDstPath, pasteData->target->path, FILE_PATH_MAX); + } + + if(strncmp(parentPath, baseDstPath, FILE_PATH_MAX) == 0) { + list_item* dstItem = NULL; + if(R_SUCCEEDED(res) && R_SUCCEEDED(task_create_file_item(&dstItem, pasteData->target->archive, dstPath, attributes))) { + linked_list_add(pasteData->items, dstItem); + } + } } util_free_path_utf8(fsPath); @@ -87,25 +102,6 @@ static Result action_paste_contents_make_dst_directory(void* data, u32 index) { res = R_FBI_OUT_OF_MEMORY; } - if(R_SUCCEEDED(res)) { - char parentPath[FILE_PATH_MAX]; - util_get_parent_path(parentPath, dstPath, FILE_PATH_MAX); - - char baseDstPath[FILE_PATH_MAX]; - if(pasteData->target->attributes & FS_ATTRIBUTE_DIRECTORY) { - strncpy(baseDstPath, pasteData->target->path, FILE_PATH_MAX); - } else { - util_get_parent_path(baseDstPath, pasteData->target->path, FILE_PATH_MAX); - } - - if(strncmp(parentPath, baseDstPath, FILE_PATH_MAX) == 0) { - list_item* dstItem = NULL; - if(R_SUCCEEDED(res) && R_SUCCEEDED(task_create_file_item(&dstItem, pasteData->target->archive, dstPath, attributes))) { - linked_list_add(pasteData->items, dstItem); - } - } - } - return res; }