RigsofRods
Soft-body Physics Simulation
PlatformUtils.h
Go to the documentation of this file.
1 /*
2  This source file is part of Rigs of Rods
3  Copyright 2005-2012 Pierre-Michel Ricordel
4  Copyright 2007-2012 Thomas Fischer
5  Copyright 2013-2020 Petr Ohlidal
6 
7  For more information, see http://www.rigsofrods.org/
8 
9  Rigs of Rods is free software: you can redistribute it and/or modify
10  it under the terms of the GNU General Public License version 3, as
11  published by the Free Software Foundation.
12 
13  Rigs of Rods is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with Rigs of Rods. If not, see <http://www.gnu.org/licenses/>.
20 */
21 
27 
28 #pragma once
29 
30 #include <string>
31 #include <ctime>
32 
33 namespace RoR {
34 
37 
38 extern char PATH_SLASH;
39 
40 bool FileExists(const char* path);
41 bool FolderExists(const char* path);
42 void CreateFolder(const char* path);
43 
44 inline bool FileExists(std::string const& path) { return FileExists(path.c_str()); }
45 inline bool FolderExists(std::string const& path) { return FolderExists(path.c_str()); }
46 inline void CreateFolder(std::string const& path) { CreateFolder(path.c_str()); }
47 
48 inline std::string PathCombine(std::string a, std::string b) { return a + PATH_SLASH + b; };
49 
50 std::string GetUserHomeDirectory();
51 std::string GetExecutablePath();
52 std::string GetParentDirectory(const char* path);
53 
54 std::time_t GetFileLastModifiedTime(std::string const & path);
55 
56 void OpenUrlInDefaultBrowser(std::string const& url);
57 
59 
60 } // namespace RoR
RoR::OpenUrlInDefaultBrowser
void OpenUrlInDefaultBrowser(std::string const &url)
Definition: PlatformUtils.cpp:199
RoR::FolderExists
bool FolderExists(const char *path)
Path must be UTF-8 encoded.
Definition: PlatformUtils.cpp:169
RoR::PATH_SLASH
char PATH_SLASH
Definition: PlatformUtils.cpp:161
RoR::PathCombine
std::string PathCombine(std::string a, std::string b)
Definition: PlatformUtils.h:48
RoR::CreateFolder
void CreateFolder(const char *path)
Path must be UTF-8 encoded.
Definition: PlatformUtils.cpp:175
RoR::GetUserHomeDirectory
std::string GetUserHomeDirectory()
Returns UTF-8 path or empty string on error.
Definition: PlatformUtils.cpp:180
RoR::GetFileLastModifiedTime
std::time_t GetFileLastModifiedTime(std::string const &path)
Definition: PlatformUtils.cpp:238
RoR::GetExecutablePath
std::string GetExecutablePath()
Returns UTF-8 path or empty string on error.
Definition: PlatformUtils.cpp:185
RoR::GetParentDirectory
std::string GetParentDirectory(const char *src_buff)
Returns UTF-8 path without trailing slash.
Definition: PlatformUtils.cpp:209
RoR
Definition: AppContext.h:36
RoR::FileExists
bool FileExists(const char *path)
Path must be UTF-8 encoded.
Definition: PlatformUtils.cpp:163