2016-05-25 Fred Gleason <fredg@paravelsystems.com>

Added a '--escape-string=' parameters to rdexport(1).
This commit is contained in:
Fred Gleason 2016-05-25 18:49:31 -04:00
parent c952aa57b5
commit ef27640396
3 changed files with 37 additions and 1 deletions

View File

@ -15168,3 +15168,5 @@
Ubuntu 16.04 [GitHub pull request #000130].
2016-05-25 Fred Gleason <fredg@paravelsystems.com>
* Incremented the package version to 2.13.0int00.
2016-05-25 Fred Gleason <fredg@paravelsystems.com>
Added a '--escape-string=' parameters to rdexport(1).

View File

@ -41,6 +41,7 @@ MainObject::MainObject(QObject *parent)
:QObject(parent)
{
export_metadata_pattern="%n_%j";
export_escape_string="_";
//
// Read Command Options
@ -73,6 +74,14 @@ MainObject::MainObject(QObject *parent)
}
cmd->setProcessed(i,true);
}
if(cmd->key(i)=="--escape-string") {
if(cmd->value(i)!=SanitizePath(cmd->value(i))) {
fprintf(stderr,"rdxport: illegal character(s) in escape string\n");
exit(256);
}
export_escape_string=cmd->value(i);
cmd->setProcessed(i,true);
}
if(cmd->key(i)=="--group") {
export_groups.push_back(cmd->value(i));
cmd->setProcessed(i,true);
@ -326,7 +335,7 @@ QString MainObject::ResolveOutputName(RDCart *cart,RDCut *cut,
name.replace("%u",cart->userDefined());
name.replace("%y",QString().sprintf("%d",cart->year()));
QString ret=name;
QString ret=SanitizePath(name);
int count=1;
while(QFile::exists(export_output_to+"/"+ret+"."+exten)) {
ret=name+QString().sprintf("[%d]",count++);
@ -336,6 +345,29 @@ QString MainObject::ResolveOutputName(RDCart *cart,RDCut *cut,
}
QString MainObject::SanitizePath(const QString &pathname) const
{
//
// Remove illegal characters from the filepath.
// (from https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247%28v=vs.85%29.aspx#naming_conventions
//
QString ret=pathname;
ret.replace("/",export_escape_string);
ret.replace(":",export_escape_string);
ret.replace("<",export_escape_string);
ret.replace(">",export_escape_string);
ret.replace(":",export_escape_string);
ret.replace("\"",export_escape_string);
ret.replace("\\",export_escape_string);
ret.replace("|",export_escape_string);
ret.replace("?",export_escape_string);
ret.replace("*",export_escape_string);
return ret;
}
void MainObject::Verbose(const QString &msg)
{
if(export_verbose) {

View File

@ -49,6 +49,7 @@ class MainObject : public QObject
void ExportCart(unsigned cartnum);
void ExportCut(RDCart *cart,RDCut *cut);
QString ResolveOutputName(RDCart *cart,RDCut *cut,const QString &exten);
QString SanitizePath(const QString &pathname) const;
void Verbose(const QString &msg);
std::vector<unsigned> export_start_carts;
std::vector<unsigned> export_end_carts;
@ -60,6 +61,7 @@ class MainObject : public QObject
RDStation *export_station;
RDUser *export_user;
bool export_verbose;
QString export_escape_string;
};