From 7f736611619a6a7641f16dc7f9ce5085b594d940 Mon Sep 17 00:00:00 2001 From: LoRd_MuldeR Date: Tue, 15 Aug 2017 22:47:09 +0200 Subject: [PATCH] Some tweaks to output file name generation. This should preserve original file names containing multiple dot (.) characters right before the file extension. --- etc/Translation/Blank.ts | 27 ++++++++++++-------- etc/Translation/LameXP_DE.ts | 27 ++++++++++++-------- etc/Translation/LameXP_ES.ts | 27 ++++++++++++-------- etc/Translation/LameXP_FR.ts | 27 ++++++++++++-------- etc/Translation/LameXP_HU.ts | 27 ++++++++++++-------- etc/Translation/LameXP_IT.ts | 27 ++++++++++++-------- etc/Translation/LameXP_KR.ts | 27 ++++++++++++-------- etc/Translation/LameXP_PL.ts | 27 ++++++++++++-------- etc/Translation/LameXP_RU.ts | 27 ++++++++++++-------- etc/Translation/LameXP_SV.ts | 27 ++++++++++++-------- etc/Translation/LameXP_TW.ts | 27 ++++++++++++-------- etc/Translation/LameXP_UK.ts | 29 ++++++++++++--------- etc/Translation/LameXP_ZH.ts | 27 ++++++++++++-------- res/localization/LameXP_UK.qm | Bin 93425 -> 94222 bytes src/Config.h | 2 +- src/Thread_Process.cpp | 46 +++++++++++++++++++++------------- 16 files changed, 238 insertions(+), 163 deletions(-) diff --git a/etc/Translation/Blank.ts b/etc/Translation/Blank.ts index 74630f50..58cca4d5 100644 --- a/etc/Translation/Blank.ts +++ b/etc/Translation/Blank.ts @@ -3066,57 +3066,62 @@ - + The target output directory doesn't exist and could NOT be created: - + The target output directory is NOT writable: - + + Failed to generate non-existing target file name! + + + + Unknown File Name - + Unknown Title - + Unknown Artist - + Unknown Album - + Unknown Comment - + Target output file already exists, going to skip this file: - + If you don't want existing files to be skipped, please change the overwrite mode! - + Target output file already exists, going to delete existing file: - + Failed to delete existing target file, will save to another file name! diff --git a/etc/Translation/LameXP_DE.ts b/etc/Translation/LameXP_DE.ts index 3f334974..6810fa23 100644 --- a/etc/Translation/LameXP_DE.ts +++ b/etc/Translation/LameXP_DE.ts @@ -3059,37 +3059,42 @@ Die Quell-Audiodatei konnte nicht zum Lesen geöffnet werden: - + The target output directory doesn't exist and could NOT be created: Das Zielverzeichnis existiert nicht und konnte nicht erstellt werden: - + The target output directory is NOT writable: In das Zielverzeichnis kann nicht geschrieben werden: - + + Failed to generate non-existing target file name! + + + + Unknown File Name Unbekannter Dateiname - + Unknown Title Unbekannter Titel - + Unknown Artist Unbekannter Künstler - + Unknown Album Unbekanntes Album - + Unknown Comment Unbekannter Kommentar @@ -3110,22 +3115,22 @@ Übersprungen. - + Target output file already exists, going to skip this file: Zieldatei existiert bereits, die Datei wird übersprungen: - + If you don't want existing files to be skipped, please change the overwrite mode! Wenn existierende Dateien nicht übersprungen werden sollen, ändern Sie bitte den Überschreiben-Modus! - + Target output file already exists, going to delete existing file: Zieldatei existiert bereits, die Datei wird gelöscht und überschrieben: - + Failed to delete existing target file, will save to another file name! Die existierende Datei konnte nicht gelöscht werden, ein anderer Dateiname wird gewählt! diff --git a/etc/Translation/LameXP_ES.ts b/etc/Translation/LameXP_ES.ts index 6ed7c9d6..a825011f 100644 --- a/etc/Translation/LameXP_ES.ts +++ b/etc/Translation/LameXP_ES.ts @@ -3059,37 +3059,42 @@ No se puede abrir el archivo de entrada para su lectura: - + The target output directory doesn't exist and could NOT be created: La carpeta de salida no existe y NO puede ser creada: - + The target output directory is NOT writable: NO se puede escribir en la carpeta de salida: - + + Failed to generate non-existing target file name! + + + + Unknown File Name Nombre de archivo desconocido - + Unknown Title Título desconocido - + Unknown Artist Artista desconocido - + Unknown Album Álbum desconocido - + Unknown Comment Comentario desconocido @@ -3110,22 +3115,22 @@ Omitidos. - + Target output file already exists, going to skip this file: El archivo de destino ya existe, se omitirá este archivo: - + If you don't want existing files to be skipped, please change the overwrite mode! ¡Si no quiere sobreescribir los archivos existentes, cambie el modo sobreescritura por favor! - + Target output file already exists, going to delete existing file: El archivo de destino ya existe, se eliminará este archivo: - + Failed to delete existing target file, will save to another file name! ¡Error al eliminar el archivo de destino existente, se guardará con otro nombre! diff --git a/etc/Translation/LameXP_FR.ts b/etc/Translation/LameXP_FR.ts index fb617eb1..90303844 100644 --- a/etc/Translation/LameXP_FR.ts +++ b/etc/Translation/LameXP_FR.ts @@ -3066,37 +3066,42 @@ Sélection automatique (par défaut) Le fichier audio source n'a pas pu être ouvert pour la lecture: - + The target output directory doesn't exist and could NOT be created: Le répertoire de sortie cible n'existe pas et ne peut PAS être créé: - + The target output directory is NOT writable: Le répertoire de sortie cible n'est pas accessible en écriture: - + + Failed to generate non-existing target file name! + + + + Unknown File Name Nom de fichier inconnu - + Unknown Title Titre inconnu - + Unknown Artist Artiste inconnu - + Unknown Album Album inconnu - + Unknown Comment Commentaire inconnu @@ -3118,22 +3123,22 @@ Sélection automatique (par défaut) Ignoré. - + Target output file already exists, going to skip this file: Le fichier de sortie existe déjà, il sera ignoré : - + If you don't want existing files to be skipped, please change the overwrite mode! Si vous ne voulez pas ignorer les fichiers existants, veuillez changer le mode de remplacement ! - + Target output file already exists, going to delete existing file: Le fichier de sortie existe déjà, il sera supprimé : - + Failed to delete existing target file, will save to another file name! Impossible de supprimer le fichier cible existant, il sera enregistré sous un autre nom ! diff --git a/etc/Translation/LameXP_HU.ts b/etc/Translation/LameXP_HU.ts index d02df75d..8869737f 100644 --- a/etc/Translation/LameXP_HU.ts +++ b/etc/Translation/LameXP_HU.ts @@ -3066,57 +3066,62 @@ A forrás hangfájl nem nyitható meg olvasásra: - + The target output directory doesn't exist and could NOT be created: A cél kimeneti könyvtár nem létezik, és NEM hozható létre: - + The target output directory is NOT writable: A cél kimeneti könyvtár NEM írható: - + + Failed to generate non-existing target file name! + + + + Unknown File Name Ismeretlen fájlnév - + Unknown Title Ismeretlen cím - + Unknown Artist Ismeretlen előadó - + Unknown Album Ismeretlen album - + Unknown Comment Ismeretlen hozzászólás - + Target output file already exists, going to skip this file: A cél kimeneti fájl már létezik, ez a fájl ki lesz hagyva: - + If you don't want existing files to be skipped, please change the overwrite mode! Ha nem szeretné a meglévő fájlokat kihagyni, kérjük, változtassa meg a felülírási módot! - + Target output file already exists, going to delete existing file: A cél kimeneti fájl már létezik, a meglévő fájl törlésre kerül: - + Failed to delete existing target file, will save to another file name! Nem sikerült törölni a meglévő cél fájlt. Az állomány másik fájlnéven lesz elmentve! diff --git a/etc/Translation/LameXP_IT.ts b/etc/Translation/LameXP_IT.ts index 59cb9a26..ee9ad0eb 100644 --- a/etc/Translation/LameXP_IT.ts +++ b/etc/Translation/LameXP_IT.ts @@ -3125,38 +3125,43 @@ Il file audio sorgente non può essere aperto per la lettura: - + The target output directory doesn't exist and could NOT be created: La cartella di destinazione assegnata non esiste e NON può essere creata: - + The target output directory is NOT writable: La directory di destinazione assegnata è di SOLA LETTURA: La directory di destinazione assegnata NON è scrivibile: - + + Failed to generate non-existing target file name! + + + + Unknown File Name Nome File Sconosciuto - + Unknown Title Titolo Sconosciuto - + Unknown Artist Artista Sconosciuto - + Unknown Album Album Sconosciuto - + Unknown Comment Commento Sconosciuto @@ -3177,22 +3182,22 @@ Saltato. - + Target output file already exists, going to skip this file: Il file di destinazione esiste già, questo file verrà saltato: - + If you don't want existing files to be skipped, please change the overwrite mode! Se non vuoi saltare i file esistenti, cambia la modalità di sovrascrittura! - + Target output file already exists, going to delete existing file: Il file di destinazione esiste già, il file esistente verrà eliminato: - + Failed to delete existing target file, will save to another file name! Impossibile eliminare il file di destinazione esistente, il file verrà salvato con un altro nome! diff --git a/etc/Translation/LameXP_KR.ts b/etc/Translation/LameXP_KR.ts index 79708223..8677e30c 100644 --- a/etc/Translation/LameXP_KR.ts +++ b/etc/Translation/LameXP_KR.ts @@ -3050,37 +3050,42 @@ 원본 오디오 파일을 열 수 없음: - + The target output directory doesn't exist and could NOT be created: 대상 출력 디렉터리가 존재하지 않으며, 만들 수 없습니다: - + The target output directory is NOT writable: 대상 출력 디렉터리에 쓰기 불가: - + + Failed to generate non-existing target file name! + + + + Unknown File Name 알수 없는 파일명 - + Unknown Title 알수 없는 제목 - + Unknown Artist 알수 없는 가수 - + Unknown Album 알수 없는 앨범 - + Unknown Comment 알수 없는 설명 @@ -3101,22 +3106,22 @@ 건너뜀. - + Target output file already exists, going to skip this file: 대상 출력 파일이 이미 존재합니다. 건너뛰기할 파일: - + If you don't want existing files to be skipped, please change the overwrite mode! 기존 파일을 건너뛰기하지 않으려면, 덮어쓰기 방식을 변경하시기 바랍니다! - + Target output file already exists, going to delete existing file: 대상 출력 파일이 이미 존재합니다. 건너뛰기할 파일: - + Failed to delete existing target file, will save to another file name! 기존 대상 파일 삭제 실패. 다른 파일명으로 저장됩니다! diff --git a/etc/Translation/LameXP_PL.ts b/etc/Translation/LameXP_PL.ts index 88fe8a61..50f3356e 100644 --- a/etc/Translation/LameXP_PL.ts +++ b/etc/Translation/LameXP_PL.ts @@ -3083,57 +3083,62 @@ Źródłowy plik dźwiękowy nie mógł zostać otworzony: - + The target output directory doesn't exist and could NOT be created: Lokalizacja docelowa nie istnieje lu NIE mogła zostać utworzona: - + The target output directory is NOT writable: Nie można zapisać do lokalizacji docelowej: - + + Failed to generate non-existing target file name! + + + + Unknown File Name Nieznana nazwa pliku - + Unknown Title Nieznany Tytuł - + Unknown Artist Nieznany Artysta - + Unknown Album Nieznany Album - + Unknown Comment Nieznany Komentarz - + Target output file already exists, going to skip this file: Plik wynikowy już istnieje, zostanie pominięty plik: - + If you don't want existing files to be skipped, please change the overwrite mode! Jeśli nie chcesz aby istniejące pliki były pomijane, zmień tryb nadpisywania! - + Target output file already exists, going to delete existing file: Plik wynikowy już istnieje, zostanie usunięty plik: - + Failed to delete existing target file, will save to another file name! Usuwanie istniejącego pliku zakończone niepowodzeniem, nowy plik zostanie zapisany pod inną nazwą! diff --git a/etc/Translation/LameXP_RU.ts b/etc/Translation/LameXP_RU.ts index 310c66d5..5dd71674 100644 --- a/etc/Translation/LameXP_RU.ts +++ b/etc/Translation/LameXP_RU.ts @@ -3074,37 +3074,42 @@ Исходный аудио файл не может быть открыт: - + The target output directory doesn't exist and could NOT be created: Папка для выходных файлов не существует и не может быть создана: - + The target output directory is NOT writable: Папка для выходных файлов недоступна для записи: - + + Failed to generate non-existing target file name! + + + + Unknown File Name Неизвестное имя файла - + Unknown Title Неизвестное Название - + Unknown Artist Неизвестный Артист - + Unknown Album Неизвестный Альбом - + Unknown Comment Неизвестный Комментарий @@ -3125,22 +3130,22 @@ Пропущен. - + Target output file already exists, going to skip this file: Файл уже существует, будет пропущен: - + If you don't want existing files to be skipped, please change the overwrite mode! Если Вы не хотите пропускать уже существующие файлы, пожалуйста, измените режим перезаписи! - + Target output file already exists, going to delete existing file: Файл уже существует, будет удалён: - + Failed to delete existing target file, will save to another file name! Ошибка удаления существующего файла, будет сохранение с другим именем! diff --git a/etc/Translation/LameXP_SV.ts b/etc/Translation/LameXP_SV.ts index 328f0cc1..c9e715f9 100644 --- a/etc/Translation/LameXP_SV.ts +++ b/etc/Translation/LameXP_SV.ts @@ -3076,57 +3076,62 @@ Källfilen kan inte öppnas för läsning: - + The target output directory doesn't exist and could NOT be created: Målmappen finns inte och kan inte skapas: - + The target output directory is NOT writable: Målmappen är INTE skrivbar: - + + Failed to generate non-existing target file name! + + + + Unknown File Name Okänt filnamn - + Unknown Title Okänd titel - + Unknown Artist Okänd artist - + Unknown Album Okänt album - + Unknown Comment Okänd kommentar - + Target output file already exists, going to skip this file: Målfilen finns redan! Den här filen hoppas över: - + If you don't want existing files to be skipped, please change the overwrite mode! Om du inte vill att befintliga filer hoppas över, måste du ändra överskrivningsläge! - + Target output file already exists, going to delete existing file: Målfilen finns redan! Befintlig fil kommer att tas bort: - + Failed to delete existing target file, will save to another file name! Kunde inte ta bort befintlig målfil. Sparar med annat filnamn! diff --git a/etc/Translation/LameXP_TW.ts b/etc/Translation/LameXP_TW.ts index 8ab49037..bd34760b 100644 --- a/etc/Translation/LameXP_TW.ts +++ b/etc/Translation/LameXP_TW.ts @@ -3050,37 +3050,42 @@ 無法打開源音頻文件進行讀取: - + The target output directory doesn't exist and could NOT be created: 目標輸出目錄不存在,無法創建: - + The target output directory is NOT writable: 目標輸出目錄不是可寫: - + + Failed to generate non-existing target file name! + + + + Unknown File Name 未知文件名稱 - + Unknown Title 未知標題 - + Unknown Artist 未知藝術家 - + Unknown Album 未知專輯 - + Unknown Comment 未知評論 @@ -3101,22 +3106,22 @@ 跳過. - + Target output file already exists, going to skip this file: 目標輸出文件已經存在, 將跳過此文件: - + If you don't want existing files to be skipped, please change the overwrite mode! 如果你不希望被跳過已存在的文件, 請更改覆蓋模式! - + Target output file already exists, going to delete existing file: 目標輸出文件已經存在, 要刪除現有的文件: - + Failed to delete existing target file, will save to another file name! 無法刪除現有目標文件, 將保存到另一個文件名! diff --git a/etc/Translation/LameXP_UK.ts b/etc/Translation/LameXP_UK.ts index e338d352..f1524edf 100644 --- a/etc/Translation/LameXP_UK.ts +++ b/etc/Translation/LameXP_UK.ts @@ -1,6 +1,6 @@ - + AboutDialog @@ -3067,37 +3067,42 @@ Неможливо відкрити для читання вхідний файл аудіо: - + The target output directory doesn't exist and could NOT be created: Вихідної теки не існує і її неможливо створити: - + The target output directory is NOT writable: До вихідної теки неможливо проводити запис: - + + Failed to generate non-existing target file name! + + + + Unknown File Name Невідома назва файла - + Unknown Title Невідомий заголовок - + Unknown Artist Невідомий виконавець - + Unknown Album Невідомий альбом - + Unknown Comment Невідомий коментар @@ -3118,22 +3123,22 @@ Пропущено. - + Target output file already exists, going to skip this file: Вихідний цільовий файл вже існує, спроба пропустити цей файл: - + If you don't want existing files to be skipped, please change the overwrite mode! Якщо ви не хочете, щоб існуючі файли були пропущені, будь ласка, змініть режим перезапису! - + Target output file already exists, going to delete existing file: Вихідний цільовий файл вже існує, спроба видалити існуючий файл: - + Failed to delete existing target file, will save to another file name! Неможливо видалити існуючий файл, збереження буде проведено до файла з іншою назвою! diff --git a/etc/Translation/LameXP_ZH.ts b/etc/Translation/LameXP_ZH.ts index e8ff6d2e..ef8a59c5 100644 --- a/etc/Translation/LameXP_ZH.ts +++ b/etc/Translation/LameXP_ZH.ts @@ -3050,37 +3050,42 @@ 无法打开源音频文件进行读取: - + The target output directory doesn't exist and could NOT be created: 目标输出目录不存在且无法创建: - + The target output directory is NOT writable: 目标输出目录不可写: - + + Failed to generate non-existing target file name! + + + + Unknown File Name 未知文件名称 - + Unknown Title 未知标题 - + Unknown Artist 未知艺术家 - + Unknown Album 未知专辑 - + Unknown Comment 未知注释 @@ -3101,22 +3106,22 @@ 跳过。 - + Target output file already exists, going to skip this file: 目标输出文件已经存在, 将跳过此文件: - + If you don't want existing files to be skipped, please change the overwrite mode! 如果你不希望跳过已存在的文件, 请更改覆盖模式! - + Target output file already exists, going to delete existing file: 目标输出文件已经存在, 将删除现有的文件: - + Failed to delete existing target file, will save to another file name! 无法删除现有目标文件, 将保存为另一个文件名! diff --git a/res/localization/LameXP_UK.qm b/res/localization/LameXP_UK.qm index 1e84b4ef0ff65564cda1fc272f71866ed86dd934..118814bdd8b422a8a438add0351c81fd030a1c84 100644 GIT binary patch delta 639 zcmex(leO;wtEkP66p2&s=S)4TD6>Cd;oiGW3=E#$YWp(a%F0M70AFCvV5{EOD6l{TlW|k z1CDHNW#MCDitN}tl?`ZwU+rX8j*0Bkm-8_&`kHT^$`QxP6tQaZSKen#{*xx(<-5le zShRUBzZfG^NdDxj0_&KZ z$g&u)II&o;II`HXgaKJT3<@k(K(-x=J&<;0P+)LnC}v0oikh%kv-ksPBcM7H78@XG z%VIHoZXBcd>pBSmdW0L^7&M8v;$SW-&l>ttrq{gXs#qjH1);`!ljn z4wxW4y*`~$$=4p}8FQdy7>fssDUvTdLNZcOEL6xyELKQLP0fS)B_}mSA*oWK1f;Au zwMb7PASZSD&lEb delta 187 zcmV;s07U0p02KJK6>k9nHVg*Zw2ZA00IaCeO~1N0O_8SEd*(^o&*g70#=K&tp;uZ0!_w~9SD)L zwg_DX0#&V(6%OVCPTQ0H4&DM#4YS=376AfL_mlMyt^!lwv!xNX0s>UGlU)=(0!@FD pofMM-SIvVm6}K`K0Xt2%Bx3>A0+*;}0n@jRXaP?Fw_<7mtOdIeM9=^L diff --git a/src/Config.h b/src/Config.h index ae2245db..e1861728 100644 --- a/src/Config.h +++ b/src/Config.h @@ -35,7 +35,7 @@ #define VER_LAMEXP_MINOR_LO 6 #define VER_LAMEXP_TYPE Alpha #define VER_LAMEXP_PATCH 2 -#define VER_LAMEXP_BUILD 2005 +#define VER_LAMEXP_BUILD 2006 #define VER_LAMEXP_CONFG 2002 /////////////////////////////////////////////////////////////////////////////// diff --git a/src/Thread_Process.cpp b/src/Thread_Process.cpp index 10ca521d..765faa1e 100644 --- a/src/Thread_Process.cpp +++ b/src/Thread_Process.cpp @@ -415,7 +415,6 @@ int ProcessThread::generateOutFileName(QString &outFileName) readTest.close(); } - const QString baseName = sourceFile.completeBaseName(); QDir targetDir(MUtils::clean_file_path(m_outputDirectory.isEmpty() ? sourceFile.canonicalPath() : m_outputDirectory, false)); //Prepend relative source file path? @@ -457,12 +456,15 @@ int ProcessThread::generateOutFileName(QString &outFileName) writeTest.remove(); } - //Apply rename pattern - const QString fileName = MUtils::clean_file_name(applyRegularExpression(applyRenamePattern(baseName, m_audioFile.metaInfo())), true); + //File extension + const QString fileExt = m_renameFileExt.isEmpty() ? QString::fromUtf8(m_encoder->toEncoderInfo()->extension()) : m_renameFileExt; + + //Generate file name + const QString fileName = MUtils::clean_file_name(QString("%1.%2").arg(applyRegularExpression(applyRenamePattern(sourceFile.completeBaseName(), m_audioFile.metaInfo())), fileExt), true); + qWarning("fileName: \"%s\"", MUTILS_UTF8(fileName)); //Generate full output path - const QString fileExt = m_renameFileExt.isEmpty() ? QString::fromUtf8(m_encoder->toEncoderInfo()->extension()) : m_renameFileExt; - outFileName = QString("%1/%2.%3").arg(targetDir.canonicalPath(), fileName, fileExt); + outFileName = QString("%1/%2").arg(targetDir.canonicalPath(), fileName); //Skip file, if target file exists (optional!) if((m_overwriteMode == OverwriteMode_SkipExisting) && QFileInfo(outFileName).exists()) @@ -476,39 +478,47 @@ int ProcessThread::generateOutFileName(QString &outFileName) if((m_overwriteMode == OverwriteMode_Overwrite) && QFileInfo(outFileName).exists() && QFileInfo(outFileName).isFile()) { handleMessage(QString("%1\n%2\n").arg(tr("Target output file already exists, going to delete existing file:"), QDir::toNativeSeparators(outFileName))); + bool removed = false; if(sourceFile.canonicalFilePath().compare(QFileInfo(outFileName).absoluteFilePath(), Qt::CaseInsensitive) != 0) { for(int i = 0; i < 16; i++) { if(QFile::remove(outFileName)) { + removed = true; break; } MUtils::OS::sleep_ms(1); } } - if(QFileInfo(outFileName).exists()) + if(!removed) { handleMessage(QString("%1\n").arg(tr("Failed to delete existing target file, will save to another file name!"))); } } - int n = 1; - //Generate final name - while(QFileInfo(outFileName).exists() && (n < (INT_MAX/2))) + for (int n = 2; n <= 99999; ++n) { - outFileName = QString("%1/%2 (%3).%4").arg(targetDir.canonicalPath(), fileName, QString::number(++n), fileExt); + //Check file existence + QFileInfo outFileInfo(outFileName); + if (outFileInfo.exists()) + { + outFileName = QString("%1/%2 (%3).%4").arg(outFileInfo.canonicalPath(), outFileInfo.completeBaseName(), QString::number(n), outFileInfo.suffix()); + continue; + } + + //Create placeholder + QFile placeholder(outFileName); + if (placeholder.open(QIODevice::WriteOnly)) + { + placeholder.close(); + return 1; + } } - //Create placeholder - QFile placeholder(outFileName); - if(placeholder.open(QIODevice::WriteOnly)) - { - placeholder.close(); - } - - return 1; + handleMessage(QString("%1\n").arg(tr("Failed to generate non-existing target file name!"))); + return 0; } QString ProcessThread::applyRenamePattern(const QString &baseName, const AudioFileModel_MetaInfo &metaInfo)