]> git.sur5r.net Git - bacula/bacula/commitdiff
Add -w parameter to wx-console to change the temporary directory.
authorNicolas Boichat <nicolas@boichat.ch>
Mon, 15 Nov 2004 16:49:53 +0000 (16:49 +0000)
committerNicolas Boichat <nicolas@boichat.ch>
Mon, 15 Nov 2004 16:49:53 +0000 (16:49 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1697 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/wx-console/TODO
bacula/src/wx-console/console_thread.cpp
bacula/src/wx-console/console_thread.h
bacula/src/wx-console/wxbmainframe.cpp

index 8839f14d806fd4317b50fa05455fed79cf1c5cc0..a877a4ea286921f6779ac0287ced9889a93fa9c2 100644 (file)
@@ -1,3 +1,6 @@
+console_thread: Find an alternate way to get error messages, without using
+  a temporary file. (See Kern's mail 15.11.04 - 17:32)
+
 general : Show nice messages boxes when errors occurs.
 
 general : Bug reported by Kern:
index d27b6e2810053b51778d4712f315c98dd38a6923..ba51097f30cf45be5e930555a99f868370b2a87b 100644 (file)
@@ -51,6 +51,16 @@ int authenticate_director(JCR *jcr, DIRRES *director, CONRES *cons);
 
 bool console_thread::inited = false;
 bool console_thread::configloaded = false;
+wxString console_thread::working_dir = ".";
+
+void console_thread::SetWorkingDirectory(wxString w_dir) {
+   if ((w_dir.Last() == '/') || (w_dir.Last() == '\\')) {
+      console_thread::working_dir = w_dir.Mid(0, w_dir.Length()-1);
+   }
+   else {
+      console_thread::working_dir = w_dir;
+   }
+}
 
 void console_thread::InitLib() {
    if (WSA_Init() != 0) {
@@ -62,7 +72,7 @@ void console_thread::InitLib() {
    init_stack_dump();
    my_name_is(0, NULL, "wx-console");
    //textdomain("bacula-console");
-   working_directory = ".";
+   working_directory = console_thread::working_dir;
    
    inited = true;
 }
@@ -95,11 +105,11 @@ wxString console_thread::LoadConfig(wxString configfile) {
    }
    
    init_msg(NULL, msgs);
-   init_console_msg(".");
+   init_console_msg(console_thread::working_dir);
 
    if (!parse_config(configfile.c_str(), 0)) {
       configloaded = false;
-      wxFile file("./wx-console.conmsg");
+      wxFile file(console_thread::working_dir + "/wx-console.conmsg");
       if (!file.IsOpened())
          return "Unable to retrieve error message.";
       wxString err = "";
@@ -113,12 +123,12 @@ wxString console_thread::LoadConfig(wxString configfile) {
       }
       file.Close();
       term_msg();
-      wxRemoveFile("./wx-console.conmsg");
+      wxRemoveFile(console_thread::working_dir + "/wx-console.conmsg");
       return err;
    }
    
    term_msg();
-   wxRemoveFile("./wx-console.conmsg");
+   wxRemoveFile(console_thread::working_dir + "/wx-console.conmsg");
    init_msg(NULL, NULL);
    
    configloaded = true;
index 2f50be2226a6d12002daf71ec8fc68ac787a0cad..ff126d3d7616612472c92da41eca617661bb3f3f 100644 (file)
@@ -51,12 +51,15 @@ class console_thread : public wxThread
       static void InitLib();
       static void FreeLib();
       static wxString LoadConfig(wxString configfile);
+      static void SetWorkingDirectory(wxString w_dir);
    private:
       static bool inited;
       static bool configloaded;
       
       bool choosingdirector;
       
+      static wxString working_dir;
+      
       int directorchoosen;
       
       BSOCK* UA_sock;
index bd95f2c3055b7b1b42e4d7e60128a4a69060cf9f..15b6e85e93c1963fb408b6fa37d7bd140adaec09 100644 (file)
@@ -339,11 +339,30 @@ void wxbMainFrame::StartConsoleThread(const wxString& config) {
       promptparser = new wxbPromptParser();      
    }
    
-   if (config == "") {   
-      if ((wxTheApp->argc == 3) && (wxString(wxTheApp->argv[1]) == "-c")) {
-         configfile = wxTheApp->argv[2];
+   if (config == "") {
+      configfile = "";
+      
+      if (((wxTheApp->argc % 2) != 1)) {
+         Print("Error while parsing command line arguments, using defaults.\n", CS_DEBUG);
+         Print("Usage: wx-console [-c configfile] [-w tmp]\n", CS_DEBUG);
       }
       else {
+         for (int c = 1; c < wxTheApp->argc; c += 2) {
+            if ((wxTheApp->argc >= c+2) && (wxString(wxTheApp->argv[c]) == "-c")) {
+               configfile = wxTheApp->argv[c+1];
+            }
+            if ((wxTheApp->argc >= c+2) && (wxString(wxTheApp->argv[c]) == "-w")) {
+               console_thread::SetWorkingDirectory(wxTheApp->argv[c+1]);
+            }
+            if (wxTheApp->argv[c][0] != '-') {
+               Print("Error while parsing command line arguments, using defaults.\n", CS_DEBUG);
+               Print("Usage: wx-console [-c configfile] [-w tmp]\n", CS_DEBUG);
+               break;
+            }
+         }
+      }
+      
+      if (configfile == "") {
          wxConfig::Set(new wxConfig("wx-console", "bacula"));
          if (!wxConfig::Get()->Read("/ConfigFile", &configfile)) {
 #ifdef HAVE_MACOSX
@@ -362,10 +381,6 @@ void wxbMainFrame::StartConsoleThread(const wxString& config) {
 #endif //HAVE_WIN32
 #endif //HAVE_MACOSX
             wxConfig::Get()->Write("/ConfigFile", configfile);
-            if (wxTheApp->argc > 1) {
-               Print("Error while parsing command line arguments, using defaults.\n", CS_DEBUG);
-               Print("Usage: wx-console [-c configfile]\n", CS_DEBUG);
-            }
    
             int answer = wxMessageBox(
                               wxString("It seems that it is the first time you run wx-console.\n") <<