mirror of
https://gitlab.com/Theopse/fbi-i18n-zh.git
synced 2025-04-06 03:58:02 +08:00
Only add directory entry on paste if directory does not exist, fix servefiles on Python 3.
This commit is contained in:
parent
ddb18e3058
commit
f7ac0c4020
@ -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
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user