aboutsummaryrefslogtreecommitdiffstats
path: root/dev/MinGfx/src/platform.h
blob: e609756774dc83c7cfeae85371059fe854c1b8a5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
 This file is part of the MinGfx Project.
 
 Copyright (c) 2017,2018 Regents of the University of Minnesota.
 All Rights Reserved.
 
 Original Author(s) of this File:
	Dan Keefe, 2018, University of Minnesota
	
 Author(s) of Significant Updates/Modifications to the File:
	...
 */

#ifndef SRC_PLATFORM_H_
#define SRC_PLATFORM_H_

#include <string>
#include <vector>

namespace mingfx {
    
    
/** Provides access to the underlying file system and other platform-specific 
 routines.
 */
class Platform {
public:
    
    /// True if filename is found and can be opened for reading on the system
    static bool FileExists(const std::string &filename);
 
    /* Looks for a file named basename in each of the paths specified.  If found,
     the full path to the file is returned.  If not found, then basename is returned.
     Example:
     ~~~
     std::vector<std::string> search_path;
     search_path.push_back(".");
     search_path.push_back("./data");
     search_path.push_back("./shaders");
     search_path.push_back("/usr/local/share/blah/blah/data");
     
     std::string file = Platform::findFile("mydata.csv", search_path);
     ~~~
     */
    static std::string FindFile(const std::string &basename, const std::vector<std::string> &searchpath);

    /* Looks for a file named basename in each of the paths specified in a semi-colon
     separated list.  If found, the full path to the file is returned.  If not found, 
     then basename is returned. Example:
     ~~~
     std::string search_path = ".;./data;./shaders;/usr/local/share/blah/blah/data";
     std::string file = Platform::findFile("mydata.csv", search_path);
     ~~~
     */
    static std::string FindFile(const std::string &basename, const std::string &searchpath);

    /** Searches for a data file that ships with MinGfx.  This will look in the
     following locations in order:
     1. the current working directory.
     2. a subdirectory called data within the current working directory.
     3. the installed data directory INSTALL_PREFIX/share/MinGfx-1.0/data.
     4. the data directory in the MinGfx build tree.
     If the file is found, the full path is returned, else basename is returned.
     */
    static std::string FindMinGfxDataFile(const std::string &basename);

    /** Searches for a shader file that ships with MinGfx.  This will look in the
     following locations in order:
     1. the current working directory.
     2. a subdirectory called shaders within the current working directory.
     3. the installed shaders directory INSTALL_PREFIX/share/MinGfx-1.0/shaders.
     4. the shaders directory in the MinGfx build tree.
     If the file is found, the full path is returned, else basename is returned.
     */
    static std::string FindMinGfxShaderFile(const std::string &basename);
    
private:
};


} // end namespace

#endif