Make lamexp_clean_filename() a global function.

This commit is contained in:
LoRd_MuldeR 2011-08-04 20:35:40 +02:00
parent 272cef76f4
commit 93d4fb14ee
4 changed files with 38 additions and 22 deletions

View File

@ -30,7 +30,7 @@
#define VER_LAMEXP_MINOR_LO 3
#define VER_LAMEXP_TYPE Alpha
#define VER_LAMEXP_PATCH 6
#define VER_LAMEXP_BUILD 612
#define VER_LAMEXP_BUILD 613
///////////////////////////////////////////////////////////////////////////////
// Tools versions

View File

@ -1535,6 +1535,39 @@ void lamexp_blink_window(QWidget *poWindow, unsigned int count, unsigned int del
}
}
/*
* Remove forbidden characters from a filename
*/
const QString lamexp_clean_filename(const QString &str)
{
QString fixedStr(str);
fixedStr.replace("\\", "-");
fixedStr.replace(" / ", ", ");
fixedStr.replace("/", ",");
fixedStr.replace(":", "-");
fixedStr.replace("*", "x");
fixedStr.replace("?", "");
fixedStr.replace("<", "[");
fixedStr.replace(">", "]");
fixedStr.replace("|", "!");
return fixedStr;
}
/*
* Remove forbidden characters from a file path
*/
const QString lamexp_clean_filepath(const QString &str)
{
QStringList parts = QString(str).replace("\\", "/").split("/");
for(int i = 0; i < parts.count(); i++)
{
parts[i] = lamexp_clean_filename(parts[i]);
}
return parts.join("/");
}
/*
* Finalization function (final clean-up)
*/

View File

@ -120,6 +120,8 @@ __int64 lamexp_free_diskspace(const QString &path);
bool lamexp_remove_file(const QString &filename);
bool lamexp_themes_enabled(void);
void lamexp_blink_window(QWidget *poWindow, unsigned int count = 10, unsigned int delay = 150);
const QString lamexp_clean_filename(const QString &str);
const QString lamexp_clean_filepath(const QString &str);
//Debug-only functions
SIZE_T lamexp_dbg_private_bytes(void);

View File

@ -39,25 +39,6 @@
#include <float.h>
#include <limits>
////////////////////////////////////////////////////////////
// Helper function
////////////////////////////////////////////////////////////
static QString clean(const QString &str)
{
QString fixedStr(str);
fixedStr.replace("\\", "-");
fixedStr.replace(" / ", ", ");
fixedStr.replace("/", ",");
fixedStr.replace(":", "-");
fixedStr.replace("*", "x");
fixedStr.replace("?", "");
fixedStr.replace("<", "[");
fixedStr.replace(">", "]");
fixedStr.replace("|", "!");
return fixedStr;
}
////////////////////////////////////////////////////////////
// Constructor
////////////////////////////////////////////////////////////
@ -210,10 +191,10 @@ void CueSplitter::run()
//Generate output file name
QString trackTitle = trackMetaInfo.fileName().isEmpty() ? QString().sprintf("Track %02d", trackNo) : trackMetaInfo.fileName();
QString outputFile = QString("%1/[%2] %3 - %4.wav").arg(m_outputDir, QString().sprintf("%02d", trackNo), clean(m_baseName), clean(trackTitle));
QString outputFile = QString("%1/[%2] %3 - %4.wav").arg(m_outputDir, QString().sprintf("%02d", trackNo), lamexp_clean_filename(m_baseName), lamexp_clean_filename(trackTitle));
for(int n = 2; QFileInfo(outputFile).exists(); n++)
{
outputFile = QString("%1/[%2] %3 - %4 (%5).wav").arg(m_outputDir, QString().sprintf("%02d", trackNo), clean(m_baseName), clean(trackTitle), QString::number(n));
outputFile = QString("%1/[%2] %3 - %4 (%5).wav").arg(m_outputDir, QString().sprintf("%02d", trackNo), lamexp_clean_filename(m_baseName), lamexp_clean_filename(trackTitle), QString::number(n));
}
//Call split function