diff --git a/src/os/unix/FSNodePOSIX.cxx b/src/os/unix/FSNodePOSIX.cxx index 618d37fb3..0da02983d 100644 --- a/src/os/unix/FSNodePOSIX.cxx +++ b/src/os/unix/FSNodePOSIX.cxx @@ -64,6 +64,7 @@ void FSNodePOSIX::setFlags() { _isDirectory = S_ISDIR(st.st_mode); _isFile = S_ISREG(st.st_mode); + _size = st.st_size; // Add a trailing slash, if necessary if (_isDirectory && _path.length() > 0 && _path[_path.length()-1] != '/') @@ -93,8 +94,12 @@ string FSNodePOSIX::getShortPath() const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - size_t FSNodePOSIX::getSize() const { - struct stat st; - return (stat(_path.c_str(), &st) == 0) ? st.st_size : 0; + if (_size == 0) + { + struct stat st; + _size = (stat(_path.c_str(), &st) == 0) ? st.st_size : 0; + } + return _size; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/os/unix/FSNodePOSIX.hxx b/src/os/unix/FSNodePOSIX.hxx index 6407b95ca..64e5ac9f5 100644 --- a/src/os/unix/FSNodePOSIX.hxx +++ b/src/os/unix/FSNodePOSIX.hxx @@ -87,6 +87,7 @@ class FSNodePOSIX : public AbstractFSNode private: string _path, _displayName; bool _isValid{true}, _isFile{false}, _isDirectory{true}; + mutable size_t _size{0}; static const char* ourHomeDir; };