fix: typos, CamelCase to camelCase the new names

Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
This commit is contained in:
Rachel Powers 2023-03-31 20:22:07 -07:00
parent 4df4b43900
commit 538092b727
3 changed files with 81 additions and 76 deletions

View File

@ -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 * @param offset subdirectory form src to link to dest
* @return if there was an error during the attempt to link * @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, ""); link_file(src, "");
} else { } else {
if (m_debug) 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); QDir src_dir(src);
QDirIterator source_it(src, QDir::Filter::Files | QDir::Filter::Hidden, QDirIterator::Subdirectories); 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 src_path = source_it.next();
auto relative_path = src_dir.relativeFilePath(src_path); auto relative_path = src_dir.relativeFilePath(src_path);
if (m_max_depth >= 0 && PathDepth(relative_path) > m_max_depth) { if (m_max_depth >= 0 && pathDepth(relative_path) > m_max_depth){
relative_path = PathTruncate(relative_path, m_max_depth); relative_path = pathTruncate(relative_path, m_max_depth);
src_path = src_dir.filePath(relative_path); src_path = src_dir.filePath(relative_path);
if (linkedPaths.contains(src_path)) { if (linkedPaths.contains(src_path)) {
continue; continue;
@ -394,20 +394,22 @@ bool create_link::make_links()
for (auto link : m_links_to_make) { for (auto link : m_links_to_make) {
QString src_path = link.src; QString src_path = link.src;
QString dst_path = link.dst; QString dst_path = link.dst;
auto src_path_std = StringUtils::toStdString(link.src);
auto dst_path_std = StringUtils::toStdString(link.dst);
ensureFilePathExists(dst_path); ensureFilePathExists(dst_path);
if (m_useHardLinks) { if (m_useHardLinks) {
if (m_debug) if (m_debug)
qDebug() << "making hard link:" << src_path << "to" << dst_path; qDebug() << "making hard link:" << src_path << "to" << dst_path;
fs::create_hard_link(StringUtils::toStdString(src_path), StringUtils::toStdString(dst_path), m_os_err); fs::create_hard_link(src_path_std, dst_path_std, m_os_err);
} else if (fs::is_directory(StringUtils::toStdString(src_path))) { } else if (fs::is_directory(src_path_std)) {
if (m_debug) if (m_debug)
qDebug() << "making directory_symlink:" << src_path << "to" << dst_path; 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 { } else {
if (m_debug) if (m_debug)
qDebug() << "making symlink:" << src_path << "to" << dst_path; 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) { if (m_os_err) {
@ -636,7 +638,7 @@ QString AbsolutePath(const QString& path)
return QFileInfo(path).absolutePath(); return QFileInfo(path).absolutePath();
} }
int PathDepth(const QString& path) int pathDepth(const QString& path)
{ {
if (path.isEmpty()) if (path.isEmpty())
return 0; return 0;
@ -656,15 +658,15 @@ int PathDepth(const QString& path)
return numParts; return numParts;
} }
QString PathTruncate(const QString& path, int depth) QString pathTruncate(const QString& path, int depth)
{ {
if (path.isEmpty() || (depth < 0)) if (path.isEmpty() || (depth < 0))
return ""; return "";
QString trunc = QFileInfo(path).path(); QString trunc = QFileInfo(path).path();
if (PathDepth(trunc) > depth) { if (pathDepth(trunc) > depth ) {
return PathTruncate(trunc, depth); return pathTruncate(trunc, depth);
} }
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) #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 * @brief path to the near ancestor that exists
* *
*/ */
QString NearestExistentAncestor(const QString& path) QString nearestExistentAncestor(const QString& path)
{ {
if (QFileInfo::exists(path)) if (QFileInfo::exists(path))
return path; return path;
@ -1007,7 +1009,7 @@ FilesystemInfo statFS(const QString& path)
{ {
FilesystemInfo info; FilesystemInfo info;
QStorageInfo storage_info(NearestExistentAncestor(path)); QStorageInfo storage_info(nearestExistentAncestor(path));
info.fsTypeName = storage_info.fileSystemType(); info.fsTypeName = storage_info.fileSystemType();

View File

@ -280,7 +280,7 @@ QString AbsolutePath(const QString& path);
* @param path path to measure * @param path path to measure
* @return int number of components before base path * @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 * @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 * @param depth max depth of new path
* @return QString truncated path * @return QString truncated path
*/ */
QString PathTruncate(const QString& path, int depth); QString pathTruncate(const QString& path, int depth);
/** /**
* Resolve an executable * Resolve an executable
@ -360,23 +360,26 @@ enum class FilesystemType {
* QMap is ordered * QMap is ordered
* *
*/ */
static const QMap<FilesystemType, QString> s_filesystem_type_names = { { FilesystemType::FAT, QString("FAT") }, static const QMap<FilesystemType, QString> s_filesystem_type_names = {
{ FilesystemType::NTFS, QString("NTFS") }, {FilesystemType::FAT, QStringLiteral("FAT")},
{ FilesystemType::REFS, QString("REFS") }, {FilesystemType::NTFS, QStringLiteral("NTFS")},
{ FilesystemType::EXT, QString("EXT") }, {FilesystemType::REFS, QStringLiteral("REFS")},
{ FilesystemType::EXT_2_OLD, QString("EXT_2_OLD") }, {FilesystemType::EXT, QStringLiteral("EXT")},
{ FilesystemType::EXT_2_3_4, QString("EXT2/3/4") }, {FilesystemType::EXT_2_OLD, QStringLiteral("EXT_2_OLD")},
{ FilesystemType::XFS, QString("XFS") }, {FilesystemType::EXT_2_3_4, QStringLiteral("EXT2/3/4")},
{ FilesystemType::BTRFS, QString("BTRFS") }, {FilesystemType::XFS, QStringLiteral("XFS")},
{ FilesystemType::NFS, QString("NFS") }, {FilesystemType::BTRFS, QStringLiteral("BTRFS")},
{ FilesystemType::ZFS, QString("ZFS") }, {FilesystemType::NFS, QStringLiteral("NFS")},
{ FilesystemType::APFS, QString("APFS") }, {FilesystemType::ZFS, QStringLiteral("ZFS")},
{ FilesystemType::HFS, QString("HFS") }, {FilesystemType::APFS, QStringLiteral("APFS")},
{ FilesystemType::HFSPLUS, QString("HFSPLUS") }, {FilesystemType::HFS, QStringLiteral("HFS")},
{ FilesystemType::HFSX, QString("HFSX") }, {FilesystemType::HFSPLUS, QStringLiteral("HFSPLUS")},
{ FilesystemType::FUSEBLK, QString("FUSEBLK") }, {FilesystemType::HFSX, QStringLiteral("HFSX")},
{ FilesystemType::F2FS, QString("F2FS") }, {FilesystemType::FUSEBLK, QStringLiteral("FUSEBLK")},
{ FilesystemType::UNKNOWN, QString("UNKNOWN") } }; {FilesystemType::F2FS, QStringLiteral("F2FS")},
{FilesystemType::UNKNOWN, QStringLiteral("UNKNOWN")}
};
/** /**
* @brief Ordered Mapping of reported filesystem names to enum types * @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 = { static const QMap<QString, FilesystemType> s_filesystem_type_names_inverse = {
{ QString("FAT"), FilesystemType::FAT }, {QStringLiteral("FAT"), FilesystemType::FAT},
{ QString("NTFS"), FilesystemType::NTFS }, {QStringLiteral("NTFS"), FilesystemType::NTFS},
{ QString("REFS"), FilesystemType::REFS }, {QStringLiteral("REFS"), FilesystemType::REFS},
{ QString("EXT2_OLD"), FilesystemType::EXT_2_OLD }, {QStringLiteral("EXT2_OLD"), FilesystemType::EXT_2_OLD},
{ QString("EXT_2_OLD"), FilesystemType::EXT_2_OLD }, {QStringLiteral("EXT_2_OLD"), FilesystemType::EXT_2_OLD},
{ QString("EXT2"), FilesystemType::EXT_2_3_4 }, {QStringLiteral("EXT2"), FilesystemType::EXT_2_3_4},
{ QString("EXT3"), FilesystemType::EXT_2_3_4 }, {QStringLiteral("EXT3"), FilesystemType::EXT_2_3_4},
{ QString("EXT4"), FilesystemType::EXT_2_3_4 }, {QStringLiteral("EXT4"), FilesystemType::EXT_2_3_4},
{ QString("EXT2/3/4"), FilesystemType::EXT_2_3_4 }, {QStringLiteral("EXT2/3/4"), FilesystemType::EXT_2_3_4},
{ QString("EXT_2_3_4"), FilesystemType::EXT_2_3_4 }, {QStringLiteral("EXT_2_3_4"), FilesystemType::EXT_2_3_4},
{ QString("EXT"), FilesystemType::EXT }, // must come after all other EXT variants to prevent greedy detection {QStringLiteral("EXT"), FilesystemType::EXT}, // must come after all other EXT variants to prevent greedy detection
{ QString("XFS"), FilesystemType::XFS }, {QStringLiteral("XFS"), FilesystemType::XFS},
{ QString("BTRFS"), FilesystemType::BTRFS }, {QStringLiteral("BTRFS"), FilesystemType::BTRFS},
{ QString("NFS"), FilesystemType::NFS }, {QStringLiteral("NFS"), FilesystemType::NFS},
{ QString("ZFS"), FilesystemType::ZFS }, {QStringLiteral("ZFS"), FilesystemType::ZFS},
{ QString("APFS"), FilesystemType::APFS }, {QStringLiteral("APFS"), FilesystemType::APFS},
{ QString("HFSPLUS"), FilesystemType::HFSPLUS }, {QStringLiteral("HFSPLUS"), FilesystemType::HFSPLUS},
{ QString("HFSX"), FilesystemType::HFSX }, {QStringLiteral("HFSX"), FilesystemType::HFSX},
{ QString("HFS"), FilesystemType::HFS }, {QStringLiteral("HFS"), FilesystemType::HFS},
{ QString("FUSEBLK"), FilesystemType::FUSEBLK }, {QStringLiteral("FUSEBLK"), FilesystemType::FUSEBLK},
{ QString("F2FS"), FilesystemType::F2FS }, {QStringLiteral("F2FS"), FilesystemType::F2FS},
{ QString("UNKNOWN"), FilesystemType::UNKNOWN } {QStringLiteral("UNKNOWN"), FilesystemType::UNKNOWN}
}; };
/** /**
@ -452,7 +455,7 @@ struct FilesystemInfo {
* @brief path to the near ancestor that exists * @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 * @brief colect information about the filesystem under a file

View File

@ -756,30 +756,30 @@ slots:
} }
void test_path_depth() { void test_path_depth() {
QCOMPARE(FS::PathDepth(""), 0); QCOMPARE(FS::pathDepth(""), 0);
QCOMPARE(FS::PathDepth("."), 0); QCOMPARE(FS::pathDepth("."), 0);
QCOMPARE(FS::PathDepth("foo.txt"), 0); QCOMPARE(FS::pathDepth("foo.txt"), 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"), 1);
QCOMPARE(FS::PathDepth("../bar/foo.txt"), 0); QCOMPARE(FS::pathDepth("../bar/foo.txt"), 0);
QCOMPARE(FS::PathDepth("/bar/foo.txt"), 1); 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"), 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("/baz/../bar/foo.txt"), 1);
} }
void test_path_trunc() { void test_path_trunc() {
QCOMPARE(FS::PathTruncate("", 0), QDir::toNativeSeparators("")); QCOMPARE(FS::pathTruncate("", 0), QDir::toNativeSeparators(""));
QCOMPARE(FS::PathTruncate("foo.txt", 0), QDir::toNativeSeparators("")); QCOMPARE(FS::pathTruncate("foo.txt", 0), QDir::toNativeSeparators(""));
QCOMPARE(FS::PathTruncate("foo.txt", 1), 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", 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("/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("baz/bar/foo.txt", 2), QDir::toNativeSeparators("baz/bar"));
#if defined(Q_OS_WIN) #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 #endif
} }
}; };