Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions inc/osvr/Util/Directories.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/** @file
@brief Helper functions for determine where to load or store configuration files, log files, etc.

@date 2016

@author
Sensics, Inc.
<http://sensics.com>

*/

// Copyright 2016 Sensics, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef INCLUDED_Directories_h_GUID_924A614D_303C_470D_9AC4_01BCBE8F1104
#define INCLUDED_Directories_h_GUID_924A614D_303C_470D_9AC4_01BCBE8F1104

// Internal Includes
#include <osvr/Util/Export.h>

// Library/third-party includes
// - none

// Standard includes
#include <string>
#include <vector>

namespace osvr {
namespace util {

enum OSVR_UTIL_EXPORT DirectoryType {
USER_DIRECTORY_DATA, ///< user-specific data files
USER_DIRECTORY_CONFIG, ///< user-specific configuration files
USER_DIRECTORY_CACHE, ///< user-specific non-essential data files
USER_DIRECTORY_STATE, ///< user-specific state files
USER_DIRECTORY_LOG, ///< user-specific log files
SITE_DIRECTORY_DATA, ///< system-wide data files
SITE_DIRECTORY_CONFIG, ///< system-wide configuration files
USER_DIRECTORY_DESKTOP, ///< the user's Desktop directory
USER_DIRECTORY_DOCUMENTS, ///< the user's Documents directory
USER_DIRECTORY_DOWNLOAD, ///< the user's Downloads directory
USER_DIRECTORY_MUSIC, ///< the user's Music directory
USER_DIRECTORY_PICTURES, ///< the user's Pictures directory
USER_DIRECTORY_PUBLIC_SHARE, ///< the user's shared directory
USER_DIRECTORY_TEMPLATES, ///< the user's Templates directory
USER_DIRECTORY_VIDEOS ///< the user's Movies directory
};

OSVR_UTIL_EXPORT std::vector<std::string> getDirectories(DirectoryType dirtype, const std::string& appname = "OSVR", const std::string& author = "", const std::string& version = "");

/**
* @brief Return full path to the requested directory type.
*
* @param dirtype The requested directory to return.
*/
OSVR_UTIL_EXPORT std::string getDirectory(const DirectoryType dirtype, const std::string& appname = "OSVR", const std::string& author = "", const std::string& version = "");

OSVR_UTIL_EXPORT std::string getUserDataDir(const std::string& appname = "OSVR", const std::string& author = "", const std::string& version = "");

} // end namespace util
} // end namespace osvr

#endif // INCLUDED_Directories_h_GUID_924A614D_303C_470D_9AC4_01BCBE8F1104

6 changes: 5 additions & 1 deletion inc/osvr/Util/GetEnvironmentVariable.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,12 @@ namespace util {
OSVR_UTIL_EXPORT boost::optional<std::string>
getEnvironmentVariable(std::string const &var);

/// @brief Gets an environment variable's value. If the environment
/// variable is not set or is empty, the fallback value will be returned.
OSVR_UTIL_EXPORT std::string
getEnvironmentVariable(std::string const &var, std::string const &fallback);

} // namespace util
} // namespace osvr

#endif // INCLUDED_GetEnvironmentVariable_h_GUID_500031B7_31FB_45A1_B1E9_8E61905A4E0F

3 changes: 3 additions & 0 deletions src/osvr/Util/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ set(API
"${HEADER_LOCATION}/DefaultPort.h"
"${HEADER_LOCATION}/Deletable.h"
"${HEADER_LOCATION}/DeviceCallbackTypesC.h"
"${HEADER_LOCATION}/Directories.h"
"${HEADER_LOCATION}/EigenCoreGeometry.h"
"${HEADER_LOCATION}/EigenExtras.h"
"${HEADER_LOCATION}/EigenFilters.h"
Expand Down Expand Up @@ -146,6 +147,7 @@ set(SOURCE
AnyMap.cpp
BinaryLocation.cpp
Deletable.cpp
Directories.cpp
GetEnvironmentVariable.cpp
GuardInterface.cpp
TimeValueC.cpp
Expand Down Expand Up @@ -196,6 +198,7 @@ target_link_libraries(${LIBNAME_FULL}
eigen-headers
spdlog
boost_filesystem
${Boost_SYSTEM_LIBRARY}
osvrTypePack)

if(ANDROID)
Expand Down
Loading