mirror of https://github.com/stella-emu/stella.git
More optimization for FSNodePOSIX.
This commit is contained in:
parent
437046bb6b
commit
0a14629fa4
|
@ -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] != '/')
|
||||
|
@ -92,9 +93,13 @@ string FSNodePOSIX::getShortPath() const
|
|||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
size_t FSNodePOSIX::getSize() const
|
||||
{
|
||||
if (_size == 0)
|
||||
{
|
||||
struct stat st;
|
||||
return (stat(_path.c_str(), &st) == 0) ? st.st_size : 0;
|
||||
_size = (stat(_path.c_str(), &st) == 0) ? st.st_size : 0;
|
||||
}
|
||||
return _size;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue