[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[vidalia-svn] r3505: Ah ha! Steven didn't const-ify his arguments because I didn' (in vidalia/trunk/src: common vidalia)
Author: edmanm
Date: 2009-02-02 21:21:55 -0500 (Mon, 02 Feb 2009)
New Revision: 3505
Modified:
vidalia/trunk/src/common/file.cpp
vidalia/trunk/src/common/file.h
vidalia/trunk/src/vidalia/mainwindow.cpp
Log:
Ah ha! Steven didn't const-ify his arguments because I didn't either. Bad
Matt.
Modified: vidalia/trunk/src/common/file.cpp
===================================================================
--- vidalia/trunk/src/common/file.cpp 2009-02-03 02:09:39 UTC (rev 3504)
+++ vidalia/trunk/src/common/file.cpp 2009-02-03 02:21:55 UTC (rev 3505)
@@ -28,21 +28,21 @@
* then the full path to <b>filename</b> will be created. Returns true on
* success, or false on error and <b>errmsg</b> will be set. */
bool
-touch_file(QString filename, bool createdir, QString *errmsg)
+touch_file(const QString &filename, bool createdir, QString *errmsg)
{
/* Expand the file's path if it starts with a shortcut, like "~/" or
* "%APPDATA%" */
- filename = expand_filename(filename);
+ QString expanded = expand_filename(filename);
/* If the file's path doesn't exist and we're supposed to create it, do that
* now. */
- if (createdir && !create_path(QFileInfo(filename).absolutePath())) {
+ if (createdir && !create_path(QFileInfo(expanded).absolutePath())) {
return false;
}
/* Touch the file */
- QFile file(filename);
- if (!QFileInfo(filename).exists()) {
+ QFile file(expanded);
+ if (!QFileInfo(expanded).exists()) {
if (!file.open(QIODevice::WriteOnly)) {
return err(errmsg, file.errorString());
}
@@ -52,12 +52,11 @@
/** Creates all directories in <b>path</b>, if they do not exist. */
bool
-create_path(QString path)
+create_path(const QString &path)
{
QDir dir(path);
if (!dir.exists()) {
- path = dir.absolutePath();
- if (!dir.mkpath(path)) {
+ if (!dir.mkpath(dir.absolutePath())) {
return false;
}
}
@@ -68,14 +67,15 @@
* destination must already exist. Returns true on success, and false
* otherwise. */
bool
-copy_dir(QString source, QString dest)
+copy_dir(const QString &source, const QString &dest)
{
/* Source and destination as QDir's */
QDir src(source);
QDir dst(dest);
/* Get contents of the directory */
- QFileInfoList contents = src.entryInfoList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot);
+ QFileInfoList contents = src.entryInfoList(QDir::Files | QDir::Dirs
+ | QDir::NoDotAndDotDot);
/* Copy each entry in src to dst */
foreach (QFileInfo fileInfo, contents) {
@@ -105,20 +105,21 @@
* expand "%APPDATA%" and "%PROGRAMFILES%". If <b>filename</b> does not
* start with a shortcut, <b>filename</b> will be returned unmodified. */
QString
-expand_filename(QString filename)
+expand_filename(const QString &filename)
{
+ QString fname = filename;
#if defined(Q_OS_WIN32)
- if (filename.startsWith("%APPDATA%\\") ||
- filename.startsWith("%APPDATA%/"))
- return filename.replace(0, 9, win32_app_data_folder());
+ if (fname.startsWith("%APPDATA%\\") ||
+ fname.startsWith("%APPDATA%/"))
+ return fname.replace(0, 9, win32_app_data_folder());
- if (filename.startsWith("%PROGRAMFILES%\\") ||
- filename.startsWith("%PROGRAMFILES%/"))
- return filename.replace(0, 14, win32_program_files_folder());
+ if (fname.startsWith("%PROGRAMFILES%\\") ||
+ fname.startsWith("%PROGRAMFILES%/"))
+ return fname.replace(0, 14, win32_program_files_folder());
#else
- if (filename.startsWith("~/"))
- return filename.replace(0, 1, QDir::homePath());
+ if (fname.startsWith("~/"))
+ return fname.replace(0, 1, QDir::homePath());
#endif
- return filename;
+ return fname;
}
Modified: vidalia/trunk/src/common/file.h
===================================================================
--- vidalia/trunk/src/common/file.h 2009-02-03 02:09:39 UTC (rev 3504)
+++ vidalia/trunk/src/common/file.h 2009-02-03 02:21:55 UTC (rev 3505)
@@ -23,20 +23,21 @@
/** Create an empty file named <b>filename</b>. if <b>createdir</b> is true,
* then the full path to <b>filename</b> will be created. Returns true on
* success, or false on error and <b>errmsg</b> will be set. */
-bool touch_file(QString filename, bool createdir = false, QString *errmsg = 0);
+bool touch_file(const QString &filename, bool createdir = false,
+ QString *errmsg = 0);
/** Creates all directories in <b>path</b>, if they do not exist. */
-bool create_path(QString path);
+bool create_path(const QString &path);
/** Expands <b>filename</b> if it starts with "~/". On Windows, this will
* expand "%APPDATA%" and "%PROGRAMFILES%". If <b>filename</b> does not
* start with a shortcut, <b>filename</b> will be returned unmodified. */
-QString expand_filename(QString filename);
+QString expand_filename(const QString &filename);
/** Recursively copy the contents of one directory to another. The
* destination must already exist. Returns true on success, and false
* otherwise. */
-bool copy_dir(QString source, QString dest);
+bool copy_dir(const QString &source, const QString &dest);
#endif
Modified: vidalia/trunk/src/vidalia/mainwindow.cpp
===================================================================
--- vidalia/trunk/src/vidalia/mainwindow.cpp 2009-02-03 02:09:39 UTC (rev 3504)
+++ vidalia/trunk/src/vidalia/mainwindow.cpp 2009-02-03 02:21:55 UTC (rev 3505)
@@ -639,7 +639,9 @@
QString imExecutable = settings.getIMExecutable();
/* A subprocess is finished if it successfully exited or was never asked to start */
- bool browserDone = (browserExecutable.isEmpty() && browserDirectory.isEmpty()) || _browserProcess->isDone();
+ bool browserDone = (browserExecutable.isEmpty()
+ && browserDirectory.isEmpty())
+ || _browserProcess->isDone();
bool imDone = imExecutable.isEmpty() || _imProcess->isDone();
/* Exit if both subprocesses are finished */