From fd2735d524b15ac60892a0db2faeea1b004c8510 Mon Sep 17 00:00:00 2001 From: Joel16 Date: Tue, 23 Mar 2021 12:44:05 -0400 Subject: [PATCH] fs: Clear copy file entry before another copy/paste is made --- source/fs.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/source/fs.cpp b/source/fs.cpp index 69615ff..ee467c6 100644 --- a/source/fs.cpp +++ b/source/fs.cpp @@ -397,8 +397,15 @@ namespace FS { return 0; } + + static void ClearFSCopyEntry(void) { + fs_copy_entry.copy_path.clear(); + fs_copy_entry.copy_filename.clear(); + fs_copy_entry.is_dir = false; + } void Copy(FS_DirectoryEntry *entry, const std::string &path) { + FS::ClearFSCopyEntry(); fs_copy_entry.copy_path = std::wstring_convert, char16_t>{}.from_bytes(path.data()); fs_copy_entry.copy_path.append(reinterpret_cast(entry->name)); fs_copy_entry.copy_filename.append(reinterpret_cast(entry->name)); @@ -419,9 +426,7 @@ namespace FS { else // Copy file ret = FS::CopyFile(fs_copy_entry.copy_path, path); - fs_copy_entry.copy_path.clear(); - fs_copy_entry.copy_filename.clear(); - fs_copy_entry.is_dir = false; + FS::ClearFSCopyEntry(); return ret; } @@ -443,9 +448,7 @@ namespace FS { } } - fs_copy_entry.copy_path.clear(); - fs_copy_entry.copy_filename.clear(); - fs_copy_entry.is_dir = false; + FS::ClearFSCopyEntry(); return 0; } }