diff options
author | Matt Strapp <matt@mattstrapp.net> | 2021-09-20 18:15:14 -0500 |
---|---|---|
committer | Matt Strapp <matt@mattstrapp.net> | 2021-09-20 18:15:14 -0500 |
commit | 342403a02f8063903d0f38327430721d4d0ae331 (patch) | |
tree | 29d020a27bc16939c568dd4b29166566d1c0e658 /dev/MinGfx/src/platform.cc | |
parent | Fix parenthesis (diff) | |
download | csci4611-submission-p1.0.tar csci4611-submission-p1.0.tar.gz csci4611-submission-p1.0.tar.bz2 csci4611-submission-p1.0.tar.lz csci4611-submission-p1.0.tar.xz csci4611-submission-p1.0.tar.zst csci4611-submission-p1.0.zip |
do ass1submission-p1.0
Diffstat (limited to '')
-rw-r--r-- | dev/MinGfx/src/platform.cc | 156 |
1 files changed, 78 insertions, 78 deletions
diff --git a/dev/MinGfx/src/platform.cc b/dev/MinGfx/src/platform.cc index 5d941b6..5fd1dbe 100644 --- a/dev/MinGfx/src/platform.cc +++ b/dev/MinGfx/src/platform.cc @@ -1,78 +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 <vector> -#include <sstream> - -#ifdef WIN32 - #include <windows.h> -#else - #include <sys/stat.h> -#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<std::string> &searchpath) { - for (int i=0; i<searchpath.size(); i++) { - std::string fname = searchpath[i] + "/" + basename; - if (Platform::FileExists(fname)) { - return fname; - } - } - return basename; -} - -std::string Platform::FindFile(const std::string &basename, const std::string &searchpath) { - std::vector<std::string> 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<std::string> 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<std::string> 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 +/*
+ 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 <vector>
+#include <sstream>
+
+#ifdef WIN32
+ #include <windows.h>
+#else
+ #include <sys/stat.h>
+#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<std::string> &searchpath) {
+ for (int i=0; i<searchpath.size(); i++) {
+ std::string fname = searchpath[i] + "/" + basename;
+ if (Platform::FileExists(fname)) {
+ return fname;
+ }
+ }
+ return basename;
+}
+
+std::string Platform::FindFile(const std::string &basename, const std::string &searchpath) {
+ std::vector<std::string> 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<std::string> 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<std::string> 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
|