cmd += wxT(" -h ") + server->GetName()
+ wxT(" -p ") + NumToStr((long)server->GetPort())
+ wxT(" -U ") + qtIdent(server->GetUsername())
- + wxT(" -d ") + qtIdent(object->GetDatabase()->GetName());
+ + wxT(" -d ") + commandLineCleanOption(object->GetDatabase()->GetQuotedIdentifier());
return cmd;
}
}
return wxEmptyString;
-}
\ No newline at end of file
+}
+
+// Fixup a (quoted) string for use on the command line
+wxString commandLineCleanOption(const wxString &option)
+{
+ wxString tmp;
+ bool wasQuoted = false;
+
+ if (option.StartsWith(wxT("\"")) && option.EndsWith(wxT("\"")))
+ {
+ tmp = option.AfterFirst((wxChar)'"').BeforeLast((wxChar)'"');
+ wasQuoted = true;
+ }
+ else
+ tmp = option;
+
+#ifdef __WXMSW__
+ if (wasQuoted)
+ tmp.Replace(wxT("\"\""), wxT("\"\"\""));
+ else
+ {
+ tmp.Replace(wxT("\""), wxT("\"\""));
+ tmp.Replace(wxT("\\"), wxT("\\\\"));
+ }
+#else
+ tmp.Replace(wxT("\\"), wxT("\\\\"));
+ tmp.Replace(wxT("\"\""), wxT("\\\""));
+#endif
+
+ if (wasQuoted)
+ tmp = wxT("\"") + tmp + wxT("\"");
+
+ return tmp;
+}
+