development/Common/Utility/source/VTS/VirtualTransportSystemCollector.inl
//! Assures that all Path in each configList elements point to a valid folder or file. Removes them from result list if not.
Assures that all Path in each configList elements point to a valid folder or file. Removes them from result list if not.
Assures that all Path in each configList elements point to a valid folder or file . Removes them from result list if not .
yaget::dev::Configuration::Init::VTSConfigList ValidateSections(const yaget::dev::Configuration::Init::VTSConfigList& configList)
    {
        yaget::dev::Configuration::Init::VTSConfigList validSections;
        for (const auto& section : configList)
        {
            yaget::Strings verifiedPath;
            std::copy_if(section.Path.begin(), section.Path.end(), std::back_inserter(verifiedPath), [](const std::string& pathName)
            {
                std::string potentialPath = yaget::util::ExpendEnv(pathName, nullptr);
                if (!potentialPath.empty())
                {
                    if (fs::is_directory(potentialPath) || fs::is_regular_file(potentialPath))
                    {
                        return true;
                    }
                    else if (!fs::path(potentialPath).has_extension())
                    {
                        const auto& [result, errorMessage] = yaget::io::file::AssureDirectories(potentialPath + "/");
                        if (result)
                        {
                            return true;
                        }
                    }
                }
                YLOG_ERROR("VTS", "Path Alias: '%s' expended to: '%s' is not valid, skipping.", pathName.c_str(), potentialPath.c_str());
                return false;
            });
            if (!verifiedPath.empty())
            {
                if (!section.ReadOnly && section.Path.size() > 1)
                {
                    YLOG_ERROR("VTS", "Section '%s' is marked writeable but it has '%d' [%s] path entries. Only 1 is allowed, skipping.", section.Name.c_str(), section.Path.size(), yaget::conv::Combine(section.Path, "],[").c_str());
                    continue;;
                }
                yaget::dev::Configuration::Init::VTS verifiedSection = section;
                std::swap(verifiedSection.Path, verifiedPath);
                validSections.insert(verifiedSection);
            }
        }
        return validSections;
    }
yaget :: dev :: Configuration :: Init :: VTSConfigList ValidateSections ( const yaget :: dev :: Configuration :: Init :: VTSConfigList & configList ) { yaget :: dev :: Configuration :: Init :: VTSConfigList validSections ; for ( const auto & section : configList ) { yaget :: Strings verifiedPath ; std :: copy_if ( section . Path . begin ( ) , section . Path . end ( ) , std :: back_inserter ( verifiedPath ) , [ ] ( const std :: string & pathName ) { std :: string potentialPath = yaget :: util :: ExpendEnv ( pathName , nullptr ) ; if ( ! potentialPath . empty ( ) ) { if ( fs :: is_directory ( potentialPath ) || fs :: is_regular_file ( potentialPath ) ) { return true ; } else if ( ! fs :: path ( potentialPath ) . has_extension ( ) ) { const auto & [ result , errorMessage ] = yaget :: io :: file :: AssureDirectories ( potentialPath + " " ) ; if ( result ) { return true ; } } } YLOG_ERROR ( " " , " " , pathName . c_str ( ) , potentialPath . c_str ( ) ) ; return false ; } ) ; if ( ! verifiedPath . empty ( ) ) { if ( ! section . ReadOnly && section . Path . size ( ) > 1 ) { YLOG_ERROR ( " " , " " , section . Name . c_str ( ) , section . Path . size ( ) , yaget :: conv :: Combine ( section . Path , " " ) . c_str ( ) ) ; continue ; ; } yaget :: dev :: Configuration :: Init :: VTS verifiedSection = section ; std :: swap ( verifiedSection . Path , verifiedPath ) ; validSections . insert ( verifiedSection ) ; } } return validSections ; }
Assures that all Path in each configList elements point to a valid folder or file.
Assures that all Path in each configList elements point to a valid folder or file .
// we need to prune file path for each section