#include "externals.hh" #include "c-project.hh" /*= A_ProjectPathListener ====================================================*/ A_ProjectPathListener::~A_ProjectPathListener( ) {} /*= T_Project ================================================================*/ void T_Project::setBasePath( T_FSPath const& path ) noexcept { assert( path.isValid( ) ); if ( basePath_ == path ) { return; } if ( path.isRelative( ) ) { basePath_ = ( Filesystem::Cwd( ) + path ).canonical( ); } else { basePath_ = path.canonical( ); } const auto n{ listeners_.size( ) }; for ( auto i = 0u ; i < n ; i ++ ) { listeners_[ i ]->projectPathChanged( ); } } /*----------------------------------------------------------------------------*/ T_FSPath T_Project::pathOf( T_FSPath const& file ) const noexcept { if ( file.isAbsolute( ) ) { if ( file.canonical( ).isUnder( basePath_ ) ) { return file; } return basePath_; } return ( basePath_ + file ).canonical( ); } T_FSPath T_Project::pathOf( char const* file ) const noexcept { return pathOf( T_String{ file } ); } T_String T_Project::strPathOf( T_FSPath const& file ) const noexcept { return pathOf( file ).toString( ); } T_String T_Project::strPathOf( char const* file ) const noexcept { return strPathOf( T_String{ file } ); }