[Scummvm-git-logs] scummvm master -> 8fb57967d75b5ef9911fbbbf15eb25b43458c997
bgK
bastien.bouclet at gmail.com
Thu Oct 31 21:36:19 CET 2019
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
8fb57967d7 3DS: Avoid stat calls in DrivePOSIXFilesystemNode
Commit: 8fb57967d75b5ef9911fbbbf15eb25b43458c997
https://github.com/scummvm/scummvm/commit/8fb57967d75b5ef9911fbbbf15eb25b43458c997
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2019-10-31T21:35:41+01:00
Commit Message:
3DS: Avoid stat calls in DrivePOSIXFilesystemNode
Changed paths:
backends/fs/posix-drives/posix-drives-fs.cpp
backends/fs/posix-drives/posix-drives-fs.h
backends/fs/posix/posix-fs.h
diff --git a/backends/fs/posix-drives/posix-drives-fs.cpp b/backends/fs/posix-drives/posix-drives-fs.cpp
index 683ab19..d48792e 100644
--- a/backends/fs/posix-drives/posix-drives-fs.cpp
+++ b/backends/fs/posix-drives/posix-drives-fs.cpp
@@ -53,10 +53,8 @@ DrivePOSIXFilesystemNode::DrivePOSIXFilesystemNode(const DrivesArray &drives) :
_isValid = false;
}
-AbstractFSNode *DrivePOSIXFilesystemNode::getChild(const Common::String &n) const {
- if (!_isPseudoRoot) {
- return POSIXFilesystemNode::getChild(n);
- }
+DrivePOSIXFilesystemNode *DrivePOSIXFilesystemNode::getChildWithKnownType(const Common::String &n, bool isDirectory) const {
+ assert(_isDirectory);
// Make sure the string contains no slashes
assert(!n.contains('/'));
@@ -66,7 +64,21 @@ AbstractFSNode *DrivePOSIXFilesystemNode::getChild(const Common::String &n) cons
newPath += '/';
newPath += n;
- return makeNode(newPath);
+ DrivePOSIXFilesystemNode *child = new DrivePOSIXFilesystemNode(_drives);
+ child->_path = newPath;
+ child->_isValid = true;
+ child->_isPseudoRoot = false;
+ child->_isDirectory = isDirectory;
+ child->_displayName = n;
+
+ return child;
+}
+
+AbstractFSNode *DrivePOSIXFilesystemNode::getChild(const Common::String &n) const {
+ DrivePOSIXFilesystemNode *child = getChildWithKnownType(n, false);
+ child->setFlags();
+
+ return child;
}
bool DrivePOSIXFilesystemNode::getChildren(AbstractFSList &list, AbstractFSNode::ListMode mode, bool hidden) const {
@@ -96,7 +108,16 @@ bool DrivePOSIXFilesystemNode::getChildren(AbstractFSList &list, AbstractFSNode:
continue;
}
- AbstractFSNode *child = getChild(dp->d_name);
+ AbstractFSNode *child = nullptr;
+
+#if !defined(SYSTEM_NOT_SUPPORTING_D_TYPE)
+ if (dp->d_type == DT_DIR || dp->d_type == DT_REG) {
+ child = getChildWithKnownType(dp->d_name, dp->d_type == DT_DIR);
+ } else
+#endif
+ {
+ child = getChild(dp->d_name);
+ }
// Honor the chosen mode
if ((mode == Common::FSNode::kListFilesOnly && child->isDirectory()) ||
diff --git a/backends/fs/posix-drives/posix-drives-fs.h b/backends/fs/posix-drives/posix-drives-fs.h
index 43c8942..04d21b4 100644
--- a/backends/fs/posix-drives/posix-drives-fs.h
+++ b/backends/fs/posix-drives/posix-drives-fs.h
@@ -50,6 +50,7 @@ private:
bool _isPseudoRoot;
const DrivesArray &_drives;
+ DrivePOSIXFilesystemNode *getChildWithKnownType(const Common::String &n, bool isDirectory) const;
bool isDrive(const Common::String &path) const;
};
diff --git a/backends/fs/posix/posix-fs.h b/backends/fs/posix/posix-fs.h
index 9751ab7..6a67a61 100644
--- a/backends/fs/posix/posix-fs.h
+++ b/backends/fs/posix/posix-fs.h
@@ -70,7 +70,7 @@ public:
virtual Common::WriteStream *createWriteStream();
virtual bool createDirectory();
-private:
+protected:
/**
* Tests and sets the _isValid and _isDirectory flags, using the stat() function.
*/
More information about the Scummvm-git-logs
mailing list