From 26d07c7aea04185d83987974a12fdde584644bc4 Mon Sep 17 00:00:00 2001 From: Karl Blomster Date: Tue, 14 Jul 2009 02:20:40 +0000 Subject: [PATCH] Remove the dangerous CopyFile function that on Unix attempted to create hard links of files instead of copying them. Replace it with wxCopyFile instead. Patch by jfs. Fixes #912. Originally committed to SVN as r3129. --- aegisub/src/dialog_fonts_collector.cpp | 2 +- aegisub/src/frame_main.cpp | 2 +- aegisub/src/utils.cpp | 18 ------------------ aegisub/src/utils.h | 1 - 4 files changed, 2 insertions(+), 21 deletions(-) diff --git a/aegisub/src/dialog_fonts_collector.cpp b/aegisub/src/dialog_fonts_collector.cpp index 9cffdeb7c..430caf937 100644 --- a/aegisub/src/dialog_fonts_collector.cpp +++ b/aegisub/src/dialog_fonts_collector.cpp @@ -546,7 +546,7 @@ int FontsCollectorThread::CopyFont(wxString filename) { wxFileName fn(filename); wxString dstName = destFolder + _T("//") + fn.GetFullName(); if (wxFileName::FileExists(dstName)) return 2; - return CopyFile(filename,dstName) ? 1 : 0; + return wxCopyFile(filename,dstName,true) ? 1 : 0; } diff --git a/aegisub/src/frame_main.cpp b/aegisub/src/frame_main.cpp index 6460b4f71..437580890 100644 --- a/aegisub/src/frame_main.cpp +++ b/aegisub/src/frame_main.cpp @@ -725,7 +725,7 @@ void FrameMain::LoadSubtitles (wxString filename,wxString charset) { // Save wxString backup = path + origfile.GetName() + _T(".ORIGINAL.") + origfile.GetExt(); - CopyFile(filename,backup); + wxCopyFile(filename,backup,true); } // Sync diff --git a/aegisub/src/utils.cpp b/aegisub/src/utils.cpp index e305dde74..8696e8ef7 100644 --- a/aegisub/src/utils.cpp +++ b/aegisub/src/utils.cpp @@ -74,24 +74,6 @@ int CountMatches(wxString parent,wxString child) { } -/////////////// -// Copy a file -bool CopyFile(wxString src,wxString dst) { - // Windows - #if defined(__WINDOWS__) - BOOL result = CopyFile(src.wc_str(),dst.wc_str(),false); - return (result != 0); - - // Linux - #elif defined(__UNIX__) - return link(src.mb_str(),dst.mb_str()) != 0; - - // Error - #else - #error "don't know how to backup files" - #endif -} - ///////////////////////////////////// // Make a path relative to reference wxString MakeRelativePath(wxString _path,wxString reference) { diff --git a/aegisub/src/utils.h b/aegisub/src/utils.h index 88965a46a..198afc8df 100644 --- a/aegisub/src/utils.h +++ b/aegisub/src/utils.h @@ -56,7 +56,6 @@ typedef std::vector > IntPairVector; int64_t abs64(int64_t input); #endif int CountMatches(wxString parent,wxString child); -bool CopyFile(wxString src,wxString dst); wxString MakeRelativePath(wxString path,wxString reference); wxString DecodeRelativePath(wxString path,wxString reference); wxString PrettyFloat(wxString src);