<commit_before>#include <pumex/Viewer.h>
#include <pumex/utils/Log.h>
#include <pumex/PhysicalDevice.h>
#include <pumex/Device.h>
#include <pumex/Window.h>
#include <pumex/Surface.h>
#include <pumex/Thread.h>
#if defined(_WIN32)
  #include <pumex/platform/win32/WindowWin32.h>
  #include <direct.h>
  #define getcwd _getcwd
#elif defined(__linux__)
  #include <pumex/platform/linux/WindowXcb.h>
  #include <unistd.h>
#endif
#include <sys/stat.h>

using namespace pumex;

ViewerTraits::ViewerTraits(const std::string& aName, bool uv, const std::vector<std::string>& rl, uint32_t ups)
  : applicationName(aName), useValidation{ uv }, requestedLayers(rl), updatesPerSecond(ups)
{
}

const uint32_t MAX_PATH_LENGTH = 256;

Viewer::Viewer(const ViewerTraits& vt)
  : viewerTraits{ vt }, 
  startUpdateGraph { updateGraph, [=](tbb::flow::continue_msg) { doNothing(); } },
  endUpdateGraph   { updateGraph, [=](tbb::flow::continue_msg) { doNothing(); } },
  startRenderGraph { renderGraph, [=](tbb::flow::continue_msg) { doNothing(); } },
  endRenderGraph   { renderGraph, [=](tbb::flow::continue_msg) { doNothing(); } }
{
  viewerStartTime     = HPClock::now();
  for(uint32_t i=0; i<3;++i)
    updateStartTimes[i] = viewerStartTime;
  renderStartTime     = viewerStartTime;
  lastRenderDuration  = viewerStartTime - renderStartTime;
  lastUpdateDuration  = viewerStartTime - updateStartTimes[0];

  // register basic directories - current directory
  char strCurrentPath[MAX_PATH_LENGTH];
  if (getcwd(strCurrentPath, MAX_PATH_LENGTH))
  {
    std::string currentDir(strCurrentPath);
    defaultDirectories.push_back(currentDir);
#if defined(_WIN32)
    defaultDirectories.push_back(currentDir + "\\data");
    defaultDirectories.push_back(currentDir + "\\data\\textures");<commit_msg>A directory for data files ( textures, models, shaders, etc ) may be set using PUMEX_DATA_DIR environment variable.<commit_after>#include <pumex/Viewer.h>
#include <pumex/utils/Log.h>
#include <pumex/PhysicalDevice.h>
#include <pumex/Device.h>
#include <pumex/Window.h>
#include <pumex/Surface.h>
#include <pumex/Thread.h>
#if defined(_WIN32)
  #include <pumex/platform/win32/WindowWin32.h>
  #include <direct.h>
  #define getcwd _getcwd
#elif defined(__linux__)
  #include <pumex/platform/linux/WindowXcb.h>
  #include <unistd.h>
#endif
#include <sys/stat.h>

using namespace pumex;

ViewerTraits::ViewerTraits(const std::string& aName, bool uv, const std::vector<std::string>& rl, uint32_t ups)
  : applicationName(aName), useValidation{ uv }, requestedLayers(rl), updatesPerSecond(ups)
{
}

const uint32_t MAX_PATH_LENGTH = 256;

Viewer::Viewer(const ViewerTraits& vt)
  : viewerTraits{ vt }, 
  startUpdateGraph { updateGraph, [=](tbb::flow::continue_msg) { doNothing(); } },
  endUpdateGraph   { updateGraph, [=](tbb::flow::continue_msg) { doNothing(); } },
  startRenderGraph { renderGraph, [=](tbb::flow::continue_msg) { doNothing(); } },
  endRenderGraph   { renderGraph, [=](tbb::flow::continue_msg) { doNothing(); } }
{
  viewerStartTime     = HPClock::now();
  for(uint32_t i=0; i<3;++i)
    updateStartTimes[i] = viewerStartTime;
  renderStartTime     = viewerStartTime;
  lastRenderDuration  = viewerStartTime - renderStartTime;
  lastUpdateDuration  = viewerStartTime - updateStartTimes[0];

  // register basic directories - directories listed in PUMEX_DATA_DIR environment variable, spearated by semicolon
  const char* dataDirVariable = getenv("PUMEX_DATA_DIR");
  if (dataDirVariable != nullptr)
  {
    const char* currentPos = dataDirVariable;
    do
    {
      const char *begin = currentPos;
      while (*currentPos != ';' && *currentPos != 0)
        currentPos++;
      defaultDirectories.push_back( std::string(begin, currentPos));
    } while (*currentPos++ != 0);
  }

  // register basic directories - current directory
  char strCurrentPath[MAX_PATH_LENGTH];
  if (getcwd(strCurrentPath, MAX_PATH_LENGTH))
  {
    std::string currentDir(strCurrentPath);
    defaultDirectories.push_back(currentDir);
#if defined(_WIN32)
    defaultDirectories.push_back(currentDir + "\\data");
    defaultDirectories.push_back(currentDir + "\\data\\textures");
{'fraction_non_alphanumeric': 0.1410688493018777, 'fraction_numerical': 0.010110736639383727, 'mean_word_length': 5.295454545454546, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5963136', 'n_tokens_mistral': 1479, 'n_tokens_neox': 1419, 'n_words': 271}