mirror of
https://github.com/polserver/polserver
synced 2026-08-13 08:23:08 -04:00
* use std::filesystem to iterate over directories realms folder can now contain files * Ignore unix like hidden dir entries * simplified recursive compilation
36 lines
703 B
C++
36 lines
703 B
C++
/** @file
|
|
*
|
|
* @par History
|
|
*/
|
|
|
|
|
|
#include <filesystem>
|
|
#include <string>
|
|
|
|
#include "globals/uvars.h"
|
|
|
|
namespace Pol
|
|
{
|
|
namespace Core
|
|
{
|
|
namespace fs = std::filesystem;
|
|
void load_tips()
|
|
{
|
|
gamestate.tipfilenames.clear();
|
|
|
|
std::error_code ec;
|
|
for ( const auto& dir_entry : fs::directory_iterator( "tips", ec ) )
|
|
{
|
|
if ( !dir_entry.is_regular_file() )
|
|
continue;
|
|
if ( auto fn = dir_entry.path().filename().u8string(); !fn.empty() && *fn.begin() == '.' )
|
|
continue;
|
|
const auto path = dir_entry.path();
|
|
if ( !path.extension().compare( ".txt" ) )
|
|
{
|
|
gamestate.tipfilenames.push_back( path.filename().u8string() );
|
|
}
|
|
}
|
|
}
|
|
} // namespace Core
|
|
} // namespace Pol
|