ecode: Improved file system listener.

This commit is contained in:
Martín Lucas Golini
2023-07-25 00:42:10 -03:00
parent 451ffc75ad
commit cf13a5aa5d
3 changed files with 13 additions and 3 deletions

View File

@@ -70,12 +70,19 @@ void FileSystemListener::handleFileAction( efsw::WatchID, const std::string& dir
}
}
if ( file.isLink() )
file = FileInfo( file.linksTo() );
if ( isFileOpen( file ) )
notifyChange( file );
Lock l( mCbsMutex );
if ( !mCbs.empty() ) {
auto cbs = mCbs;
for ( const auto& cb : cbs )
cb.second( event, file );
}
break;
}
case efsw::Actions::Modified: {

View File

@@ -324,8 +324,11 @@ void ProjectDirectoryTree::tryAddFile( const FileInfo& file ) {
}
if ( foundPattern ) {
Lock l( mFilesMutex );
mFiles.emplace_back( file.getFilepath() );
mNames.emplace_back( file.getFileName() );
auto exists = std::find( mFiles.begin(), mFiles.end(), file.getFilepath() ) != mFiles.end();
if ( !exists ) {
mFiles.emplace_back( file.getFilepath() );
mNames.emplace_back( file.getFileName() );
}
}
}
}