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.
This commit is contained in:
Karl Blomster 2009-07-14 02:20:40 +00:00
parent 68481215c9
commit 2f65a5bb68
4 changed files with 2 additions and 21 deletions

View file

@ -546,7 +546,7 @@ int FontsCollectorThread::CopyFont(wxString filename) {
wxFileName fn(filename); wxFileName fn(filename);
wxString dstName = destFolder + _T("//") + fn.GetFullName(); wxString dstName = destFolder + _T("//") + fn.GetFullName();
if (wxFileName::FileExists(dstName)) return 2; if (wxFileName::FileExists(dstName)) return 2;
return CopyFile(filename,dstName) ? 1 : 0; return wxCopyFile(filename,dstName,true) ? 1 : 0;
} }

View file

@ -725,7 +725,7 @@ void FrameMain::LoadSubtitles (wxString filename,wxString charset) {
// Save // Save
wxString backup = path + origfile.GetName() + _T(".ORIGINAL.") + origfile.GetExt(); wxString backup = path + origfile.GetName() + _T(".ORIGINAL.") + origfile.GetExt();
CopyFile(filename,backup); wxCopyFile(filename,backup,true);
} }
// Sync // Sync

View file

@ -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 // Make a path relative to reference
wxString MakeRelativePath(wxString _path,wxString reference) { wxString MakeRelativePath(wxString _path,wxString reference) {

View file

@ -56,7 +56,6 @@ typedef std::vector<std::pair<int,int> > IntPairVector;
int64_t abs64(int64_t input); int64_t abs64(int64_t input);
#endif #endif
int CountMatches(wxString parent,wxString child); int CountMatches(wxString parent,wxString child);
bool CopyFile(wxString src,wxString dst);
wxString MakeRelativePath(wxString path,wxString reference); wxString MakeRelativePath(wxString path,wxString reference);
wxString DecodeRelativePath(wxString path,wxString reference); wxString DecodeRelativePath(wxString path,wxString reference);
wxString PrettyFloat(wxString src); wxString PrettyFloat(wxString src);