Adding getSystemRoot function (#2386)

Adding a cross platform function for getting the OS root
and returning it as a boost::fs::path
This commit is contained in:
Nick Anderson 2016-08-18 09:32:34 -07:00 committed by GitHub
parent 1b75972181
commit fe7b8d98f9
3 changed files with 30 additions and 5 deletions

View File

@ -185,6 +185,19 @@ Status resolveFilePattern(const boost::filesystem::path& pattern,
std::vector<std::string>& results,
GlobLimits setting);
/**
* @brief Returns the OS root system directory.
*
* Some applications store configuration and application data inside of the
* Windows directory. This function retrieves the path to the current
* configurations Windows location.
*
* On POSIX systems this returns "/".
*
* @return an instance of fs::path, containing the OS root location.
*/
boost::filesystem::path getSystemRoot();
/**
* @brief Transform a path with SQL wildcards to globbing wildcard.
*

View File

@ -295,6 +295,16 @@ Status resolveFilePattern(const fs::path& fs_path,
return Status(0, "OK");
}
fs::path getSystemRoot() {
#ifdef WIN32
char winDirectory[MAX_PATH] = {0};
GetWindowsDirectory(winDirectory, MAX_PATH);
return fs::path(winDirectory);
#else
return fs::path("/");
#endif
}
inline void replaceGlobWildcards(std::string& pattern, GlobLimits limits) {
// Replace SQL-wildcard '%' with globbing wildcard '*'.
if (pattern.find("%") != std::string::npos) {

View File

@ -32,21 +32,23 @@ function check_format() {
function audit() {
log "Running various code/change audits!"
echo ""
log "Initializing and updating all submodules"
checkout_thirdparty
# Check the docs creation
echo ""
log "Running: make docs"
make docs
log "Running: make format"
check_format
echo ""
log "Running: make check"
make check
# Check the docs creation
echo ""
log "Running: make format"
check_format
log "Running: make docs"
make docs
}
audit