From 9b83919815f6a6ce5d73da1c28483970d0ca5589 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 3 Feb 2021 14:22:28 -0600 Subject: added dev/MinGfx/ --- dev/MinGfx/src/platform.cc | 78 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 dev/MinGfx/src/platform.cc (limited to 'dev/MinGfx/src/platform.cc') diff --git a/dev/MinGfx/src/platform.cc b/dev/MinGfx/src/platform.cc new file mode 100644 index 0000000..5d941b6 --- /dev/null +++ b/dev/MinGfx/src/platform.cc @@ -0,0 +1,78 @@ +/* + Copyright (c) 2017,2018 Regents of the University of Minnesota. + All Rights Reserved. + See corresponding header file for details. + */ + +#include "platform.h" + +#include "mingfx_config.h" + +#include +#include + +#ifdef WIN32 + #include +#else + #include +#endif + + +namespace mingfx { + +bool Platform::FileExists(const std::string &filename) { +#ifdef WIN32 + LPCTSTR szPath = (LPCTSTR)filename.c_str(); + DWORD dwAttrib = GetFileAttributes(szPath); + return (dwAttrib != INVALID_FILE_ATTRIBUTES && + !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY)); +#else + struct stat buf; + return (stat(filename.c_str(), &buf) == 0); +#endif +} + + +std::string Platform::FindFile(const std::string &basename, const std::vector &searchpath) { + for (int i=0; i paths; + std::stringstream ss(searchpath); + std::string path; + while (ss >> path) { + paths.push_back(path); + if (ss.peek() == ';') + ss.ignore(); + } + return FindFile(basename, paths); +} + + +std::string Platform::FindMinGfxDataFile(const std::string &basename) { + std::vector searchpath; + searchpath.push_back("."); + searchpath.push_back("data"); + searchpath.push_back(MINGFX_DATA_DIR_INSTALL); + searchpath.push_back(MINGFX_DATA_DIR_BUILD); + return FindFile(basename, searchpath); +} + +std::string Platform::FindMinGfxShaderFile(const std::string &basename) { + std::vector searchpath; + searchpath.push_back("."); + searchpath.push_back("shaders"); + searchpath.push_back(MINGFX_SHADERS_DIR_INSTALL); + searchpath.push_back(MINGFX_SHADERS_DIR_BUILD); + return FindFile(basename, searchpath); +} + + +} // end namespace -- cgit v1.2.3