diff options
Diffstat (limited to 'plugins/CopyEngine/Ultracopier-Spec/CopyEngine.cpp')
-rwxr-xr-x | plugins/CopyEngine/Ultracopier-Spec/CopyEngine.cpp | 63 |
1 files changed, 61 insertions, 2 deletions
diff --git a/plugins/CopyEngine/Ultracopier-Spec/CopyEngine.cpp b/plugins/CopyEngine/Ultracopier-Spec/CopyEngine.cpp index 8ec21e1..0061f0a 100755 --- a/plugins/CopyEngine/Ultracopier-Spec/CopyEngine.cpp +++ b/plugins/CopyEngine/Ultracopier-Spec/CopyEngine.cpp @@ -5,6 +5,10 @@ #include <QFileDialog> #include <QMessageBox> #include <cmath> +#ifdef ULTRACOPIER_PLUGIN_DEBUG +#include <sys/stat.h> +#include <regex> +#endif #include "CopyEngine.h" #include "FolderExistsDialog.h" @@ -464,8 +468,50 @@ bool CopyEngine::newCopy(const std::vector<std::string> &sources,const std::stri return listThread->newCopy(sources,destination); } +#ifdef ULTRACOPIER_PLUGIN_DEBUG +bool stringStartWithC(std::string const &fullString, std::string const &starting) +{ + if (fullString.length() >= starting.length()) { + return (fullString.substr(0,starting.length())==starting); + } else { + return false; + } +} +#endif + bool CopyEngine::newMove(const std::vector<std::string> &sources) { + #ifdef ULTRACOPIER_PLUGIN_DEBUG + { + std::regex base_regex("^[a-z][a-z][a-z]*:/.*"); + std::smatch base_match; + + unsigned int index=0; + while(index<sources.size()) + { + std::string source=sources.at(index); + //can be: file://192.168.0.99/share/file.txt + //can be: file:///C:/file.txt + //can be: file:///home/user/fileatrootunderunix + #ifndef Q_OS_WIN + if(stringStartWithC(source,"file:///")) + source.replace(0,7,""); + #else + if(stringStartWithC(source,"file:///")) + source.replace(0,8,""); + else if(stringStartWithC(source,"file://")) + source.replace(0,5,""); + else if(stringStartWithC(source,"file:/")) + source.replace(0,6,""); + #endif + if(index<99) + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,sources.at(index)+" -> "+source); + index++; + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"source is_file: "+std::to_string(TransferThread::is_file(TransferThread::stringToInternalString(source)))+" is_dir: "+std::to_string(TransferThread::is_dir(TransferThread::stringToInternalString(source)))); + } + } + #endif + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,stringimplode(sources,", ")); if(forcedMode && mode!=Ultracopier::Move) { @@ -764,8 +810,14 @@ void CopyEngine::setFileCollision(int index) case 6: alwaysDoThisActionForFileExists=FileExists_Rename; break; + case 7: + alwaysDoThisActionForFileExists=FileExists_OverwriteIfNotSameSize; + break; + case 8: + alwaysDoThisActionForFileExists=FileExists_OverwriteIfNotSameSizeAndDate; + break; default: - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"Error, unknow index, ignored"); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"Error, unknow index, ignored: "+std::to_string(index)); alwaysDoThisActionForFileExists=FileExists_NotSet; break; } @@ -790,7 +842,7 @@ void CopyEngine::setFileError(int index) alwaysDoThisActionForFileError=FileError_PutToEndOfTheList; break; default: - ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"Error, unknow index, ignored"); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"Error, unknow index, ignored: "+std::to_string(index)); alwaysDoThisActionForFileError=FileError_NotSet; break; } @@ -826,7 +878,14 @@ void CopyEngine::setNativeCopy(const bool native_copy) { this->native_copy=native_copy; if(uiIsInstalled) + { ui->native_copy->setChecked(native_copy); + #ifndef Q_OS_WIN32 + ui->native_copy->setEnabled(false); + ui->label_native_copy->setEnabled(false); + ui->native_copy->setToolTip(tr("Supported only on Windows")); + #endif + } listThread->setNativeCopy(native_copy); } |