Fix segmentation fault when '.' or '..' is first entry in readdir

This commit is contained in:
zvon 2019-01-15 23:52:15 +01:00
parent 55efe036dd
commit e976ffddc1

View File

@ -22,6 +22,8 @@ namespace FSLib{
public:
Iterator( const Directory &d_ ) : d(opendir(d_.path())) {
current_entry = readdir(d);
if( current_entry != nullptr && ( !strcmp(current_entry->d_name, ".") || !strcmp(current_entry->d_name, "..") ) )
++(*this);
}
Iterator( const Directory &d_, const struct dirent *current_entry_) : d(opendir(d_.path())), current_entry(current_entry_) {}