diff options
author | Thomas Preud'homme <robotux@celest.fr> | 2020-08-11 22:35:12 +0100 |
---|---|---|
committer | Thomas Preud'homme <robotux@celest.fr> | 2020-08-11 22:35:12 +0100 |
commit | 3ac113857071fc1f225b2e1b42547269e568c6b7 (patch) | |
tree | 8b28dd9c44a0d3c7ab8187cd8d8f19d47591d813 /plugins/CopyEngine/Ultracopier-Spec/ListThreadNew.cpp | |
parent | 9b10c21f5cad0e2ec27d23c59e65af7141a226f3 (diff) |
New upstream version 2.2.4.4
Diffstat (limited to 'plugins/CopyEngine/Ultracopier-Spec/ListThreadNew.cpp')
-rwxr-xr-x | plugins/CopyEngine/Ultracopier-Spec/ListThreadNew.cpp | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/plugins/CopyEngine/Ultracopier-Spec/ListThreadNew.cpp b/plugins/CopyEngine/Ultracopier-Spec/ListThreadNew.cpp new file mode 100755 index 0000000..f4a1857 --- /dev/null +++ b/plugins/CopyEngine/Ultracopier-Spec/ListThreadNew.cpp @@ -0,0 +1,104 @@ +#include "ListThread.h" +#include <QStorageInfo> +#include <QtGlobal> +#include "../../../cpp11addition.h" + +#include "async/TransferThreadAsync.h" + +// -> add thread safe, by Qt::BlockingQueuedConnection +bool ListThread::newCopy(const std::vector<std::string> &sources,const std::string &destination) +{ + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"start: "+stringimplode(sources,";")+", destination: "+destination); + ScanFileOrFolder * scanFileOrFolderThread=newScanThread(Ultracopier::Copy); + if(scanFileOrFolderThread==NULL) + { + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"unable to get new thread"); + return false; + } + std::regex base_regex("^[a-z][a-z][a-z]*:/.*"); + std::smatch base_match; + std::vector<INTERNALTYPEPATH> sourcesClean; + 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(stringStartWith(source,"file:///")) + source.replace(0,7,""); + #else + if(stringStartWith(source,"file:///")) + source.replace(0,8,""); + else if(stringStartWith(source,"file://")) + source.replace(0,5,""); + else if(stringStartWith(source,"file:/")) + source.replace(0,6,""); + #endif + else if (std::regex_match(source, base_match, base_regex)) + return false; + if(index<99) + { + if(sources.at(index)!=source) + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,sources.at(index)+" -> "+source); + } + index++; + sourcesClean.push_back(TransferThread::stringToInternalString(source)); + } + //ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"sourcesClean: "+stringimplode(sourcesClean,";")); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"destination: "+destination); + const INTERNALTYPEPATH &Wdest=TransferThread::stringToInternalString(destination); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"destination: "+TransferThread::internalStringTostring(Wdest)); + scanFileOrFolderThread->addToList(sourcesClean,Wdest); + scanThreadHaveFinish(true); + detectDrivesOfCurrentTransfer(sourcesClean,TransferThread::stringToInternalString(destination)); + return true; +} + +// -> add thread safe, by Qt::BlockingQueuedConnection +bool ListThread::newMove(const std::vector<std::string> &sources,const std::string &destination) +{ + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"start"); + ScanFileOrFolder * scanFileOrFolderThread = newScanThread(Ultracopier::Move); + if(scanFileOrFolderThread==NULL) + { + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"unable to get new thread"); + return false; + } + std::regex base_regex("^[a-z][a-z][a-z]*:/.*"); + std::smatch base_match; + std::vector<INTERNALTYPEPATH> sourcesClean; + 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(stringStartWith(source,"file:///")) + source.replace(0,7,""); + #else + if(stringStartWith(source,"file:///")) + source.replace(0,8,""); + else if(stringStartWith(source,"file://")) + source.replace(0,5,""); + else if(stringStartWith(source,"file:/")) + source.replace(0,6,""); + #endif + else if (std::regex_match(source, base_match, base_regex)) + return false; + if(index<99) + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,sources.at(index)+" -> "+source); + index++; + sourcesClean.push_back(TransferThread::stringToInternalString(source)); + } + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"destination: "+destination); + const INTERNALTYPEPATH &Wdest=TransferThread::stringToInternalString(destination); + ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"destination: "+TransferThread::internalStringTostring(Wdest)); + scanFileOrFolderThread->addToList(sourcesClean,Wdest); + scanThreadHaveFinish(true); + detectDrivesOfCurrentTransfer(sourcesClean,TransferThread::stringToInternalString(destination)); + return true; +} |