aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRachel Powers <508861+Ryex@users.noreply.github.com>2023-03-31 20:22:07 -0700
committerRachel Powers <508861+Ryex@users.noreply.github.com>2023-03-31 20:31:27 -0700
commit538092b72728fa34bafc873e16abaa7f318a945c (patch)
tree5c96a765d0d957edcdc563d1eae0d57c0c19b4fb
parent4df4b4390086171b9ee78a8cd7efb32412292485 (diff)
downloadPrismLauncher-538092b72728fa34bafc873e16abaa7f318a945c.tar.gz
PrismLauncher-538092b72728fa34bafc873e16abaa7f318a945c.tar.bz2
PrismLauncher-538092b72728fa34bafc873e16abaa7f318a945c.zip
fix: typos, CamelCase to camelCase the new names
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
-rw-r--r--launcher/FileSystem.cpp30
-rw-r--r--launcher/FileSystem.h87
-rw-r--r--tests/FileSystem_test.cpp40
3 files changed, 81 insertions, 76 deletions
diff --git a/launcher/FileSystem.cpp b/launcher/FileSystem.cpp
index 640cf9be..c046ee86 100644
--- a/launcher/FileSystem.cpp
+++ b/launcher/FileSystem.cpp
@@ -328,7 +328,7 @@ bool create_link::operator()(const QString& offset, bool dryRun)
}
/**
- * @brief make a list off all the links to
+ * @brief Make a list of all the links to make
* @param offset subdirectory form src to link to dest
* @return if there was an error during the attempt to link
*/
@@ -363,7 +363,7 @@ void create_link::make_link_list(const QString& offset)
link_file(src, "");
} else {
if (m_debug)
- qDebug() << "linking recursively:" << src << "to" << dst << "max_depth:" << m_max_depth;
+ qDebug() << "linking recursively:" << src << "to" << dst << ", max_depth:" << m_max_depth;
QDir src_dir(src);
QDirIterator source_it(src, QDir::Filter::Files | QDir::Filter::Hidden, QDirIterator::Subdirectories);
@@ -373,8 +373,8 @@ void create_link::make_link_list(const QString& offset)
auto src_path = source_it.next();
auto relative_path = src_dir.relativeFilePath(src_path);
- if (m_max_depth >= 0 && PathDepth(relative_path) > m_max_depth) {
- relative_path = PathTruncate(relative_path, m_max_depth);
+ if (m_max_depth >= 0 && pathDepth(relative_path) > m_max_depth){
+ relative_path = pathTruncate(relative_path, m_max_depth);
src_path = src_dir.filePath(relative_path);
if (linkedPaths.contains(src_path)) {
continue;
@@ -394,20 +394,22 @@ bool create_link::make_links()
for (auto link : m_links_to_make) {
QString src_path = link.src;
QString dst_path = link.dst;
+ auto src_path_std = StringUtils::toStdString(link.src);
+ auto dst_path_std = StringUtils::toStdString(link.dst);
ensureFilePathExists(dst_path);
if (m_useHardLinks) {
if (m_debug)
qDebug() << "making hard link:" << src_path << "to" << dst_path;
- fs::create_hard_link(StringUtils::toStdString(src_path), StringUtils::toStdString(dst_path), m_os_err);
- } else if (fs::is_directory(StringUtils::toStdString(src_path))) {
+ fs::create_hard_link(src_path_std, dst_path_std, m_os_err);
+ } else if (fs::is_directory(src_path_std)) {
if (m_debug)
qDebug() << "making directory_symlink:" << src_path << "to" << dst_path;
- fs::create_directory_symlink(StringUtils::toStdString(src_path), StringUtils::toStdString(dst_path), m_os_err);
+ fs::create_directory_symlink(src_path_std, dst_path_std, m_os_err);
} else {
if (m_debug)
qDebug() << "making symlink:" << src_path << "to" << dst_path;
- fs::create_symlink(StringUtils::toStdString(src_path), StringUtils::toStdString(dst_path), m_os_err);
+ fs::create_symlink(src_path_std, dst_path_std, m_os_err);
}
if (m_os_err) {
@@ -636,7 +638,7 @@ QString AbsolutePath(const QString& path)
return QFileInfo(path).absolutePath();
}
-int PathDepth(const QString& path)
+int pathDepth(const QString& path)
{
if (path.isEmpty())
return 0;
@@ -656,15 +658,15 @@ int PathDepth(const QString& path)
return numParts;
}
-QString PathTruncate(const QString& path, int depth)
+QString pathTruncate(const QString& path, int depth)
{
if (path.isEmpty() || (depth < 0))
return "";
QString trunc = QFileInfo(path).path();
- if (PathDepth(trunc) > depth) {
- return PathTruncate(trunc, depth);
+ if (pathDepth(trunc) > depth ) {
+ return pathTruncate(trunc, depth);
}
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
@@ -984,7 +986,7 @@ FilesystemType getFilesystemType(const QString& name)
* @brief path to the near ancestor that exists
*
*/
-QString NearestExistentAncestor(const QString& path)
+QString nearestExistentAncestor(const QString& path)
{
if (QFileInfo::exists(path))
return path;
@@ -1007,7 +1009,7 @@ FilesystemInfo statFS(const QString& path)
{
FilesystemInfo info;
- QStorageInfo storage_info(NearestExistentAncestor(path));
+ QStorageInfo storage_info(nearestExistentAncestor(path));
info.fsTypeName = storage_info.fileSystemType();
diff --git a/launcher/FileSystem.h b/launcher/FileSystem.h
index 673c3563..47044d93 100644
--- a/launcher/FileSystem.h
+++ b/launcher/FileSystem.h
@@ -280,7 +280,7 @@ QString AbsolutePath(const QString& path);
* @param path path to measure
* @return int number of components before base path
*/
-int PathDepth(const QString& path);
+int pathDepth(const QString& path);
/**
* @brief cut off segments of path until it is a max of length depth
@@ -289,7 +289,7 @@ int PathDepth(const QString& path);
* @param depth max depth of new path
* @return QString truncated path
*/
-QString PathTruncate(const QString& path, int depth);
+QString pathTruncate(const QString& path, int depth);
/**
* Resolve an executable
@@ -360,23 +360,26 @@ enum class FilesystemType {
* QMap is ordered
*
*/
-static const QMap<FilesystemType, QString> s_filesystem_type_names = { { FilesystemType::FAT, QString("FAT") },
- { FilesystemType::NTFS, QString("NTFS") },
- { FilesystemType::REFS, QString("REFS") },
- { FilesystemType::EXT, QString("EXT") },
- { FilesystemType::EXT_2_OLD, QString("EXT_2_OLD") },
- { FilesystemType::EXT_2_3_4, QString("EXT2/3/4") },
- { FilesystemType::XFS, QString("XFS") },
- { FilesystemType::BTRFS, QString("BTRFS") },
- { FilesystemType::NFS, QString("NFS") },
- { FilesystemType::ZFS, QString("ZFS") },
- { FilesystemType::APFS, QString("APFS") },
- { FilesystemType::HFS, QString("HFS") },
- { FilesystemType::HFSPLUS, QString("HFSPLUS") },
- { FilesystemType::HFSX, QString("HFSX") },
- { FilesystemType::FUSEBLK, QString("FUSEBLK") },
- { FilesystemType::F2FS, QString("F2FS") },
- { FilesystemType::UNKNOWN, QString("UNKNOWN") } };
+static const QMap<FilesystemType, QString> s_filesystem_type_names = {
+ {FilesystemType::FAT, QStringLiteral("FAT")},
+ {FilesystemType::NTFS, QStringLiteral("NTFS")},
+ {FilesystemType::REFS, QStringLiteral("REFS")},
+ {FilesystemType::EXT, QStringLiteral("EXT")},
+ {FilesystemType::EXT_2_OLD, QStringLiteral("EXT_2_OLD")},
+ {FilesystemType::EXT_2_3_4, QStringLiteral("EXT2/3/4")},
+ {FilesystemType::XFS, QStringLiteral("XFS")},
+ {FilesystemType::BTRFS, QStringLiteral("BTRFS")},
+ {FilesystemType::NFS, QStringLiteral("NFS")},
+ {FilesystemType::ZFS, QStringLiteral("ZFS")},
+ {FilesystemType::APFS, QStringLiteral("APFS")},
+ {FilesystemType::HFS, QStringLiteral("HFS")},
+ {FilesystemType::HFSPLUS, QStringLiteral("HFSPLUS")},
+ {FilesystemType::HFSX, QStringLiteral("HFSX")},
+ {FilesystemType::FUSEBLK, QStringLiteral("FUSEBLK")},
+ {FilesystemType::F2FS, QStringLiteral("F2FS")},
+ {FilesystemType::UNKNOWN, QStringLiteral("UNKNOWN")}
+};
+
/**
* @brief Ordered Mapping of reported filesystem names to enum types
@@ -387,28 +390,28 @@ static const QMap<FilesystemType, QString> s_filesystem_type_names = { { Filesys
*
*/
static const QMap<QString, FilesystemType> s_filesystem_type_names_inverse = {
- { QString("FAT"), FilesystemType::FAT },
- { QString("NTFS"), FilesystemType::NTFS },
- { QString("REFS"), FilesystemType::REFS },
- { QString("EXT2_OLD"), FilesystemType::EXT_2_OLD },
- { QString("EXT_2_OLD"), FilesystemType::EXT_2_OLD },
- { QString("EXT2"), FilesystemType::EXT_2_3_4 },
- { QString("EXT3"), FilesystemType::EXT_2_3_4 },
- { QString("EXT4"), FilesystemType::EXT_2_3_4 },
- { QString("EXT2/3/4"), FilesystemType::EXT_2_3_4 },
- { QString("EXT_2_3_4"), FilesystemType::EXT_2_3_4 },
- { QString("EXT"), FilesystemType::EXT }, // must come after all other EXT variants to prevent greedy detection
- { QString("XFS"), FilesystemType::XFS },
- { QString("BTRFS"), FilesystemType::BTRFS },
- { QString("NFS"), FilesystemType::NFS },
- { QString("ZFS"), FilesystemType::ZFS },
- { QString("APFS"), FilesystemType::APFS },
- { QString("HFSPLUS"), FilesystemType::HFSPLUS },
- { QString("HFSX"), FilesystemType::HFSX },
- { QString("HFS"), FilesystemType::HFS },
- { QString("FUSEBLK"), FilesystemType::FUSEBLK },
- { QString("F2FS"), FilesystemType::F2FS },
- { QString("UNKNOWN"), FilesystemType::UNKNOWN }
+ {QStringLiteral("FAT"), FilesystemType::FAT},
+ {QStringLiteral("NTFS"), FilesystemType::NTFS},
+ {QStringLiteral("REFS"), FilesystemType::REFS},
+ {QStringLiteral("EXT2_OLD"), FilesystemType::EXT_2_OLD},
+ {QStringLiteral("EXT_2_OLD"), FilesystemType::EXT_2_OLD},
+ {QStringLiteral("EXT2"), FilesystemType::EXT_2_3_4},
+ {QStringLiteral("EXT3"), FilesystemType::EXT_2_3_4},
+ {QStringLiteral("EXT4"), FilesystemType::EXT_2_3_4},
+ {QStringLiteral("EXT2/3/4"), FilesystemType::EXT_2_3_4},
+ {QStringLiteral("EXT_2_3_4"), FilesystemType::EXT_2_3_4},
+ {QStringLiteral("EXT"), FilesystemType::EXT}, // must come after all other EXT variants to prevent greedy detection
+ {QStringLiteral("XFS"), FilesystemType::XFS},
+ {QStringLiteral("BTRFS"), FilesystemType::BTRFS},
+ {QStringLiteral("NFS"), FilesystemType::NFS},
+ {QStringLiteral("ZFS"), FilesystemType::ZFS},
+ {QStringLiteral("APFS"), FilesystemType::APFS},
+ {QStringLiteral("HFSPLUS"), FilesystemType::HFSPLUS},
+ {QStringLiteral("HFSX"), FilesystemType::HFSX},
+ {QStringLiteral("HFS"), FilesystemType::HFS},
+ {QStringLiteral("FUSEBLK"), FilesystemType::FUSEBLK},
+ {QStringLiteral("F2FS"), FilesystemType::F2FS},
+ {QStringLiteral("UNKNOWN"), FilesystemType::UNKNOWN}
};
/**
@@ -452,7 +455,7 @@ struct FilesystemInfo {
* @brief path to the near ancestor that exists
*
*/
-QString NearestExistentAncestor(const QString& path);
+QString nearestExistentAncestor(const QString& path);
/**
* @brief colect information about the filesystem under a file
diff --git a/tests/FileSystem_test.cpp b/tests/FileSystem_test.cpp
index 19565a99..ec1f0bcf 100644
--- a/tests/FileSystem_test.cpp
+++ b/tests/FileSystem_test.cpp
@@ -756,30 +756,30 @@ slots:
}
void test_path_depth() {
- QCOMPARE(FS::PathDepth(""), 0);
- QCOMPARE(FS::PathDepth("."), 0);
- QCOMPARE(FS::PathDepth("foo.txt"), 0);
- QCOMPARE(FS::PathDepth("./foo.txt"), 0);
- QCOMPARE(FS::PathDepth("./bar/foo.txt"), 1);
- QCOMPARE(FS::PathDepth("../bar/foo.txt"), 0);
- QCOMPARE(FS::PathDepth("/bar/foo.txt"), 1);
- QCOMPARE(FS::PathDepth("baz/bar/foo.txt"), 2);
- QCOMPARE(FS::PathDepth("/baz/bar/foo.txt"), 2);
- QCOMPARE(FS::PathDepth("./baz/bar/foo.txt"), 2);
- QCOMPARE(FS::PathDepth("/baz/../bar/foo.txt"), 1);
+ QCOMPARE(FS::pathDepth(""), 0);
+ QCOMPARE(FS::pathDepth("."), 0);
+ QCOMPARE(FS::pathDepth("foo.txt"), 0);
+ QCOMPARE(FS::pathDepth("./foo.txt"), 0);
+ QCOMPARE(FS::pathDepth("./bar/foo.txt"), 1);
+ QCOMPARE(FS::pathDepth("../bar/foo.txt"), 0);
+ QCOMPARE(FS::pathDepth("/bar/foo.txt"), 1);
+ QCOMPARE(FS::pathDepth("baz/bar/foo.txt"), 2);
+ QCOMPARE(FS::pathDepth("/baz/bar/foo.txt"), 2);
+ QCOMPARE(FS::pathDepth("./baz/bar/foo.txt"), 2);
+ QCOMPARE(FS::pathDepth("/baz/../bar/foo.txt"), 1);
}
void test_path_trunc() {
- QCOMPARE(FS::PathTruncate("", 0), QDir::toNativeSeparators(""));
- QCOMPARE(FS::PathTruncate("foo.txt", 0), QDir::toNativeSeparators(""));
- QCOMPARE(FS::PathTruncate("foo.txt", 1), QDir::toNativeSeparators(""));
- QCOMPARE(FS::PathTruncate("./bar/foo.txt", 0), QDir::toNativeSeparators("./bar"));
- QCOMPARE(FS::PathTruncate("./bar/foo.txt", 1), QDir::toNativeSeparators("./bar"));
- QCOMPARE(FS::PathTruncate("/bar/foo.txt", 1), QDir::toNativeSeparators("/bar"));
- QCOMPARE(FS::PathTruncate("bar/foo.txt", 1), QDir::toNativeSeparators("bar"));
- QCOMPARE(FS::PathTruncate("baz/bar/foo.txt", 2), QDir::toNativeSeparators("baz/bar"));
+ QCOMPARE(FS::pathTruncate("", 0), QDir::toNativeSeparators(""));
+ QCOMPARE(FS::pathTruncate("foo.txt", 0), QDir::toNativeSeparators(""));
+ QCOMPARE(FS::pathTruncate("foo.txt", 1), QDir::toNativeSeparators(""));
+ QCOMPARE(FS::pathTruncate("./bar/foo.txt", 0), QDir::toNativeSeparators("./bar"));
+ QCOMPARE(FS::pathTruncate("./bar/foo.txt", 1), QDir::toNativeSeparators("./bar"));
+ QCOMPARE(FS::pathTruncate("/bar/foo.txt", 1), QDir::toNativeSeparators("/bar"));
+ QCOMPARE(FS::pathTruncate("bar/foo.txt", 1), QDir::toNativeSeparators("bar"));
+ QCOMPARE(FS::pathTruncate("baz/bar/foo.txt", 2), QDir::toNativeSeparators("baz/bar"));
#if defined(Q_OS_WIN)
- QCOMPARE(FS::PathTruncate("C:\\bar\\foo.txt", 1), QDir::toNativeSeparators("C:\\bar"));
+ QCOMPARE(FS::pathTruncate("C:\\bar\\foo.txt", 1), QDir::toNativeSeparators("C:\\bar"));
#endif
}
};