diff --git a/ChangeLog b/ChangeLog index 2b09e2a..4be7d24 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +V0.3.1 +--------- + * Fixed archiving of files from different folders. + * Fixed a mistake in choosing the archive name on compressing a folder. + V0.3.0 --------- * Eliminated a rare cause of crash, when the file list contains "/" and "//" (with "application/x-archive", for example). diff --git a/NEWS b/NEWS index 501de3a..1bc43e9 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,5 @@ Latest version: - 24 Oct 2019, V0.3.0 + 25 Oct 2019, V0.3.1 See "ChangeLog" for changes. diff --git a/backends.cpp b/backends.cpp index f75ae49..58d74a1 100644 --- a/backends.cpp +++ b/backends.cpp @@ -199,31 +199,32 @@ static inline void skipExistingFiles(QString& file) { file += suffix; } -void Backend::startAdd(QStringList& paths, bool absolutePaths) { +void Backend::startAdd(const QStringList& paths, bool absolutePaths) { keyArgs_.clear(); + QStringList filePaths = paths; /* exclude the archive itself */ - if (paths.contains(filepath_)) - paths.removeAll(filepath_); + if (filePaths.contains(filepath_)) + filePaths.removeAll(filepath_); /* no path should be a parent folder of the archive */ QString parentDir = filepath_.section("/", 0, -2); - for (int i = 0; !paths.isEmpty() && i < paths.length(); i++) { - if (parentDir.startsWith (paths[i])) { - paths.removeAt(i); + for (int i = 0; !filePaths.isEmpty() && i < filePaths.length(); i++) { + if (parentDir.startsWith (filePaths[i])) { + filePaths.removeAt(i); i--; } } - if(paths.isEmpty()) return; + if(filePaths.isEmpty()) return; /* no path should be repeated */ - paths.removeDuplicates(); + filePaths.removeDuplicates(); QStringList args; if (isGzip_) { emit processStarting(); if (QFile::exists(filepath_)) // the overwrite prompt should be already accepted - args << "--to-stdout" << "--force" << paths[0]; + args << "--to-stdout" << "--force" << filePaths[0]; else - args << "--to-stdout" << paths[0]; + args << "--to-stdout" << filePaths[0]; QProcess tmpProc; tmpProc.setStandardOutputFile(filepath_); tmpProc.start("gzip", args); // "gzip -c (-f) file > archive.gz" @@ -248,7 +249,7 @@ void Backend::startAdd(QStringList& paths, bool absolutePaths) { args << "-p" + pswrd_; encrypted_ = true; } - args << "a" << fileArgs_ << paths; + args << "a" << fileArgs_ << filePaths; starting7z_ = true; keyArgs_ << "a"; proc_.start ("7z", args); @@ -256,11 +257,11 @@ void Backend::startAdd(QStringList& paths, bool absolutePaths) { } /* NOTE: All paths should have the same parent directory. Check that and put the wrong paths into insertQueue_. */ - QString parent = paths[0].section("/", 0, -2); + QString parent = filePaths[0].section("/", 0, -2); insertQueue_.clear(); - for (int i = 1; i < paths.length(); i++) { - if (paths[i].section("/", 0, -2) != parent) { - insertQueue_ << paths.takeAt(i); + for (int i = 1; i < filePaths.length(); i++) { + if (filePaths[i].section("/", 0, -2) != parent) { + insertQueue_ << filePaths.takeAt(i); i--; } } @@ -268,16 +269,16 @@ void Backend::startAdd(QStringList& paths, bool absolutePaths) { args << fileArgs_; /* now, setup the parent dir */ if (!absolutePaths) { - for (int i = 0; i < paths.length(); i++) { - paths[i] = paths[i].section(parent, 1, -1); - if (paths[i].startsWith("/")) - paths[i].remove(0, 1); + for (int i = 0; i < filePaths.length(); i++) { + filePaths[i] = filePaths[i].section(parent, 1, -1); + if (filePaths[i].startsWith("/")) + filePaths[i].remove(0, 1); } args << "-C" << parent; } else args << "-C" << "/"; - args << paths; + args << filePaths; if (QFile::exists(filepath_)) { // append to the existing archive skipExistingFiles(tmpfilepath_); // practically not required args.replaceInStrings(filepath_, tmpfilepath_); @@ -287,19 +288,20 @@ void Backend::startAdd(QStringList& paths, bool absolutePaths) { proc_.start(TAR_CMD, args); } -void Backend::startRemove(QStringList& paths) { +void Backend::startRemove(const QStringList& paths) { keyArgs_.clear(); if (isGzip_) return; - if (paths.contains(filepath_)) - paths.removeAll(filepath_); - if (contents_.isEmpty() || paths.isEmpty() || !QFile::exists(filepath_)) + QStringList filePaths = paths; + if (filePaths.contains(filepath_)) + filePaths.removeAll(filepath_); + if (contents_.isEmpty() || filePaths.isEmpty() || !QFile::exists(filepath_)) return; // invalid - paths.removeDuplicates(); + filePaths.removeDuplicates(); QStringList args; if (is7z_) { if (encrypted_) args << "-p" + pswrd_; - args << "d" << fileArgs_ << paths; + args << "d" << fileArgs_ << filePaths; starting7z_ = true; keyArgs_ << "d"; proc_.start("7z", args); @@ -309,8 +311,8 @@ void Backend::startRemove(QStringList& paths) { args << fileArgs_; skipExistingFiles(tmpfilepath_); // practically not required args.replaceInStrings(filepath_, tmpfilepath_); - for (int i = 0; i < paths.length(); i++) { - args << "--exclude" << paths[i]; + for (int i = 0; i < filePaths.length(); i++) { + args << "--exclude" << filePaths[i]; } args << "@" + filepath_; keyArgs_ << "-c" << "-a" << "--exclude"; diff --git a/backends.h b/backends.h index 7c80237..7104384 100644 --- a/backends.h +++ b/backends.h @@ -48,8 +48,8 @@ class Backend : public QObject{ bool isLink(const QString& file); QString linkTo(const QString& file); - void startAdd(QStringList& paths, bool absolutePaths = false); - void startRemove(QStringList& paths); + void startAdd(const QStringList& paths, bool absolutePaths = false); + void startRemove(const QStringList& paths); void startExtract(const QString& path, const QString& file = QString(), bool overwrite = true, bool preservePaths = true); void startExtract(const QString& path, const QStringList& files, bool overwrite = true, bool preservePaths = true); diff --git a/data/translations/arqiver.ts b/data/translations/arqiver.ts index da44ae7..c2be3f1 100644 --- a/data/translations/arqiver.ts +++ b/data/translations/arqiver.ts @@ -12,37 +12,37 @@ Arqiver::Backend - - + + Could not read archive - - + + Archive Loaded - - + + Modification Finished - - + + Extraction Finished - - + + Extraction Failed - + %1 is missing from your system. Please install it for this kind of archive! @@ -249,8 +249,8 @@ Clear text with the Escape key. - - + + Opening Archive... @@ -372,138 +372,138 @@ Clear text with the Escape key. - + Create Archive - - + + Question - + The following archive already exists: - + Do you want to replace it? - + Open Archive - - - + + + Add to Archive - - - - + + + + Adding Items... - + Removing Items... - - - - - + + + + + Extracting... - + View Current Item - - + + Enter Password - + Cancel - + OK - + Encrypt the file list - + This will take effect after files/folders are added. - - + + Extract Into Directory - + Some files will be overwritten. Do you want to continue? - + Link To: %1 - + A simple Qt archive manager - + based on libarchive, gzip and 7z - + Author - + aka. - - + + About Arqiver - + Translators diff --git a/data/translations/arqiver_eo.ts b/data/translations/arqiver_eo.ts index d963e18..58c357b 100644 --- a/data/translations/arqiver_eo.ts +++ b/data/translations/arqiver_eo.ts @@ -12,37 +12,37 @@ Arqiver::Backend - - + + Could not read archive La arkivo ne legeblis - - + + Archive Loaded Arkivo Ŝargita - - + + Modification Finished Modifado Farita - - + + Extraction Finished Ekstraktado Farita - - + + Extraction Failed Ekstraktado Malsukcesis - + %1 is missing from your system. Please install it for this kind of archive! %1 mankas al via sistemo. @@ -251,8 +251,8 @@ Viŝu la tekston per la eskapa klavo. - - + + Opening Archive... Malfermadi Arkivon... @@ -374,101 +374,101 @@ Viŝu la tekston per la eskapa klavo. Montri Ĉiujn Dosierojn (*) - + Create Archive Estigi Arkivon - - + + Question Demando - + The following archive already exists: La jana arkivo jam ekzistas: - + Do you want to replace it? Ĉu vi volas anstataŭigi ĝin? - + Open Archive Malfermi Arkivon - - - + + + Add to Archive Aldoni al Arkivon - - - - + + + + Adding Items... Aldoni Erojn... - + Removing Items... Forviŝi Erojn... - - - - - + + + + + Extracting... Ekstrakti... - + View Current Item Vidi Ĉi Tiun Eron - - + + Enter Password Enmetu Pasvorton - + Cancel Rezigni - + OK Bone - + Encrypt the file list Ĉifri la dosierliston - + This will take effect after files/folders are added. Ĉi tio efektiviĝos post kiam dosieroj/dosierujoj estas aldonitaj. - - + + Extract Into Directory Ekstrakto en Dosierujon - + Some files will be overwritten. Do you want to continue? @@ -477,38 +477,38 @@ Do you want to continue? - + Link To: %1 Ligilo Al %1 - + A simple Qt archive manager Simpla Qt-Arkivilo - + based on libarchive, gzip and 7z bazita sur libarchive, gzip kaj 7z - + Author Verkinto - + aka. akk. - - + + About Arqiver Pri Arqiver - + Translators Tradukintoj diff --git a/data/translations/arqiver_nl.ts b/data/translations/arqiver_nl.ts index 99d6b53..b3e0201 100644 --- a/data/translations/arqiver_nl.ts +++ b/data/translations/arqiver_nl.ts @@ -12,37 +12,37 @@ Arqiver::Backend - - + + Could not read archive Kan archief niet uitlezen - - + + Archive Loaded Archief geladen - - + + Modification Finished Bewerking voltooid - - + + Extraction Finished Uitpakken voltooid - - + + Extraction Failed - + %1 is missing from your system. Please install it for this kind of archive! %1 is niet geïnstalleerd. @@ -250,8 +250,8 @@ Clear text with the Escape key. - - + + Opening Archive... Bezig met openen van archief... @@ -373,139 +373,139 @@ Clear text with the Escape key. Alle bestanden tonen (*) - + Create Archive Archief creëren - - + + Question Vraag - + The following archive already exists: Het volgende archief bestaat al: - + Do you want to replace it? Wil je dit vervangen? - + Open Archive Archief openen - - - + + + Add to Archive Toevoegen aan archief - - - - + + + + Adding Items... Bezig met toevoegen van items... - + Removing Items... Bezig met verwijderen van items... - - - - - + + + + + Extracting... Bezig met uitpakken... - + View Current Item Huidig item tonen - - + + Enter Password Voer wachtwoord in - + Cancel Annuleren - + OK Oké - + Encrypt the file list Bestandslijst versleutelen - + This will take effect after files/folders are added. Dit wordt toegepast na het toevoegen van bestanden/mappen. - - + + Extract Into Directory Uitpakken naar map - + Some files will be overwritten. Do you want to continue? - + Link To: %1 Link naar: %1 - + A simple Qt archive manager Een eenvoudige Qt-archiefbeheerder - + based on libarchive, gzip and 7z gebaseerd op libarchive, gzip en 7z - + Author Maker - + aka. ook bekend als - - + + About Arqiver Over Arqiver - + Translators Vertalers diff --git a/data/translations/arqiver_pl.ts b/data/translations/arqiver_pl.ts index a711573..bc45b04 100644 --- a/data/translations/arqiver_pl.ts +++ b/data/translations/arqiver_pl.ts @@ -12,37 +12,37 @@ Arqiver::Backend - - + + Could not read archive Nie udało się odczytać archiwum - - + + Archive Loaded Załadowano archiwum - - + + Modification Finished Zakończono modyfikowanie - - + + Extraction Finished Zakończono rozpakowywanie - - + + Extraction Failed - + %1 is missing from your system. Please install it for this kind of archive! W Twoim systemie brakuje %1. @@ -250,8 +250,8 @@ Clear text with the Escape key. - - + + Opening Archive... Otwieranie archiwum… @@ -373,139 +373,139 @@ Clear text with the Escape key. Pokaż wszystkie pliki (*) - + Create Archive Utwórz archiwum - - + + Question Pytanie - + The following archive already exists: Następujące archiwum już istnieje: - + Do you want to replace it? Czy chcesz je zamienić? - + Open Archive Otwórz archiwum - - - + + + Add to Archive Dodaj do archiwum - - - - + + + + Adding Items... Dodawanie elementów… - + Removing Items... Usuwanie elementów… - - - - - + + + + + Extracting... Rozpakowywanie… - + View Current Item Pokaż obecny element - - + + Enter Password Wprowadź hasło - + Cancel Anuluj - + OK OK - + Encrypt the file list Szyfruj listę plików - + This will take effect after files/folders are added. Efekt będzie widoczny po dodaniu nowych plików/katalogów. - - + + Extract Into Directory Rozpakuj do katalogu - + Some files will be overwritten. Do you want to continue? - + Link To: %1 Odnośnik do: %1 - + A simple Qt archive manager Prosty menedżer archiwum Qt - + based on libarchive, gzip and 7z oparty o libarchive, gzip i 7z - + Author Autor - + aka. aka. - - + + About Arqiver O Arqiver - + Translators Tłumacze diff --git a/data/translations/arqiver_pt_BR.ts b/data/translations/arqiver_pt_BR.ts index 021276b..2a6eda6 100644 --- a/data/translations/arqiver_pt_BR.ts +++ b/data/translations/arqiver_pt_BR.ts @@ -12,37 +12,37 @@ Arqiver::Backend - - + + Could not read archive Não foi possível ler o arquivo - - + + Archive Loaded Arquivo Carregado - - + + Modification Finished Modificação Concluída - - + + Extraction Finished Extração Concluída - - + + Extraction Failed Extração Falhou - + %1 is missing from your system. Please install it for this kind of archive! %1 está ausente do seu sistema. @@ -250,8 +250,8 @@ Clear text with the Escape key. - - + + Opening Archive... Abrindo Arquivo... @@ -373,100 +373,100 @@ Clear text with the Escape key. Exibir Todos os Arquivos (*) - + Create Archive Criar Arquivo - - + + Question Questão - + The following archive already exists: O seguinte arquivo já existe: - + Do you want to replace it? Deseja substituir esse arquivo? - + Open Archive Abrir Arquivo - - - + + + Add to Archive Adicionar ao Arquivo - - - - + + + + Adding Items... Adicionando Itens... - + Removing Items... Removendo Itens... - - - - - + + + + + Extracting... Extraindo... - + View Current Item Exibir Item Atual - - + + Enter Password Digite a Senha - + Cancel Cancelar - + OK Ok - + Encrypt the file list Criptografar a lista de arquivos - + This will take effect after files/folders are added. Isso entrará em vigor depois que os arquivos/pastas forem adicionados. - - + + Extract Into Directory Extrair no Diretório - + Some files will be overwritten. Do you want to continue? @@ -474,38 +474,38 @@ Do you want to continue? Deseja continuar? - + Link To: %1 Link Para: %1 - + A simple Qt archive manager Um simples gerenciador de arquivos Qt - + based on libarchive, gzip and 7z baseado em libarchive, gzip e 7z - + Author Autor - + aka. aka. - - + + About Arqiver Sobre Arqiver - + Translators Tradutores diff --git a/main.cpp b/main.cpp index 70183b9..7bab660 100644 --- a/main.cpp +++ b/main.cpp @@ -38,7 +38,7 @@ void handleQuitSignals(const std::vector& quitSignals) { int main(int argc, char **argv) { const QString name = "Arqiver"; - const QString version = "0.3.0"; + const QString version = "0.3.1"; const QString option = QString::fromUtf8(argv[1]); if (option == "--help" || option == "-h") { QTextStream out (stdout); diff --git a/mainWin.cpp b/mainWin.cpp index b9cfb6c..e9be758 100644 --- a/mainWin.cpp +++ b/mainWin.cpp @@ -508,15 +508,10 @@ QString mainWin::filterToExtension(const QString& filter) { void mainWin::newArchive() { QString file; - QString path; QString ext = (lastFilter_.isEmpty() ? ".tar.gz" : filterToExtension(lastFilter_)); - if (!saFileList_.isEmpty()) { - path = QFile::exists(saFileList_.at(0)) && QFileInfo(saFileList_.at(0)).isDir() - ? saFileList_.at(0) + (lastFilter_.isEmpty() - ? ".tar.gz" - : filterToExtension(lastFilter_)) - : saFileList_.at(0); - } + QString path; + if (!saFileList_.isEmpty()) + path = saFileList_.at(0); bool retry(true); while (retry) { QFileDialog dlg(this, tr("Create Archive"),