[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [vidalia/alpha] Make relative paths relative to Vidalia's binary path



commit d718bfe5b91ab7f944727e1f34c8f1717818f2f1
Author: Tomás Touceda <chiiph@xxxxxxxxxxxxxx>
Date:   Sat Mar 24 12:58:04 2012 -0300

    Make relative paths relative to Vidalia's binary path
---
 src/vidalia/MainWindow.cpp         |    7 ++++++-
 src/vidalia/config/TorSettings.cpp |   12 ++++++++++--
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/src/vidalia/MainWindow.cpp b/src/vidalia/MainWindow.cpp
index c0321d5..b203b84 100644
--- a/src/vidalia/MainWindow.cpp
+++ b/src/vidalia/MainWindow.cpp
@@ -635,6 +635,8 @@ MainWindow::start()
 
   /* Specify Tor's data directory, if different from the default */
   QString dataDirectory = settings.getDataDirectory();
+  if(QDir(dataDirectory).isRelative())
+    dataDirectory = QCoreApplication::applicationDirPath() + "/" + dataDirectory;
   QString expDataDirectory = expand_filename(dataDirectory);
 
   if(settings.getControlMethod() == ControlMethod::Port) {
@@ -681,7 +683,10 @@ MainWindow::start()
    * start. */
   _isIntentionalExit = true;
   /* Kick off the Tor process */
-  _torControl->start(settings.getExecutable(), args);
+  QString torExecutable = settings.getExecutable();
+  if(QDir(QFileInfo(torExecutable).filePath()).isRelative())
+    torExecutable = QCoreApplication::applicationDirPath() + "/" + torExecutable;
+  _torControl->start(torExecutable, args);
 
   QString errmsg;
   while(not _torControl->isRunning()) {
diff --git a/src/vidalia/config/TorSettings.cpp b/src/vidalia/config/TorSettings.cpp
index 0a7b2d1..fe7e4c1 100644
--- a/src/vidalia/config/TorSettings.cpp
+++ b/src/vidalia/config/TorSettings.cpp
@@ -202,7 +202,11 @@ TorSettings::getTorrc() const
   TorControl *tc = torControl();
   if (tc && tc->isConnected() && tc->getInfo("config-file", torrc))
     return QDir::convertSeparators(torrc);
-  return QDir::convertSeparators(localValue(SETTING_TORRC).toString());
+
+  torrc = localValue(SETTING_TORRC).toString();
+  if(QDir(QFileInfo(torrc).filePath()).isRelative())
+    torrc = QCoreApplication::applicationDirPath() + "/" + torrc;
+  return QDir::convertSeparators(torrc);
 }
 
 /** Sets the torrc that will be used when starting Tor.
@@ -222,7 +226,11 @@ TorSettings::getDefaultsTorrc() const
   // TorControl *tc = torControl();
   // if (tc && tc->isConnected() && tc->getInfo("config-file", torrc))
   //   return QDir::convertSeparators(torrc);
-  return QDir::convertSeparators(localValue(SETTING_DEFAULTS_TORRC).toString());
+
+  torrc = localValue(SETTING_DEFAULTS_TORRC).toString();
+  if(QDir(QFileInfo(torrc).filePath()).isRelative())
+    torrc = QCoreApplication::applicationDirPath() + "/" + torrc;
+  return QDir::convertSeparators(torrc);
 }
 
 /** Sets the defaults torrc that will be used when starting Tor.



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits