summaryrefslogtreecommitdiffstats
path: root/depends/util/src/pathutils.cpp
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2013-11-04 02:53:05 +0100
committerPetr Mrázek <peterix@gmail.com>2013-11-04 02:53:05 +0100
commitbb7e8985f6d189de0acac6a1c3033cb16378c1fb (patch)
tree7c2e88c7184a7f5acf5e7a03be5c5f0bf6904113 /depends/util/src/pathutils.cpp
parentd6e4fb29713d6ce55b092c0e22412f6121e7f516 (diff)
downloadMultiMC-bb7e8985f6d189de0acac6a1c3033cb16378c1fb.tar
MultiMC-bb7e8985f6d189de0acac6a1c3033cb16378c1fb.tar.gz
MultiMC-bb7e8985f6d189de0acac6a1c3033cb16378c1fb.tar.lz
MultiMC-bb7e8985f6d189de0acac6a1c3033cb16378c1fb.tar.xz
MultiMC-bb7e8985f6d189de0acac6a1c3033cb16378c1fb.zip
Reformat and (slightly) decruft all the things.
Diffstat (limited to 'depends/util/src/pathutils.cpp')
-rw-r--r--depends/util/src/pathutils.cpp35
1 files changed, 16 insertions, 19 deletions
diff --git a/depends/util/src/pathutils.cpp b/depends/util/src/pathutils.cpp
index ad8d7566..485d03e8 100644
--- a/depends/util/src/pathutils.cpp
+++ b/depends/util/src/pathutils.cpp
@@ -3,7 +3,7 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@@ -41,7 +41,7 @@ QString AbsolutePath(QString path)
/**
* Normalize path
- *
+ *
* Any paths inside the current directory will be normalized to relative paths (to current)
* Other paths will be made absolute
*/
@@ -85,7 +85,7 @@ QString DirNameFromString(QString string, QString inDir)
{
num++;
dirName = RemoveInvalidFilenameChars(dirName, '-') + QString::number(num);
-
+
// If it's over 9000
if (num > 9000)
return "";
@@ -95,59 +95,56 @@ QString DirNameFromString(QString string, QString inDir)
bool ensureFilePathExists(QString filenamepath)
{
- QFileInfo a ( filenamepath );
+ QFileInfo a(filenamepath);
QDir dir;
QString ensuredPath = a.path();
- bool success = dir.mkpath ( ensuredPath );
+ bool success = dir.mkpath(ensuredPath);
return success;
}
bool ensureFolderPathExists(QString foldernamepath)
{
- QFileInfo a ( foldernamepath );
+ QFileInfo a(foldernamepath);
QDir dir;
QString ensuredPath = a.filePath();
- bool success = dir.mkpath ( ensuredPath );
+ bool success = dir.mkpath(ensuredPath);
return success;
}
-
bool copyPath(QString src, QString dst)
{
QDir dir(src);
if (!dir.exists())
return false;
- if(!ensureFolderPathExists(dst))
+ if (!ensureFolderPathExists(dst))
return false;
- foreach (QString d, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot))
+ foreach(QString d, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot))
{
QString inner_src = src + QDir::separator() + d;
QString inner_dst = dst + QDir::separator() + d;
copyPath(inner_src, inner_dst);
}
- foreach (QString f, dir.entryList(QDir::Files))
+ foreach(QString f, dir.entryList(QDir::Files))
{
QFile::copy(src + QDir::separator() + f, dst + QDir::separator() + f);
}
return true;
}
-void openDirInDefaultProgram ( QString path, bool ensureExists )
+void openDirInDefaultProgram(QString path, bool ensureExists)
{
QDir parentPath;
- QDir dir( path );
- if(!dir.exists())
+ QDir dir(path);
+ if (!dir.exists())
{
parentPath.mkpath(dir.absolutePath());
}
- QDesktopServices::openUrl ( "file:///" + dir.absolutePath() );
+ QDesktopServices::openUrl("file:///" + dir.absolutePath());
}
-void openFileInDefaultProgram ( QString filename )
+void openFileInDefaultProgram(QString filename)
{
- QDesktopServices::openUrl ( "file:///" + QFileInfo ( filename ).absolutePath() );
+ QDesktopServices::openUrl("file:///" + QFileInfo(filename).absolutePath());
}
-
-