From 014c12fa35aa03c0478de71ce960f6d47cd079ee Mon Sep 17 00:00:00 2001 From: Federico Santamorena Date: Fri, 19 Jul 2019 16:44:31 +0200 Subject: [PATCH] FileInfo is now an immutable struct --- Source/Backend/Crawler.d | 23 +++++++------- Source/Backend/FileInfo.d | 65 ++++++--------------------------------- 2 files changed, 21 insertions(+), 67 deletions(-) diff --git a/Source/Backend/Crawler.d b/Source/Backend/Crawler.d index 72f0ae32..d331ed6f 100644 --- a/Source/Backend/Crawler.d +++ b/Source/Backend/Crawler.d @@ -134,17 +134,18 @@ private: immutable(FileInfo) buildFileInfo(DirEntry currentFile) const { - FileInfo f; - f.isDirectory = !currentFile.isDir(); - f.isDirectory = currentFile.isDir(); - f.fullPath = currentFile.name; - f.fileName = baseName(currentFile.name); - f.fileNameLower = toLower(f.fileName); - f.containingFolder = dirName(currentFile.name); - f.extension = extension(currentFile.name); - f.sizeString = humanSize(currentFile.size); - f.originalMountpoint = this.MOUNTPOINT; - f.dateModifiedString = toDateString(currentFile.timeLastModified()); + FileInfo f = { + this.MOUNTPOINT, + currentFile.isDir(), + !currentFile.isDir(), + toDateString(currentFile.timeLastModified()), + dirName(currentFile.name), + baseName(currentFile.name), + toLower(baseName(currentFile.name)), + extension(currentFile.name), + currentFile.name, + humanSize(currentFile.size) + }; return f; } diff --git a/Source/Backend/FileInfo.d b/Source/Backend/FileInfo.d index 798674fc..d2d52ac9 100644 --- a/Source/Backend/FileInfo.d +++ b/Source/Backend/FileInfo.d @@ -3,9 +3,8 @@ module FileInfo; /** FileInfo is a struct filled by the information a crawler can find about a file */ -struct FileInfo +immutable struct FileInfo { - /** The original mountpoint used by a crawler that found this file */ @@ -24,7 +23,7 @@ struct FileInfo /** true if is a symbolic link */ - bool isSymbolic; + //bool isSymbolic; /** string of the date modified @@ -39,14 +38,13 @@ struct FileInfo /** name of the icon to use on the left of the name */ - string iconName; + //string iconName; /** the filename with extension */ string fileName; - /** the filename with extension but lower string */ @@ -57,58 +55,13 @@ struct FileInfo */ string extension; - - + /** + Complete full path of the file + */ string fullPath; - - + /** + The size of the file, already converted as a human readable string + */ string sizeString; - - - - - } - -// this(DirEntry de) -// { - -// } - -// void isDirectory() -// { - -// } - -// string getDateModifiedString() -// { - -// } - -// void openContainingFolder() -// { - -// } - -// void openFile() -// { - -// } - -// string getContainingFolder() -// { - -// } - -// string getFileName() -// { - -// } - -// string getIconName() -// { - -// } - -// }