From 0cc54cc2ea8c1bab1b9dc543d860d80b27ce90d1 Mon Sep 17 00:00:00 2001 From: sorgelig Date: Fri, 15 Mar 2019 03:33:28 +0800 Subject: [PATCH] file_io: fix: file name haven't stored in fileTYPE for files in zip. --- file_io.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/file_io.cpp b/file_io.cpp index 4ba6235..3a8ec2b 100644 --- a/file_io.cpp +++ b/file_io.cpp @@ -230,6 +230,9 @@ int FileOpenEx(fileTYPE *file, const char *name, int mode, char mute) file->mode = 0; file->type = 0; + char *p = strrchr(full_path, '/'); + strcpy(file->name, (mode == -1) ? full_path : p + 1); + char *zip_path, *file_path; if ((mode != -1) && FileIsZipped(full_path, &zip_path, &file_path)) { @@ -284,9 +287,6 @@ int FileOpenEx(fileTYPE *file, const char *name, int mode, char mute) } else { - char *p = strrchr(full_path, '/'); - strcpy(file->name, (mode == -1) ? full_path : p+1); - int fd = (mode == -1) ? shm_open("/vtrd", O_CREAT | O_RDWR | O_TRUNC, 0777) : open(full_path, mode, 0777); if (fd <= 0) {