From 35f81c38263f81b9331b4651ad6fc2844388490b Mon Sep 17 00:00:00 2001 From: sorgelig Date: Mon, 20 Jan 2020 14:04:36 +0800 Subject: [PATCH] Cleanup. --- file_io.cpp | 16 ++++++++-------- file_io.h | 6 +++--- menu.cpp | 5 ++--- support/c64/c64.cpp | 2 +- user_io.cpp | 8 +++++--- user_io.h | 2 +- 6 files changed, 20 insertions(+), 19 deletions(-) diff --git a/file_io.cpp b/file_io.cpp index f96fac3..dd95a8b 100644 --- a/file_io.cpp +++ b/file_io.cpp @@ -82,10 +82,10 @@ static int FileIsZipped(char* path, char** zip_path, char** file_path) return 0; } -static char* make_fullpath(const char *path, int mode = 0, bool absolutePath = false) +static char* make_fullpath(const char *path, int mode = 0) { const char *root = getRootDir(); - if (!absolutePath && strncasecmp(getRootDir(), path, strlen(root))) + if (path[0] != '/') { sprintf(full_path, "%s/%s", (mode == -1) ? "" : root, path); } @@ -253,9 +253,9 @@ static int zip_search_by_crc(mz_zip_archive *zipArchive, uint32_t crc32) return -1; } -int FileOpenZip(fileTYPE *file, const char *name, uint32_t crc32, bool absolutePath) +int FileOpenZip(fileTYPE *file, const char *name, uint32_t crc32) { - make_fullpath(name, 0, absolutePath); + make_fullpath(name); FileClose(file); file->mode = 0; file->type = 0; @@ -317,9 +317,9 @@ int FileOpenZip(fileTYPE *file, const char *name, uint32_t crc32, bool absoluteP return 1; } -int FileOpenEx(fileTYPE *file, const char *name, int mode, char mute, bool absolutePath) +int FileOpenEx(fileTYPE *file, const char *name, int mode, char mute) { - make_fullpath((char*)name, mode, absolutePath); + make_fullpath((char*)name, mode); FileClose(file); file->mode = 0; file->type = 0; @@ -461,9 +461,9 @@ __off64_t FileGetSize(fileTYPE *file) return 0; } -int FileOpen(fileTYPE *file, const char *name, char mute, bool absolutePath) +int FileOpen(fileTYPE *file, const char *name, char mute) { - return FileOpenEx(file, name, O_RDONLY, mute, absolutePath); + return FileOpenEx(file, name, O_RDONLY, mute); } int FileSeek(fileTYPE *file, __off64_t offset, int origin) diff --git a/file_io.h b/file_io.h index 87b9ae0..853d036 100644 --- a/file_io.h +++ b/file_io.h @@ -59,9 +59,9 @@ int getStorage(int from_setting); void setStorage(int dev); int isUSBMounted(); -int FileOpenZip(fileTYPE *file, const char *name, uint32_t crc32, bool absolutePath = false); -int FileOpenEx(fileTYPE *file, const char *name, int mode, char mute = 0, bool absolutePath = false); -int FileOpen(fileTYPE *file, const char *name, char mute = 0, bool absolutePath = false); +int FileOpenZip(fileTYPE *file, const char *name, uint32_t crc32); +int FileOpenEx(fileTYPE *file, const char *name, int mode, char mute = 0); +int FileOpen(fileTYPE *file, const char *name, char mute = 0); void FileClose(fileTYPE *file); __off64_t FileGetSize(fileTYPE *file); diff --git a/menu.cpp b/menu.cpp index 8f06400..c660ffb 100644 --- a/menu.cpp +++ b/menu.cpp @@ -1727,9 +1727,8 @@ void HandleUI(void) } else { - unsigned char ioctl_subindex = user_io_ext_idx(SelectedPath, fs_pFileExt); - user_io_set_index(ioctl_subindex << 6 | (menusub + 1)); - user_io_file_mount(SelectedPath, ioctl_index, 0, ioctl_subindex); + user_io_set_index(user_io_ext_idx(SelectedPath, fs_pFileExt) << 6 | (menusub + 1)); + user_io_file_mount(SelectedPath, ioctl_index); } menustate = SelectedPath[0] ? MENU_NONE1 : MENU_8BIT_MAIN1; diff --git a/support/c64/c64.cpp b/support/c64/c64.cpp index 38d8eab..6feb78f 100644 --- a/support/c64/c64.cpp +++ b/support/c64/c64.cpp @@ -164,7 +164,7 @@ int c64_convert_t64_to_d64(fileTYPE* f, const char *path) CHECK_SUCCESS(files.size()); - CHECK_SUCCESS(FileOpenEx(&fd, path, O_CREAT | O_TRUNC | O_RDWR | O_SYNC, 0, true)); + CHECK_SUCCESS(FileOpenEx(&fd, path, O_CREAT | O_TRUNC | O_RDWR | O_SYNC, 0)); unsigned char sector[D64_BYTE_PER_SECTOR]; memset(sector, D64_INIT_VALUE, sizeof(sector)); diff --git a/user_io.cpp b/user_io.cpp index eef208e..d73ae23 100644 --- a/user_io.cpp +++ b/user_io.cpp @@ -1187,7 +1187,7 @@ void user_io_set_download(unsigned char enable) DisableFpga(); } -int user_io_file_mount(char *name, unsigned char index, char pre, unsigned char subindex) +int user_io_file_mount(char *name, unsigned char index, char pre) { int writable = 0; int ret = 0; @@ -1247,7 +1247,9 @@ int user_io_file_mount(char *name, unsigned char index, char pre, unsigned char if (is_c64_core()) { - if (subindex == 1) { + int len = strlen(name); + if(len>4 && !strcasecmp(name+len-4, ".t64")) + { // mount T64 size = 0; writable = false; @@ -1257,7 +1259,7 @@ int user_io_file_mount(char *name, unsigned char index, char pre, unsigned char if (ret) { - ret = FileOpenEx(&sd_image[index], path, O_RDONLY, 0, true); + ret = FileOpenEx(&sd_image[index], path, O_RDONLY, 0); size = sd_image[index].size; } } diff --git a/user_io.h b/user_io.h index 0e7c654..5aa9e54 100644 --- a/user_io.h +++ b/user_io.h @@ -216,7 +216,7 @@ void user_io_file_tx_write(const uint8_t *addr, uint16_t len); int user_io_get_width(); uint32_t user_io_get_file_crc(); -int user_io_file_mount(char *name, unsigned char index = 0, char pre = 0, unsigned char subindex = 0); +int user_io_file_mount(char *name, unsigned char index = 0, char pre = 0); char user_io_serial_status(serial_status_t *, uint8_t); char *user_io_make_filepath(const char *path, const char *filename); char *user_io_get_core_name();