Commit e4d3f775 authored by Alex Cooper's avatar Alex Cooper Committed by Commit Bot

Roll OpenVR SDK 1.8.19

The OpenVR SDK has made some changes that we need since the last time it
was updated. Primarily, this is the addition of the method:
GetAppContainerFilePaths and a few other updates intended to allow the
SDK to work better in the AppContainer version of the WebXr device
process.

Some prototyping will still need to be done before this can actually be
achieved, but doing this first roll better enables that and sets up a
(hopefully) smaller diff if another roll is needed due to any issues
discovered during prototyping.

Fixed:845255

Change-Id: I6f9af21df282b3fe90cd9855aefd4b4ff9cc3c56
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1935411Reviewed-by: default avatarBrandon Jones <bajones@chromium.org>
Commit-Queue: Alexander Cooper <alcooper@chromium.org>
Cr-Commit-Position: refs/heads/master@{#722658}
parent 14cb217e
...@@ -88,6 +88,10 @@ if (enable_vr) { ...@@ -88,6 +88,10 @@ if (enable_vr) {
} }
if (enable_openvr) { if (enable_openvr) {
if (!is_component_build) {
defines += ["OPENVR_BUILD_STATIC"]
}
deps += [ "//third_party/openvr:openvr" ] deps += [ "//third_party/openvr:openvr" ]
sources += [ sources += [
"openvr/openvr_api_wrapper.cc", "openvr/openvr_api_wrapper.cc",
......
...@@ -51,6 +51,9 @@ device::mojom::XRHandedness ConvertToMojoHandedness( ...@@ -51,6 +51,9 @@ device::mojom::XRHandedness ConvertToMojoHandedness(
case vr::TrackedControllerRole_RightHand: case vr::TrackedControllerRole_RightHand:
return device::mojom::XRHandedness::RIGHT; return device::mojom::XRHandedness::RIGHT;
case vr::TrackedControllerRole_Invalid: case vr::TrackedControllerRole_Invalid:
case vr::TrackedControllerRole_OptOut:
case vr::TrackedControllerRole_Treadmill:
case vr::TrackedControllerRole_Max:
return device::mojom::XRHandedness::NONE; return device::mojom::XRHandedness::NONE;
} }
......
...@@ -48,6 +48,11 @@ class TestVRSystem : public IVRSystem { ...@@ -48,6 +48,11 @@ class TestVRSystem : public IVRSystem {
return 0; return 0;
} }
void GetDXGIOutputInfo(int32_t* adapter_index) override; void GetDXGIOutputInfo(int32_t* adapter_index) override;
void GetOutputDevice(uint64_t* pnDevice,
ETextureType textureType,
VkInstance_T* pInstance = nullptr) override {
NOTIMPLEMENTED();
}
bool IsDisplayOnDesktop() override { bool IsDisplayOnDesktop() override {
NOTIMPLEMENTED(); NOTIMPLEMENTED();
return false; return false;
...@@ -127,6 +132,16 @@ class TestVRSystem : public IVRSystem { ...@@ -127,6 +132,16 @@ class TestVRSystem : public IVRSystem {
NOTIMPLEMENTED(); NOTIMPLEMENTED();
return {}; return {};
} }
uint32_t GetArrayTrackedDeviceProperty(
vr::TrackedDeviceIndex_t unDeviceIndex,
ETrackedDeviceProperty prop,
PropertyTypeTag_t propType,
void* pBuffer,
uint32_t unBufferSize,
ETrackedPropertyError* pError = 0L) override {
NOTIMPLEMENTED();
return 0;
}
uint32_t GetStringTrackedDeviceProperty( uint32_t GetStringTrackedDeviceProperty(
TrackedDeviceIndex_t device_index, TrackedDeviceIndex_t device_index,
ETrackedDeviceProperty prop, ETrackedDeviceProperty prop,
...@@ -179,21 +194,21 @@ class TestVRSystem : public IVRSystem { ...@@ -179,21 +194,21 @@ class TestVRSystem : public IVRSystem {
NOTIMPLEMENTED(); NOTIMPLEMENTED();
return nullptr; return nullptr;
} }
bool CaptureInputFocus() override { bool IsInputAvailable() override {
NOTIMPLEMENTED(); NOTIMPLEMENTED();
return false; return false;
} }
void ReleaseInputFocus() override { NOTIMPLEMENTED(); } bool IsSteamVRDrawingControllers() override {
bool IsInputFocusCapturedByAnotherProcess() override {
NOTIMPLEMENTED(); NOTIMPLEMENTED();
return false; return false;
} }
uint32_t DriverDebugRequest(TrackedDeviceIndex_t device_index, bool ShouldApplicationPause() override {
const char* request,
char* response_buffer,
uint32_t response_buffer_size) override {
NOTIMPLEMENTED(); NOTIMPLEMENTED();
return 0; return false;
}
bool ShouldApplicationReduceRenderingWork() override {
NOTIMPLEMENTED();
return false;
} }
EVRFirmwareError PerformFirmwareUpdate( EVRFirmwareError PerformFirmwareUpdate(
TrackedDeviceIndex_t device_index) override { TrackedDeviceIndex_t device_index) override {
...@@ -201,7 +216,15 @@ class TestVRSystem : public IVRSystem { ...@@ -201,7 +216,15 @@ class TestVRSystem : public IVRSystem {
return VRFirmwareError_None; return VRFirmwareError_None;
} }
void AcknowledgeQuit_Exiting() override { NOTIMPLEMENTED(); } void AcknowledgeQuit_Exiting() override { NOTIMPLEMENTED(); }
void AcknowledgeQuit_UserPrompt() override { NOTIMPLEMENTED(); } uint32_t GetAppContainerFilePaths(VR_OUT_STRING() char* pchBuffer,
uint32_t unBufferSize) override {
NOTIMPLEMENTED();
return 0;
}
const char* GetRuntimeVersion() override {
NOTIMPLEMENTED();
return "";
}
}; };
class TestVRCompositor : public IVRCompositor { class TestVRCompositor : public IVRCompositor {
...@@ -357,11 +380,31 @@ class TestVRCompositor : public IVRCompositor { ...@@ -357,11 +380,31 @@ class TestVRCompositor : public IVRCompositor {
NOTIMPLEMENTED(); NOTIMPLEMENTED();
return 0; return 0;
} }
void SetExplicitTimingMode(EVRCompositorTimingMode eTimingMode) override {
NOTIMPLEMENTED();
}
EVRCompositorError SubmitExplicitTimingData() override {
NOTIMPLEMENTED();
return VRCompositorError_None;
}
bool IsMotionSmoothingEnabled() override {
NOTIMPLEMENTED();
return false;
}
bool IsMotionSmoothingSupported() override {
NOTIMPLEMENTED();
return false;
}
bool IsCurrentSceneFocusAppLoading() override {
NOTIMPLEMENTED();
return false;
}
}; };
class TestVRClientCore : public IVRClientCore { class TestVRClientCore : public IVRClientCore {
public: public:
EVRInitError Init(EVRApplicationType application_type) override; EVRInitError Init(EVRApplicationType application_type,
const char* pStartupInfo) override;
void Cleanup() override; void Cleanup() override;
EVRInitError IsInterfaceVersionValid(const char* interface_version) override; EVRInitError IsInterfaceVersionValid(const char* interface_version) override;
void* GetGenericInterface(const char* name_and_version, void* GetGenericInterface(const char* name_and_version,
...@@ -382,7 +425,8 @@ TestVRSystem g_system; ...@@ -382,7 +425,8 @@ TestVRSystem g_system;
TestVRCompositor g_compositor; TestVRCompositor g_compositor;
TestVRClientCore g_loader; TestVRClientCore g_loader;
EVRInitError TestVRClientCore::Init(EVRApplicationType application_type) { EVRInitError TestVRClientCore::Init(EVRApplicationType application_type,
const char* pStartupInfo) {
return VRInitError_None; return VRInitError_None;
} }
......
Name: OpenVR SDK Name: OpenVR SDK
Short Name: OpenVR Short Name: OpenVR
URL: https://github.com/ValveSoftware/openvr URL: https://github.com/ValveSoftware/openvr
Version: 1.0.4 Version: 1.8.19
Date: 2 Feb 2017 Date: 5 Nov 2019
Revision: 7fa6470f2972970859f2395f1390f6d87d4b0fc3 Revision: 176b58f6ccaaae3e9d14efaf612c50b72ec5da76
License: BSD 3-Clause License: BSD 3-Clause
License File: src/LICENSE License File: src/LICENSE
Security Critical: yes Security Critical: yes
...@@ -12,15 +12,14 @@ Description: ...@@ -12,15 +12,14 @@ Description:
The OpenVR API supports HTC Vive and other headsets for VR. The OpenVR API supports HTC Vive and other headsets for VR.
Local Modifications: Local Modifications:
Only contains a subset of the git repo necessary to build Chromium. Only contains a subset of the git repo necessary to build Chromium. (Note that
openvr.h has been modified to remove dllimport/dllexport when building a this includes removing jsoncpp as we use it from \\third_party).
non-component build so this can be built as a static library.
Redefined VRLog to avoid logspam on startup. Redefined VRLog to avoid logspam on startup.
We use jsoncpp from \\third_party. Define alloca to map to _alloca on Windows
merge https://github.com/ValveSoftware/openvr/pull/1048 Use #defines to remove try/catch from vrpathregistry_public.cpp
Copy the correct files with these commands: Copy the correct files with these commands:
copy %openvrsdk%\README.md %chromium%\src\third_party\openvr\src copy %openvrsdk%\README.md %chromiumopenvr%\src
copy %openvrsdk%\LICENSE %chromium%\src\third_party\openvr\src copy %openvrsdk%\LICENSE %chromiumopenvr%\src
xcopy /S %openvrsdk%\src %chromium%\src\third_party\openvr\src\src xcopy /S %openvrsdk%\src %chromiumopenvr%\src\src /EXCLUDE:%chromiumopenvr%\openvr_jsoncpp.txt
xcopy /S %openvrsdk%\headers %chromium%\src\third_party\openvr\src\headers xcopy /S %openvrsdk%\headers %chromiumopenvr%\src\headers /EXCLUDE:%chromiumopenvr%\openvr_jsoncpp.txt
src\json
headers\openvr_api.json
headers\openvr_api.cs
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -2,18 +2,19 @@ ...@@ -2,18 +2,19 @@
project(openvr_api) project(openvr_api)
set( LIBNAME "openvr_api" ) set( LIBNAME "openvr_api" )
set(OPENVR_HEADER_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../headers)
# Set some properies for specific files. # Set some properies for specific files.
if(APPLE) if(APPLE)
set(CMAKE_MACOSX_RPATH 0) set(CMAKE_MACOSX_RPATH 1)
if(CMAKE_SYSTEM_NAME MATCHES "Darwin") if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
set_source_files_properties(vrcommon/pathtools_public.cpp vrcommon/vrpathregistry_public.cpp PROPERTIES COMPILE_FLAGS "-x objective-c++") set_source_files_properties(vrcommon/pathtools_public.cpp vrcommon/vrpathregistry_public.cpp PROPERTIES COMPILE_FLAGS "-x objective-c++")
endif() endif()
if(BUILD_SHARED) if(BUILD_SHARED OR BUILD_FRAMEWORK)
find_library(FOUNDATION_FRAMEWORK Foundation) find_library(FOUNDATION_FRAMEWORK Foundation)
mark_as_advanced(FOUNDATION_FRAMEWORK) mark_as_advanced(FOUNDATION_FRAMEWORK)
set(EXTRA_LIBS ${EXTRA_LIBS} ${FOUNDATION_FRAMEWORK}) set(EXTRA_LIBS ${EXTRA_LIBS} ${FOUNDATION_FRAMEWORK})
endif(BUILD_SHARED) endif(BUILD_SHARED OR BUILD_FRAMEWORK)
elseif(WIN32) elseif(WIN32)
if(CMAKE_SIZEOF_VOID_P EQUAL 8) if(CMAKE_SIZEOF_VOID_P EQUAL 8)
add_definitions( -DWIN64 ) add_definitions( -DWIN64 )
...@@ -22,7 +23,7 @@ elseif(WIN32) ...@@ -22,7 +23,7 @@ elseif(WIN32)
endif() endif()
# Add include folders. # Add include folders.
include_directories(${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/headers ${CMAKE_SOURCE_DIR}/src/vrcommon) include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../headers ${CMAKE_CURRENT_SOURCE_DIR}/vrcommon)
if(USE_CUSTOM_LIBCXX) if(USE_CUSTOM_LIBCXX)
link_directories( link_directories(
...@@ -50,6 +51,12 @@ set(SOURCE_FILES ...@@ -50,6 +51,12 @@ set(SOURCE_FILES
${VRCOMMON_FILES} ${VRCOMMON_FILES}
) )
set(PUBLIC_HEADER_FILES
${OPENVR_HEADER_DIR}/openvr_driver.h
${OPENVR_HEADER_DIR}/openvr_capi.h
${OPENVR_HEADER_DIR}/openvr.h
)
source_group("Src" FILES source_group("Src" FILES
${CORE_FILES} ${CORE_FILES}
) )
...@@ -61,6 +68,28 @@ source_group("VRCommon" FILES ...@@ -61,6 +68,28 @@ source_group("VRCommon" FILES
# Build the library. # Build the library.
if(BUILD_SHARED) if(BUILD_SHARED)
add_library(${LIBNAME} SHARED ${SOURCE_FILES}) add_library(${LIBNAME} SHARED ${SOURCE_FILES})
elseif(BUILD_FRAMEWORK)
set( LIBNAME "OpenVR" )
add_library( ${LIBNAME}
SHARED ${SOURCE_FILES}
${CMAKE_SOURCE_DIR}/headers/openvr.h
${CMAKE_SOURCE_DIR}/headers/openvr_api.cs
${CMAKE_SOURCE_DIR}/headers/openvr_api.json
${CMAKE_SOURCE_DIR}/headers/openvr_capi.h
${CMAKE_SOURCE_DIR}/headers/openvr_driver.h
)
set_target_properties(OpenVR PROPERTIES
FRAMEWORK TRUE
FRAMEWORK_VERSION A
MACOSX_FRAMEWORK_IDENTIFIER com.valvesoftware.OpenVR.framework
MACOSX_FRAMEWORK_INFO_PLIST ${CMAKE_SOURCE_DIR}/src/Info.plist
# "current version" in semantic format in Mach-O binary file
VERSION 1.0.6
# "compatibility version" in semantic format in Mach-O binary file
SOVERSION 1.0.0
PUBLIC_HEADER "${CMAKE_SOURCE_DIR}/headers/openvr.h;${CMAKE_SOURCE_DIR}/headers/openvr_api.cs;${CMAKE_SOURCE_DIR}/headers/openvr_api.json;${CMAKE_SOURCE_DIR}/headers/openvr_capi.h;${CMAKE_SOURCE_DIR}/headers/openvr_driver.h"
LINKER_LANGUAGE CXX
)
else() else()
add_library(${LIBNAME} STATIC ${SOURCE_FILES}) add_library(${LIBNAME} STATIC ${SOURCE_FILES})
endif() endif()
...@@ -69,6 +98,19 @@ if(USE_CUSTOM_LIBCXX) ...@@ -69,6 +98,19 @@ if(USE_CUSTOM_LIBCXX)
set(EXTRA_LIBS ${EXTRA_LIBS} c++ c++abi) set(EXTRA_LIBS ${EXTRA_LIBS} c++ c++abi)
endif() endif()
target_link_libraries(${LIBNAME} ${EXTRA_LIBS}) target_link_libraries(${LIBNAME} ${EXTRA_LIBS} ${CMAKE_DL_LIBS})
target_include_directories(${LIBNAME} PUBLIC ${OPENVR_HEADER_DIR})
install(TARGETS ${LIBNAME} DESTINATION lib) install(TARGETS ${LIBNAME} DESTINATION lib)
install(FILES ${PUBLIC_HEADER_FILES} DESTINATION include/openvr)
# Generate a .pc file for linux environments
if(PLATFORM_NAME MATCHES "linux")
set(INSTALL_PKGCONFIG_DIR "${CMAKE_INSTALL_PREFIX}/share/pkgconfig" CACHE PATH "Installation directory for pkgconfig (.pc) files")
CONFIGURE_FILE("openvr.pc.in" "openvr.pc" @ONLY)
set(OPENVR_PC ${CMAKE_CURRENT_BINARY_DIR}/openvr.pc)
if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
install(FILES ${OPENVR_PC} DESTINATION "${INSTALL_PKGCONFIG_DIR}")
endif()
endif()
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleIdentifier</key>
<string>com.valvesoftware.OpenVR.framework</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>OpenVR</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1.0</string>
</dict>
</plist>
...@@ -3,9 +3,9 @@ OpenVR applications to the SteamVR runtime, taking into account the version ...@@ -3,9 +3,9 @@ OpenVR applications to the SteamVR runtime, taking into account the version
of the OpenVR interface they were compiled against. of the OpenVR interface they were compiled against.
The client binding library - openvr_api.dll on Windows, openvr_api.so on The client binding library - openvr_api.dll on Windows, openvr_api.so on
Linux, and openvr_api.dylib on macOS - knows how to find and read the Linux, and openvr_api.dylib or OpenVR.framework on macOS - knows how to find
SteamVR runtime installation information which allows it to find and and read the SteamVR runtime installation information which allows it to
dynamically connect to the installed runtime. In combination with the find and dynamically connect to the installed runtime. In combination with the
interface version identifiers from /include/openvr.h which are baked interface version identifiers from /include/openvr.h which are baked
into applications at the time they are built, the OpenVR API client into applications at the time they are built, the OpenVR API client
binding library captures and conveys to the SteamVR runtime the version binding library captures and conveys to the SteamVR runtime the version
...@@ -32,4 +32,8 @@ for your platform. For example, to build on a POSIX system simply perform ...@@ -32,4 +32,8 @@ for your platform. For example, to build on a POSIX system simply perform
cd src; mkdir _build; cd _build; cmake ..; make cd src; mkdir _build; cd _build; cmake ..; make
and you will end up with the static library /src/_build/libopenvr_api.a and you will end up with the static library /src/bin/<arch>/libopenvr_api.a
\ No newline at end of file
To build a shared library, pass -DBUILD_SHARED=1 to cmake.
To build as a framework on apple platforms, pass -DBUILD_FRAMEWORK=1 to cmake.
To see a complete list of configurable build options, use `cmake -LAH`
...@@ -8,7 +8,7 @@ class IVRClientCore ...@@ -8,7 +8,7 @@ class IVRClientCore
{ {
public: public:
/** Initializes the system */ /** Initializes the system */
virtual EVRInitError Init( vr::EVRApplicationType eApplicationType ) = 0; virtual EVRInitError Init( vr::EVRApplicationType eApplicationType, const char *pStartupInfo ) = 0;
/** cleans up everything in vrclient.dll and prepares the DLL to be unloaded */ /** cleans up everything in vrclient.dll and prepares the DLL to be unloaded */
virtual void Cleanup() = 0; virtual void Cleanup() = 0;
...@@ -22,14 +22,14 @@ public: ...@@ -22,14 +22,14 @@ public:
/** Returns true if any driver has an HMD attached. Can be called outside of Init/Cleanup */ /** Returns true if any driver has an HMD attached. Can be called outside of Init/Cleanup */
virtual bool BIsHmdPresent() = 0; virtual bool BIsHmdPresent() = 0;
/** Returns an english error string from inside vrclient.dll which might be newer than the API DLL */ /** Returns an English error string from inside vrclient.dll which might be newer than the API DLL */
virtual const char *GetEnglishStringForHmdError( vr::EVRInitError eError ) = 0; virtual const char *GetEnglishStringForHmdError( vr::EVRInitError eError ) = 0;
/** Returns an error symbol from inside vrclient.dll which might be newer than the API DLL */ /** Returns an error symbol from inside vrclient.dll which might be newer than the API DLL */
virtual const char *GetIDForVRInitError( vr::EVRInitError eError ) = 0; virtual const char *GetIDForVRInitError( vr::EVRInitError eError ) = 0;
}; };
static const char * const IVRClientCore_Version = "IVRClientCore_002"; static const char * const IVRClientCore_Version = "IVRClientCore_003";
} }
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix}
libdir=${prefix}/lib
includedir=${prefix}/include/openvr
Name: openvr
Description: OpenVR is an API and runtime that allos access to VR hardware.
Version: @OPENVR_VERSION@
Libs: -L${libdir} -lopenvr_api -ldl
Cflags: -I${includedir}
...@@ -6,18 +6,38 @@ ...@@ -6,18 +6,38 @@
#include "sharedlibtools_public.h" #include "sharedlibtools_public.h"
#include "envvartools_public.h" #include "envvartools_public.h"
#include "hmderrors_public.h" #include "hmderrors_public.h"
#include "strtools_public.h"
#include "vrpathregistry_public.h" #include "vrpathregistry_public.h"
#include <mutex>
using vr::EVRInitError; using vr::EVRInitError;
using vr::IVRSystem; using vr::IVRSystem;
using vr::IVRClientCore; using vr::IVRClientCore;
using vr::VRInitError_None; using vr::VRInitError_None;
// figure out how to import from the VR API dll
#if defined(_WIN32)
#if !defined(OPENVR_BUILD_STATIC)
#define VR_EXPORT_INTERFACE extern "C" __declspec( dllexport )
#else
#define VR_EXPORT_INTERFACE extern "C"
#endif
#elif defined(__GNUC__) || defined(COMPILER_GCC) || defined(__APPLE__)
#define VR_EXPORT_INTERFACE extern "C" __attribute__((visibility("default")))
#else
#error "Unsupported Platform."
#endif
namespace vr namespace vr
{ {
static void *g_pVRModule = NULL; static void *g_pVRModule = NULL;
static IVRClientCore *g_pHmdSystem = NULL; static IVRClientCore *g_pHmdSystem = NULL;
static std::recursive_mutex g_mutexSystem;
typedef void* (*VRClientCoreFactoryFn)(const char *pInterfaceName, int *pReturnCode); typedef void* (*VRClientCoreFactoryFn)(const char *pInterfaceName, int *pReturnCode);
...@@ -33,50 +53,50 @@ EVRInitError VR_LoadHmdSystemInternal(); ...@@ -33,50 +53,50 @@ EVRInitError VR_LoadHmdSystemInternal();
void CleanupInternalInterfaces(); void CleanupInternalInterfaces();
uint32_t VR_InitInternal( EVRInitError *peError, vr::EVRApplicationType eApplicationType ) uint32_t VR_InitInternal2( EVRInitError *peError, vr::EVRApplicationType eApplicationType, const char *pStartupInfo )
{ {
std::lock_guard<std::recursive_mutex> lock( g_mutexSystem );
EVRInitError err = VR_LoadHmdSystemInternal(); EVRInitError err = VR_LoadHmdSystemInternal();
if (err != vr::VRInitError_None) if ( err == vr::VRInitError_None )
{ {
SharedLib_Unload(g_pVRModule); err = g_pHmdSystem->Init( eApplicationType, pStartupInfo );
g_pHmdSystem = NULL;
g_pVRModule = NULL;
if (peError)
*peError = err;
return 0;
} }
err = g_pHmdSystem->Init(eApplicationType); if ( peError )
if (err != VRInitError_None) *peError = err;
if ( err != VRInitError_None )
{ {
SharedLib_Unload(g_pVRModule); SharedLib_Unload( g_pVRModule );
g_pHmdSystem = NULL; g_pHmdSystem = NULL;
g_pVRModule = NULL; g_pVRModule = NULL;
if (peError)
*peError = err;
return 0; return 0;
} }
if (peError)
*peError = VRInitError_None;
return ++g_nVRToken; return ++g_nVRToken;
} }
VR_INTERFACE uint32_t VR_CALLTYPE VR_InitInternal( EVRInitError *peError, EVRApplicationType eApplicationType );
uint32_t VR_InitInternal( EVRInitError *peError, vr::EVRApplicationType eApplicationType )
{
return VR_InitInternal2( peError, eApplicationType, nullptr );
}
void VR_ShutdownInternal() void VR_ShutdownInternal()
{ {
if (g_pHmdSystem) std::lock_guard<std::recursive_mutex> lock( g_mutexSystem );
if ( g_pHmdSystem )
{ {
g_pHmdSystem->Cleanup(); g_pHmdSystem->Cleanup();
g_pHmdSystem = NULL; g_pHmdSystem = NULL;
} }
if (g_pVRModule) if ( g_pVRModule )
{ {
SharedLib_Unload(g_pVRModule); SharedLib_Unload( g_pVRModule );
g_pVRModule = NULL; g_pVRModule = NULL;
} }
...@@ -106,7 +126,7 @@ EVRInitError VR_LoadHmdSystemInternal() ...@@ -106,7 +126,7 @@ EVRInitError VR_LoadHmdSystemInternal()
// Because we don't have a way to select debug vs. release yet we'll just // Because we don't have a way to select debug vs. release yet we'll just
// use debug if it's there // use debug if it's there
#if defined( LINUX64 ) #if defined( LINUX64 ) || defined( LINUXARM64 )
std::string sTestPath = Path_Join( sRuntimePath, "bin", PLATSUBDIR ); std::string sTestPath = Path_Join( sRuntimePath, "bin", PLATSUBDIR );
#else #else
std::string sTestPath = Path_Join( sRuntimePath, "bin" ); std::string sTestPath = Path_Join( sRuntimePath, "bin" );
...@@ -152,6 +172,8 @@ EVRInitError VR_LoadHmdSystemInternal() ...@@ -152,6 +172,8 @@ EVRInitError VR_LoadHmdSystemInternal()
void *VR_GetGenericInterface(const char *pchInterfaceVersion, EVRInitError *peError) void *VR_GetGenericInterface(const char *pchInterfaceVersion, EVRInitError *peError)
{ {
std::lock_guard<std::recursive_mutex> lock( g_mutexSystem );
if (!g_pHmdSystem) if (!g_pHmdSystem)
{ {
if (peError) if (peError)
...@@ -164,6 +186,8 @@ void *VR_GetGenericInterface(const char *pchInterfaceVersion, EVRInitError *peEr ...@@ -164,6 +186,8 @@ void *VR_GetGenericInterface(const char *pchInterfaceVersion, EVRInitError *peEr
bool VR_IsInterfaceVersionValid(const char *pchInterfaceVersion) bool VR_IsInterfaceVersionValid(const char *pchInterfaceVersion)
{ {
std::lock_guard<std::recursive_mutex> lock( g_mutexSystem );
if (!g_pHmdSystem) if (!g_pHmdSystem)
{ {
return false; return false;
...@@ -174,6 +198,8 @@ bool VR_IsInterfaceVersionValid(const char *pchInterfaceVersion) ...@@ -174,6 +198,8 @@ bool VR_IsInterfaceVersionValid(const char *pchInterfaceVersion)
bool VR_IsHmdPresent() bool VR_IsHmdPresent()
{ {
std::lock_guard<std::recursive_mutex> lock( g_mutexSystem );
if( g_pHmdSystem ) if( g_pHmdSystem )
{ {
// if we're already initialized, just call through // if we're already initialized, just call through
...@@ -199,6 +225,8 @@ bool VR_IsHmdPresent() ...@@ -199,6 +225,8 @@ bool VR_IsHmdPresent()
/** Returns true if the OpenVR runtime is installed. */ /** Returns true if the OpenVR runtime is installed. */
bool VR_IsRuntimeInstalled() bool VR_IsRuntimeInstalled()
{ {
std::lock_guard<std::recursive_mutex> lock( g_mutexSystem );
if( g_pHmdSystem ) if( g_pHmdSystem )
{ {
// if we're already initialized, OpenVR is obviously installed // if we're already initialized, OpenVR is obviously installed
...@@ -228,33 +256,71 @@ bool VR_IsRuntimeInstalled() ...@@ -228,33 +256,71 @@ bool VR_IsRuntimeInstalled()
} }
// -------------------------------------------------------------------------------
// Purpose: This is the old Runtime Path interface that is no longer exported in the
// latest header. We still want to export it from the DLL, though, so updating
// to a new DLL doesn't break old compiled code. This version was not thread
// safe and could change the buffer pointer to by a previous result on a
// subsequent call
// -------------------------------------------------------------------------------
VR_EXPORT_INTERFACE const char *VR_CALLTYPE VR_RuntimePath();
/** Returns where OpenVR runtime is installed. */ /** Returns where OpenVR runtime is installed. */
const char *VR_RuntimePath() const char *VR_RuntimePath()
{
static char rchBuffer[1024];
uint32_t unRequiredSize;
if ( VR_GetRuntimePath( rchBuffer, sizeof( rchBuffer ), &unRequiredSize ) && unRequiredSize < sizeof( rchBuffer ) )
{
return rchBuffer;
}
else
{
return nullptr;
}
}
/** Returns where OpenVR runtime is installed. */
bool VR_GetRuntimePath( char *pchPathBuffer, uint32_t unBufferSize, uint32_t *punRequiredBufferSize )
{ {
// otherwise we need to do a bit more work // otherwise we need to do a bit more work
static std::string sRuntimePath; std::string sRuntimePath;
std::string sConfigPath, sLogPath;
bool bReadPathRegistry = CVRPathRegistry_Public::GetPaths( &sRuntimePath, &sConfigPath, &sLogPath, NULL, NULL ); *punRequiredBufferSize = 0;
bool bReadPathRegistry = CVRPathRegistry_Public::GetPaths( &sRuntimePath, nullptr, nullptr, nullptr, nullptr );
if ( !bReadPathRegistry ) if ( !bReadPathRegistry )
{ {
return nullptr; return false;
} }
// figure out where we're going to look for vrclient.dll // figure out where we're going to look for vrclient.dll
// see if the specified path actually exists. // see if the specified path actually exists.
if ( !Path_IsDirectory( sRuntimePath ) ) if ( !Path_IsDirectory( sRuntimePath ) )
{ {
return nullptr; return false;
}
*punRequiredBufferSize = (uint32_t)sRuntimePath.size() + 1;
if ( sRuntimePath.size() >= unBufferSize )
{
*pchPathBuffer = '\0';
}
else
{
strcpy_safe( pchPathBuffer, unBufferSize, sRuntimePath.c_str() );
} }
return sRuntimePath.c_str(); return true;
} }
/** Returns the symbol version of an HMD error. */ /** Returns the symbol version of an HMD error. */
const char *VR_GetVRInitErrorAsSymbol( EVRInitError error ) const char *VR_GetVRInitErrorAsSymbol( EVRInitError error )
{ {
std::lock_guard<std::recursive_mutex> lock( g_mutexSystem );
if( g_pHmdSystem ) if( g_pHmdSystem )
return g_pHmdSystem->GetIDForVRInitError( error ); return g_pHmdSystem->GetIDForVRInitError( error );
else else
...@@ -265,6 +331,8 @@ const char *VR_GetVRInitErrorAsSymbol( EVRInitError error ) ...@@ -265,6 +331,8 @@ const char *VR_GetVRInitErrorAsSymbol( EVRInitError error )
/** Returns the english string version of an HMD error. */ /** Returns the english string version of an HMD error. */
const char *VR_GetVRInitErrorAsEnglishDescription( EVRInitError error ) const char *VR_GetVRInitErrorAsEnglishDescription( EVRInitError error )
{ {
std::lock_guard<std::recursive_mutex> lock( g_mutexSystem );
if ( g_pHmdSystem ) if ( g_pHmdSystem )
return g_pHmdSystem->GetEnglishStringForHmdError( error ); return g_pHmdSystem->GetEnglishStringForHmdError( error );
else else
......
//========= Copyright Valve Corporation ============// //========= Copyright Valve Corporation ============//
#include "envvartools_public.h" #include "envvartools_public.h"
#include "strtools_public.h"
#include <stdlib.h> #include <stdlib.h>
#include <string>
#include <cctype>
#if defined(_WIN32) #if defined(_WIN32)
#include <Windows.h> #include <windows.h>
#undef GetEnvironmentVariable #undef GetEnvironmentVariable
#undef SetEnvironmentVariable #undef SetEnvironmentVariable
...@@ -30,6 +33,45 @@ std::string GetEnvironmentVariable( const char *pchVarName ) ...@@ -30,6 +33,45 @@ std::string GetEnvironmentVariable( const char *pchVarName )
#endif #endif
} }
bool GetEnvironmentVariableAsBool( const char *pchVarName, bool bDefault )
{
std::string sValue = GetEnvironmentVariable( pchVarName );
if ( sValue.empty() )
{
return bDefault;
}
sValue = StringToLower( sValue );
std::string sYesValues[] = { "y", "yes", "true" };
std::string sNoValues[] = { "n", "no", "false" };
for ( std::string &sMatch : sYesValues )
{
if ( sMatch == sValue )
{
return true;
}
}
for ( std::string &sMatch : sNoValues )
{
if ( sMatch == sValue )
{
return false;
}
}
if ( std::isdigit( sValue.at(0) ) )
{
return atoi( sValue.c_str() ) != 0;
}
fprintf( stderr,
"GetEnvironmentVariableAsBool(%s): Unable to parse value '%s', using default %d\n",
pchVarName, sValue.c_str(), bDefault );
return bDefault;
}
bool SetEnvironmentVariable( const char *pchVarName, const char *pchVarValue ) bool SetEnvironmentVariable( const char *pchVarName, const char *pchVarValue )
{ {
......
...@@ -4,4 +4,5 @@ ...@@ -4,4 +4,5 @@
#include <string> #include <string>
std::string GetEnvironmentVariable( const char *pchVarName ); std::string GetEnvironmentVariable( const char *pchVarName );
bool GetEnvironmentVariableAsBool( const char *pchVarName, bool bDefault );
bool SetEnvironmentVariable( const char *pchVarName, const char *pchVarValue ); bool SetEnvironmentVariable( const char *pchVarName, const char *pchVarValue );
...@@ -3,19 +3,23 @@ ...@@ -3,19 +3,23 @@
#include "pathtools_public.h" #include "pathtools_public.h"
#if defined( _WIN32) #if defined( _WIN32)
#include <Windows.h> #include <windows.h>
#include <direct.h> #include <direct.h>
#include <Shobjidl.h> #include <shobjidl.h>
#include <KnownFolders.h> #include <knownfolders.h>
#include <Shlobj.h> #include <shlobj.h>
#include <share.h>
#undef GetEnvironmentVariable #undef GetEnvironmentVariable
#define alloca _alloca
#else #else
#include <dlfcn.h> #include <dlfcn.h>
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
#include <stdlib.h> #include <stdlib.h>
#include <alloca.h>
#endif #endif
#if defined OSX #if defined OSX
#include <Foundation/Foundation.h> #include <Foundation/Foundation.h>
#include <AppKit/AppKit.h> #include <AppKit/AppKit.h>
...@@ -96,6 +100,24 @@ bool Path_SetWorkingDirectory( const std::string & sPath ) ...@@ -96,6 +100,24 @@ bool Path_SetWorkingDirectory( const std::string & sPath )
return bSuccess; return bSuccess;
} }
/** Gets the path to a temporary directory. */
std::string Path_GetTemporaryDirectory()
{
#if defined( _WIN32 )
wchar_t buf[MAX_UNICODE_PATH];
if ( GetTempPathW( MAX_UNICODE_PATH, buf ) == 0 )
return Path_GetWorkingDirectory();
return UTF16to8( buf );
#else
const char *pchTmpDir = getenv( "TMPDIR" );
if ( pchTmpDir == NULL )
{
return "";
}
return pchTmpDir;
#endif
}
/** Returns the specified path without its filename */ /** Returns the specified path without its filename */
std::string Path_StripFilename( const std::string & sPath, char slash ) std::string Path_StripFilename( const std::string & sPath, char slash )
{ {
...@@ -122,7 +144,7 @@ std::string Path_StripDirectory( const std::string & sPath, char slash ) ...@@ -122,7 +144,7 @@ std::string Path_StripDirectory( const std::string & sPath, char slash )
return std::string( sPath.begin() + n + 1, sPath.end() ); return std::string( sPath.begin() + n + 1, sPath.end() );
} }
/** returns just the filename with no extension of the provided filename. /** returns just the filename with no extension of the provided filename.
* If there is a path the path is left intact. */ * If there is a path the path is left intact. */
std::string Path_StripExtension( const std::string & sPath ) std::string Path_StripExtension( const std::string & sPath )
{ {
...@@ -187,19 +209,16 @@ bool Path_IsAbsolute( const std::string & sPath ) ...@@ -187,19 +209,16 @@ bool Path_IsAbsolute( const std::string & sPath )
/** Makes an absolute path from a relative path and a base path */ /** Makes an absolute path from a relative path and a base path */
std::string Path_MakeAbsolute( const std::string & sRelativePath, const std::string & sBasePath, char slash ) std::string Path_MakeAbsolute( const std::string & sRelativePath, const std::string & sBasePath )
{ {
if( slash == 0 )
slash = Path_GetSlash();
if( Path_IsAbsolute( sRelativePath ) ) if( Path_IsAbsolute( sRelativePath ) )
return sRelativePath; return Path_Compact( sRelativePath );
else else
{ {
if( !Path_IsAbsolute( sBasePath ) ) if( !Path_IsAbsolute( sBasePath ) )
return ""; return "";
std::string sCompacted = Path_Compact( Path_Join( sBasePath, sRelativePath, slash ), slash ); std::string sCompacted = Path_Compact( Path_Join( sBasePath, sRelativePath ) );
if( Path_IsAbsolute( sCompacted ) ) if( Path_IsAbsolute( sCompacted ) )
return sCompacted; return sCompacted;
else else
...@@ -267,12 +286,12 @@ std::string Path_Join( const std::string & first, const std::string & second, co ...@@ -267,12 +286,12 @@ std::string Path_Join( const std::string & first, const std::string & second, co
return Path_Join( Path_Join( Path_Join( first, second, slash ), third, slash ), fourth, slash ); return Path_Join( Path_Join( Path_Join( first, second, slash ), third, slash ), fourth, slash );
} }
std::string Path_Join( std::string Path_Join(
const std::string & first, const std::string & first,
const std::string & second, const std::string & second,
const std::string & third, const std::string & third,
const std::string & fourth, const std::string & fourth,
const std::string & fifth, const std::string & fifth,
char slash ) char slash )
{ {
return Path_Join( Path_Join( Path_Join( Path_Join( first, second, slash ), third, slash ), fourth, slash ), fifth, slash ); return Path_Join( Path_Join( Path_Join( Path_Join( first, second, slash ), third, slash ), fourth, slash ), fifth, slash );
...@@ -303,17 +322,17 @@ std::string Path_RemoveTrailingSlash( const std::string & sRawPath, char slash ) ...@@ -303,17 +322,17 @@ std::string Path_RemoveTrailingSlash( const std::string & sRawPath, char slash )
break; break;
} }
} }
if ( nLastFound >= 0 ) if ( nLastFound >= 0 )
{ {
sPath.erase( nLastFound, std::string::npos ); sPath.erase( nLastFound, std::string::npos );
} }
return sPath; return sPath;
} }
/** Removes redundant <dir>/.. elements in the path. Returns an empty path if the /** Removes redundant <dir>/.. elements in the path. Returns an empty path if the
* specified path has a broken number of directories for its number of ..s */ * specified path has a broken number of directories for its number of ..s */
std::string Path_Compact( const std::string & sRawPath, char slash ) std::string Path_Compact( const std::string & sRawPath, char slash )
{ {
...@@ -348,7 +367,7 @@ std::string Path_Compact( const std::string & sRawPath, char slash ) ...@@ -348,7 +367,7 @@ std::string Path_Compact( const std::string & sRawPath, char slash )
} }
} }
// get rid of leading ./ // get rid of leading ./
if( sPath.length() > 2 ) if( sPath.length() > 2 )
{ {
if( sPath[ 0 ] == '.' && sPath[ 1 ] == slash ) if( sPath[ 0 ] == '.' && sPath[ 1 ] == slash )
...@@ -362,7 +381,7 @@ std::string Path_Compact( const std::string & sRawPath, char slash ) ...@@ -362,7 +381,7 @@ std::string Path_Compact( const std::string & sRawPath, char slash )
std::string::size_type i = 0; std::string::size_type i = 0;
while( i < sPath.length() ) while( i < sPath.length() )
{ {
if( i > 0 && sPath.length() - i >= 2 if( i > 0 && sPath.length() - i >= 2
&& sPath[i] == '.' && sPath[i] == '.'
&& sPath[i+1] == '.' && sPath[i+1] == '.'
&& ( i + 2 == sPath.length() || sPath[ i+2 ] == slash ) && ( i + 2 == sPath.length() || sPath[ i+2 ] == slash )
...@@ -371,7 +390,7 @@ std::string Path_Compact( const std::string & sRawPath, char slash ) ...@@ -371,7 +390,7 @@ std::string Path_Compact( const std::string & sRawPath, char slash )
// check if we've hit the start of the string and have a bogus path // check if we've hit the start of the string and have a bogus path
if( i == 1 ) if( i == 1 )
return ""; return "";
// find the separator before i-1 // find the separator before i-1
std::string::size_type iDirStart = i-2; std::string::size_type iDirStart = i-2;
while( iDirStart > 0 && sPath[ iDirStart - 1 ] != slash ) while( iDirStart > 0 && sPath[ iDirStart - 1 ] != slash )
...@@ -393,6 +412,20 @@ std::string Path_Compact( const std::string & sRawPath, char slash ) ...@@ -393,6 +412,20 @@ std::string Path_Compact( const std::string & sRawPath, char slash )
} }
/** Returns true if these two paths are the same without respect for internal . or ..
* sequences, slash type, or case (on case-insensitive platforms). */
bool Path_IsSamePath( const std::string & sPath1, const std::string & sPath2 )
{
std::string sCompact1 = Path_Compact( sPath1 );
std::string sCompact2 = Path_Compact( sPath2 );
#if defined(WIN32)
return !stricmp( sCompact1.c_str(), sCompact2.c_str() );
#else
return !strcmp( sCompact1.c_str(), sCompact2.c_str() );
#endif
}
/** Returns the path to the current DLL or exe */ /** Returns the path to the current DLL or exe */
std::string Path_GetThisModulePath() std::string Path_GetThisModulePath()
{ {
...@@ -463,10 +496,11 @@ bool Path_IsDirectory( const std::string & sPath ) ...@@ -463,10 +496,11 @@ bool Path_IsDirectory( const std::string & sPath )
bool Path_IsAppBundle( const std::string & sPath ) bool Path_IsAppBundle( const std::string & sPath )
{ {
#if defined(OSX) #if defined(OSX)
NSBundle *bundle = [ NSBundle bundleWithPath: [ NSString stringWithUTF8String:sPath.c_str() ] ]; @autoreleasepool {
bool bisAppBundle = ( nullptr != bundle ); NSBundle *bundle = [ NSBundle bundleWithPath: [ NSString stringWithUTF8String:sPath.c_str() ] ];
[ bundle release ]; bool bisAppBundle = ( nullptr != bundle );
return bisAppBundle; return bisAppBundle;
}
#else #else
return false; return false;
#endif #endif
...@@ -567,7 +601,7 @@ unsigned char * Path_ReadBinaryFile( const std::string &strFilename, int *pSize ...@@ -567,7 +601,7 @@ unsigned char * Path_ReadBinaryFile( const std::string &strFilename, int *pSize
// the open operation needs to be sharable, therefore use of _wfsopen instead of _wfopen_s // the open operation needs to be sharable, therefore use of _wfsopen instead of _wfopen_s
f = _wfsopen( wstrFilename.c_str(), L"rb", _SH_DENYNO ); f = _wfsopen( wstrFilename.c_str(), L"rb", _SH_DENYNO );
#endif #endif
unsigned char* buf = NULL; unsigned char* buf = NULL;
if ( f != NULL ) if ( f != NULL )
...@@ -654,7 +688,7 @@ bool Path_WriteBinaryFile(const std::string &strFilename, unsigned char *pData, ...@@ -654,7 +688,7 @@ bool Path_WriteBinaryFile(const std::string &strFilename, unsigned char *pData,
fclose(f); fclose(f);
} }
return written = nSize ? true : false; return written == nSize ? true : false;
} }
std::string Path_ReadTextFile( const std::string &strFilename ) std::string Path_ReadTextFile( const std::string &strFilename )
...@@ -683,6 +717,28 @@ std::string Path_ReadTextFile( const std::string &strFilename ) ...@@ -683,6 +717,28 @@ std::string Path_ReadTextFile( const std::string &strFilename )
} }
bool Path_MakeWritable( const std::string &strFilename )
{
#if defined ( _WIN32 )
std::wstring wstrFilename = UTF8to16( strFilename.c_str() );
DWORD dwAttrs = GetFileAttributesW( wstrFilename.c_str() );
if ( dwAttrs != INVALID_FILE_ATTRIBUTES && ( dwAttrs & FILE_ATTRIBUTE_READONLY ) )
{
return SetFileAttributesW( wstrFilename.c_str(), dwAttrs & ~FILE_ATTRIBUTE_READONLY );
}
#else
struct stat sb;
if ( stat( strFilename.c_str(), &sb ) == 0 && !( sb.st_mode & S_IWUSR ) )
{
return ( chmod( strFilename.c_str(), sb.st_mode | S_IWUSR ) == 0 );
}
#endif
return true;
}
bool Path_WriteStringToTextFile( const std::string &strFilename, const char *pchData ) bool Path_WriteStringToTextFile( const std::string &strFilename, const char *pchData )
{ {
FILE *f; FILE *f;
...@@ -696,7 +752,7 @@ bool Path_WriteStringToTextFile( const std::string &strFilename, const char *pch ...@@ -696,7 +752,7 @@ bool Path_WriteStringToTextFile( const std::string &strFilename, const char *pch
f = NULL; f = NULL;
} }
#endif #endif
bool ok = false; bool ok = false;
if ( f != NULL ) if ( f != NULL )
...@@ -747,9 +803,11 @@ bool Path_WriteStringToTextFileAtomic( const std::string &strFilename, const cha ...@@ -747,9 +803,11 @@ bool Path_WriteStringToTextFileAtomic( const std::string &strFilename, const cha
// ---------------------------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------------------------
std::string Path_FilePathToUrl( const std::string & sRelativePath, const std::string & sBasePath ) std::string Path_FilePathToUrl( const std::string & sRelativePath, const std::string & sBasePath )
{ {
if ( !strnicmp( sRelativePath.c_str(), "http://", 7 ) if ( StringHasPrefix( sRelativePath, "http://" )
|| !strnicmp( sRelativePath.c_str(), "https://", 8 ) || StringHasPrefix( sRelativePath, "https://" )
|| !strnicmp( sRelativePath.c_str(), "file://", 7 ) ) || StringHasPrefix( sRelativePath, "vr-input-workshop://" )
|| StringHasPrefix( sRelativePath, "file://" )
)
{ {
return sRelativePath; return sRelativePath;
} }
...@@ -758,7 +816,13 @@ std::string Path_FilePathToUrl( const std::string & sRelativePath, const std::st ...@@ -758,7 +816,13 @@ std::string Path_FilePathToUrl( const std::string & sRelativePath, const std::st
std::string sAbsolute = Path_MakeAbsolute( sRelativePath, sBasePath ); std::string sAbsolute = Path_MakeAbsolute( sRelativePath, sBasePath );
if ( sAbsolute.empty() ) if ( sAbsolute.empty() )
return sAbsolute; return sAbsolute;
return std::string( FILE_URL_PREFIX ) + sAbsolute; sAbsolute = Path_FixSlashes( sAbsolute, '/' );
size_t unBufferSize = sAbsolute.length() * 3;
char *pchBuffer = (char *)alloca( unBufferSize );
V_URLEncodeNoPlusForSpace( pchBuffer, (int)unBufferSize, sAbsolute.c_str(), (int)sAbsolute.length() );
return std::string( FILE_URL_PREFIX ) + pchBuffer;
} }
} }
...@@ -769,7 +833,11 @@ std::string Path_UrlToFilePath( const std::string & sFileUrl ) ...@@ -769,7 +833,11 @@ std::string Path_UrlToFilePath( const std::string & sFileUrl )
{ {
if ( !strnicmp( sFileUrl.c_str(), FILE_URL_PREFIX, strlen( FILE_URL_PREFIX ) ) ) if ( !strnicmp( sFileUrl.c_str(), FILE_URL_PREFIX, strlen( FILE_URL_PREFIX ) ) )
{ {
return sFileUrl.c_str() + strlen( FILE_URL_PREFIX ); char *pchBuffer = (char *)alloca( sFileUrl.length() );
V_URLDecodeNoPlusForSpace( pchBuffer, (int)sFileUrl.length(),
sFileUrl.c_str() + strlen( FILE_URL_PREFIX ), (int)( sFileUrl.length() - strlen( FILE_URL_PREFIX ) ) );
return Path_FixSlashes( pchBuffer );
} }
else else
{ {
...@@ -802,7 +870,7 @@ std::string GetUserDocumentsPath() ...@@ -802,7 +870,7 @@ std::string GetUserDocumentsPath()
{ {
return ""; return "";
} }
return [[paths objectAtIndex:0] UTF8String]; return [[paths objectAtIndex:0] UTF8String];
} }
#elif defined( LINUX ) #elif defined( LINUX )
...@@ -816,3 +884,16 @@ std::string GetUserDocumentsPath() ...@@ -816,3 +884,16 @@ std::string GetUserDocumentsPath()
#endif #endif
} }
// -----------------------------------------------------------------------------------------------------
// Purpose: deletes / unlinks a single file
// -----------------------------------------------------------------------------------------------------
bool Path_UnlinkFile( const std::string &strFilename )
{
#if defined( WIN32 )
std::wstring wsFilename = UTF8to16( strFilename.c_str() );
return ( 0 != DeleteFileW( wsFilename.c_str() ) );
#else
return ( 0 == unlink( strFilename.c_str() ) );
#endif
}
...@@ -13,6 +13,9 @@ std::string Path_GetWorkingDirectory(); ...@@ -13,6 +13,9 @@ std::string Path_GetWorkingDirectory();
/** Sets the path of the current working directory. Returns true if this was successful. */ /** Sets the path of the current working directory. Returns true if this was successful. */
bool Path_SetWorkingDirectory( const std::string & sPath ); bool Path_SetWorkingDirectory( const std::string & sPath );
/** Gets the path to a temporary directory. */
std::string Path_GetTemporaryDirectory();
/** returns the path (including filename) of the current shared lib or DLL */ /** returns the path (including filename) of the current shared lib or DLL */
std::string Path_GetThisModulePath(); std::string Path_GetThisModulePath();
...@@ -35,7 +38,7 @@ std::string Path_GetExtension( const std::string & sPath ); ...@@ -35,7 +38,7 @@ std::string Path_GetExtension( const std::string & sPath );
bool Path_IsAbsolute( const std::string & sPath ); bool Path_IsAbsolute( const std::string & sPath );
/** Makes an absolute path from a relative path and a base path */ /** Makes an absolute path from a relative path and a base path */
std::string Path_MakeAbsolute( const std::string & sRelativePath, const std::string & sBasePath, char slash = 0 ); std::string Path_MakeAbsolute( const std::string & sRelativePath, const std::string & sBasePath );
/** Fixes the directory separators for the current platform. /** Fixes the directory separators for the current platform.
* If slash is unspecified the native path separator of the current platform * If slash is unspecified the native path separator of the current platform
...@@ -64,6 +67,10 @@ std::string Path_Join( ...@@ -64,6 +67,10 @@ std::string Path_Join(
* will be used. */ * will be used. */
std::string Path_Compact( const std::string & sRawPath, char slash = 0 ); std::string Path_Compact( const std::string & sRawPath, char slash = 0 );
/** Returns true if these two paths are the same without respect for internal . or ..
* sequences, slash type, or case (on case-insensitive platforms). */
bool Path_IsSamePath( const std::string & sPath1, const std::string & sPath2 );
//** Removed trailing slashes */ //** Removed trailing slashes */
std::string Path_RemoveTrailingSlash( const std::string & sRawPath, char slash = 0 ); std::string Path_RemoveTrailingSlash( const std::string & sRawPath, char slash = 0 );
...@@ -80,6 +87,9 @@ bool Path_Exists( const std::string & sPath ); ...@@ -80,6 +87,9 @@ bool Path_Exists( const std::string & sPath );
std::string Path_FindParentDirectoryRecursively( const std::string &strStartDirectory, const std::string &strDirectoryName ); std::string Path_FindParentDirectoryRecursively( const std::string &strStartDirectory, const std::string &strDirectoryName );
std::string Path_FindParentSubDirectoryRecursively( const std::string &strStartDirectory, const std::string &strDirectoryName ); std::string Path_FindParentSubDirectoryRecursively( const std::string &strStartDirectory, const std::string &strDirectoryName );
/** Make a text file writable. */
bool Path_MakeWritable( const std::string &strFilename );
/** Path operations to read or write text/binary files */ /** Path operations to read or write text/binary files */
unsigned char * Path_ReadBinaryFile( const std::string &strFilename, int *pSize ); unsigned char * Path_ReadBinaryFile( const std::string &strFilename, int *pSize );
uint32_t Path_ReadBinaryFile( const std::string &strFilename, unsigned char *pBuffer, uint32_t unSize ); uint32_t Path_ReadBinaryFile( const std::string &strFilename, unsigned char *pBuffer, uint32_t unSize );
...@@ -97,6 +107,9 @@ std::string Path_UrlToFilePath( const std::string & sFileUrl ); ...@@ -97,6 +107,9 @@ std::string Path_UrlToFilePath( const std::string & sFileUrl );
/** Returns the root of the directory the system wants us to store user documents in */ /** Returns the root of the directory the system wants us to store user documents in */
std::string GetUserDocumentsPath(); std::string GetUserDocumentsPath();
/** deletes / unlinks a single file */
bool Path_UnlinkFile( const std::string &strFilename );
#ifndef MAX_UNICODE_PATH #ifndef MAX_UNICODE_PATH
#define MAX_UNICODE_PATH 32767 #define MAX_UNICODE_PATH 32767
#endif #endif
...@@ -108,6 +121,7 @@ std::string GetUserDocumentsPath(); ...@@ -108,6 +121,7 @@ std::string GetUserDocumentsPath();
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#if defined(WIN32) #if defined(WIN32)
#define DYNAMIC_LIB_EXT ".dll" #define DYNAMIC_LIB_EXT ".dll"
#define PROGRAM_EXT ".exe"
#ifdef _WIN64 #ifdef _WIN64
#define PLATSUBDIR "win64" #define PLATSUBDIR "win64"
#else #else
...@@ -116,10 +130,16 @@ std::string GetUserDocumentsPath(); ...@@ -116,10 +130,16 @@ std::string GetUserDocumentsPath();
#elif defined(OSX) #elif defined(OSX)
#define DYNAMIC_LIB_EXT ".dylib" #define DYNAMIC_LIB_EXT ".dylib"
#define PLATSUBDIR "osx32" #define PLATSUBDIR "osx32"
#define PROGRAM_EXT ""
#elif defined(LINUX) #elif defined(LINUX)
#define DYNAMIC_LIB_EXT ".so" #define DYNAMIC_LIB_EXT ".so"
#define PROGRAM_EXT ""
#if defined( LINUX32 ) #if defined( LINUX32 )
#define PLATSUBDIR "linux32" #define PLATSUBDIR "linux32"
#elif defined( ANDROIDARM64 )
#define PLATSUBDIR "androidarm64"
#elif defined( LINUXARM64 )
#define PLATSUBDIR "linuxarm64"
#else #else
#define PLATSUBDIR "linux64" #define PLATSUBDIR "linux64"
#endif #endif
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
#include <string.h> #include <string.h>
#if defined(_WIN32) #if defined(_WIN32)
#include <Windows.h> #include <windows.h>
#endif #endif
#if defined(POSIX) #if defined(POSIX)
...@@ -31,6 +31,8 @@ void *SharedLib_GetFunction( SharedLibHandle lib, const char *pchFunctionName) ...@@ -31,6 +31,8 @@ void *SharedLib_GetFunction( SharedLibHandle lib, const char *pchFunctionName)
void SharedLib_Unload( SharedLibHandle lib ) void SharedLib_Unload( SharedLibHandle lib )
{ {
if ( !lib )
return;
#if defined( _WIN32) #if defined( _WIN32)
FreeLibrary( (HMODULE)lib ); FreeLibrary( (HMODULE)lib );
#elif defined(POSIX) #elif defined(POSIX)
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <sstream>
#include <iostream>
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: // Purpose:
...@@ -142,8 +144,8 @@ std::wstring UTF8to16(const char * in) ...@@ -142,8 +144,8 @@ std::wstring UTF8to16(const char * in)
void strcpy_safe( char *pchBuffer, size_t unBufferSizeBytes, const char *pchSource ) void strcpy_safe( char *pchBuffer, size_t unBufferSizeBytes, const char *pchSource )
{ {
pchBuffer[ unBufferSizeBytes - 1 ] = '\0';
strncpy( pchBuffer, pchSource, unBufferSizeBytes - 1 ); strncpy( pchBuffer, pchSource, unBufferSizeBytes - 1 );
pchBuffer[unBufferSizeBytes - 1] = '\0';
} }
...@@ -197,12 +199,6 @@ uint32_t ReturnStdString( const std::string & sValue, char *pchBuffer, uint32_t ...@@ -197,12 +199,6 @@ uint32_t ReturnStdString( const std::string & sValue, char *pchBuffer, uint32_t
return unLen; return unLen;
} }
void BufferToStdString( std::string & sDest, const char *pchBuffer, uint32_t unBufferLen )
{
sDest.resize( unBufferLen + 1 );
memcpy( const_cast< char* >( sDest.c_str() ), pchBuffer, unBufferLen );
const_cast< char* >( sDest.c_str() )[ unBufferLen ] = '\0';
}
/** Returns a std::string from a uint64_t */ /** Returns a std::string from a uint64_t */
std::string Uint64ToString( uint64_t ulValue ) std::string Uint64ToString( uint64_t ulValue )
...@@ -405,6 +401,12 @@ void V_URLEncode( char *pchDest, int nDestLen, const char *pchSource, int nSourc ...@@ -405,6 +401,12 @@ void V_URLEncode( char *pchDest, int nDestLen, const char *pchSource, int nSourc
} }
void V_URLEncodeNoPlusForSpace( char *pchDest, int nDestLen, const char *pchSource, int nSourceLen )
{
return V_URLEncodeInternal( pchDest, nDestLen, pchSource, nSourceLen, false );
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: Decodes a string (or binary data) from URL encoding format, see rfc1738 section 2.2. // Purpose: Decodes a string (or binary data) from URL encoding format, see rfc1738 section 2.2.
// This version of the call isn't a strict RFC implementation, but uses + for space as is // This version of the call isn't a strict RFC implementation, but uses + for space as is
...@@ -418,6 +420,11 @@ size_t V_URLDecode( char *pchDecodeDest, int nDecodeDestLen, const char *pchEnco ...@@ -418,6 +420,11 @@ size_t V_URLDecode( char *pchDecodeDest, int nDecodeDestLen, const char *pchEnco
return V_URLDecodeInternal( pchDecodeDest, nDecodeDestLen, pchEncodedSource, nEncodedSourceLen, true ); return V_URLDecodeInternal( pchDecodeDest, nDecodeDestLen, pchEncodedSource, nEncodedSourceLen, true );
} }
size_t V_URLDecodeNoPlusForSpace( char *pchDecodeDest, int nDecodeDestLen, const char *pchEncodedSource, int nEncodedSourceLen )
{
return V_URLDecodeInternal( pchDecodeDest, nDecodeDestLen, pchEncodedSource, nEncodedSourceLen, false );
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void V_StripExtension( std::string &in ) void V_StripExtension( std::string &in )
{ {
...@@ -435,3 +442,19 @@ void V_StripExtension( std::string &in ) ...@@ -435,3 +442,19 @@ void V_StripExtension( std::string &in )
} }
} }
//-----------------------------------------------------------------------------
// Purpose: Tokenizes a string into a vector of strings
//-----------------------------------------------------------------------------
std::vector<std::string> TokenizeString( const std::string & sString, char cToken )
{
std::vector<std::string> vecStrings;
std::istringstream stream( sString );
std::string s;
while ( std::getline( stream, s, cToken ) )
{
vecStrings.push_back( s );
}
return vecStrings;
}
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include <string> #include <string>
#include <stdint.h> #include <stdint.h>
#include <sys/types.h> #include <sys/types.h>
#include <vector>
/** returns true if the string has the prefix */ /** returns true if the string has the prefix */
bool StringHasPrefix( const std::string & sString, const std::string & sPrefix ); bool StringHasPrefix( const std::string & sString, const std::string & sPrefix );
...@@ -39,11 +40,17 @@ std::string StringToLower( const std::string & sString ); ...@@ -39,11 +40,17 @@ std::string StringToLower( const std::string & sString );
#if defined( OSX ) || defined( LINUX ) #if defined( OSX ) || defined( LINUX )
#include <strings.h> #include <strings.h>
inline int stricmp(const char *pStr1, const char *pStr2) { return strcasecmp(pStr1,pStr2); } inline int stricmp(const char *pStr1, const char *pStr2) { return strcasecmp(pStr1,pStr2); }
#ifndef _stricmp
#define _stricmp stricmp #define _stricmp stricmp
#endif
inline int strnicmp( const char *pStr1, const char *pStr2, size_t unBufferLen ) { return strncasecmp( pStr1,pStr2, unBufferLen ); } inline int strnicmp( const char *pStr1, const char *pStr2, size_t unBufferLen ) { return strncasecmp( pStr1,pStr2, unBufferLen ); }
#ifndef _strnicmp
#define _strnicmp strnicmp #define _strnicmp strnicmp
#endif
#ifndef _vsnprintf_s
#define _vsnprintf_s vsnprintf #define _vsnprintf_s vsnprintf
#endif
#define _TRUNCATE ((size_t)-1) #define _TRUNCATE ((size_t)-1)
...@@ -90,9 +97,6 @@ inline uint64_t strtoull(const char *str, char **endptr, int base) { return _str ...@@ -90,9 +97,6 @@ inline uint64_t strtoull(const char *str, char **endptr, int base) { return _str
/* Handles copying a std::string into a buffer as would be provided in an API */ /* Handles copying a std::string into a buffer as would be provided in an API */
uint32_t ReturnStdString( const std::string & sValue, char *pchBuffer, uint32_t unBufferLen ); uint32_t ReturnStdString( const std::string & sValue, char *pchBuffer, uint32_t unBufferLen );
/* Handles copying a buffer into an std::string and auto adds null terminator */
void BufferToStdString( std::string & sDest, const char *pchBuffer, uint32_t unBufferLen );
/** Returns a std::string from a uint64_t */ /** Returns a std::string from a uint64_t */
std::string Uint64ToString( uint64_t ulValue ); std::string Uint64ToString( uint64_t ulValue );
...@@ -108,6 +112,9 @@ uint64_t StringToUint64( const std::string & sValue ); ...@@ -108,6 +112,9 @@ uint64_t StringToUint64( const std::string & sValue );
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void V_URLEncode( char *pchDest, int nDestLen, const char *pchSource, int nSourceLen ); void V_URLEncode( char *pchDest, int nDestLen, const char *pchSource, int nSourceLen );
/** Same as V_URLEncode, but without plus for space. */
void V_URLEncodeNoPlusForSpace( char *pchDest, int nDestLen, const char *pchSource, int nSourceLen );
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: Decodes a string (or binary data) from URL encoding format, see rfc1738 section 2.2. // Purpose: Decodes a string (or binary data) from URL encoding format, see rfc1738 section 2.2.
// This version of the call isn't a strict RFC implementation, but uses + for space as is // This version of the call isn't a strict RFC implementation, but uses + for space as is
...@@ -118,9 +125,14 @@ void V_URLEncode( char *pchDest, int nDestLen, const char *pchSource, int nSourc ...@@ -118,9 +125,14 @@ void V_URLEncode( char *pchDest, int nDestLen, const char *pchSource, int nSourc
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
size_t V_URLDecode( char *pchDecodeDest, int nDecodeDestLen, const char *pchEncodedSource, int nEncodedSourceLen ); size_t V_URLDecode( char *pchDecodeDest, int nDecodeDestLen, const char *pchEncodedSource, int nEncodedSourceLen );
/** Same as V_URLDecode, but without plus for space. */
size_t V_URLDecodeNoPlusForSpace( char *pchDecodeDest, int nDecodeDestLen, const char *pchEncodedSource, int nEncodedSourceLen );
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: strip extension from a path // Purpose: strip extension from a path
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void V_StripExtension( std::string &in ); void V_StripExtension( std::string &in );
/** Tokenizes a string into a vector of strings */
std::vector<std::string> TokenizeString( const std::string & sString, char cToken );
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#if defined( WIN32 ) #if defined( WIN32 )
#include <windows.h> #include <windows.h>
#include <Shlobj.h> #include <shlobj.h>
#undef GetEnvironmentVariable #undef GetEnvironmentVariable
#elif defined OSX #elif defined OSX
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include <algorithm> #include <algorithm>
#ifndef VRLog #ifndef VRLog
#undef VRLog #undef VRLog
#endif #endif
#define VRLog(...) #define VRLog(...)
...@@ -52,21 +52,21 @@ static std::string GetAppSettingsPath() ...@@ -52,21 +52,21 @@ static std::string GetAppSettingsPath()
{ {
return ""; return "";
} }
NSString *resolvedPath = [paths objectAtIndex:0]; NSString *resolvedPath = [paths objectAtIndex:0];
resolvedPath = [resolvedPath stringByAppendingPathComponent: @"OpenVR"]; resolvedPath = [resolvedPath stringByAppendingPathComponent: @"OpenVR"];
if ( ![[NSFileManager new] createDirectoryAtPath: resolvedPath withIntermediateDirectories:YES attributes:nil error:nil] ) if ( ![[NSFileManager defaultManager] createDirectoryAtPath: resolvedPath withIntermediateDirectories:YES attributes:nil error:nil] )
{ {
return ""; return "";
} }
sSettingsDir.assign( [resolvedPath UTF8String] ); sSettingsDir.assign( [resolvedPath UTF8String] );
} }
return sSettingsDir; return sSettingsDir;
#elif defined( LINUX ) #elif defined( LINUX )
// As defined by XDG Base Directory Specification // As defined by XDG Base Directory Specification
// https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html // https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
const char *pchHome = getenv("XDG_CONFIG_HOME"); const char *pchHome = getenv("XDG_CONFIG_HOME");
...@@ -77,7 +77,7 @@ static std::string GetAppSettingsPath() ...@@ -77,7 +77,7 @@ static std::string GetAppSettingsPath()
// //
// XDG_CONFIG_HOME is not defined, use ~/.config instead // XDG_CONFIG_HOME is not defined, use ~/.config instead
// //
pchHome = getenv( "HOME" ); pchHome = getenv( "HOME" );
if ( pchHome == NULL ) if ( pchHome == NULL )
{ {
...@@ -112,7 +112,7 @@ std::string CVRPathRegistry_Public::GetOpenVRConfigPath() ...@@ -112,7 +112,7 @@ std::string CVRPathRegistry_Public::GetOpenVRConfigPath()
#if defined( _WIN32 ) || defined( LINUX ) #if defined( _WIN32 ) || defined( LINUX )
sConfigPath = Path_Join( sConfigPath, "openvr" ); sConfigPath = Path_Join( sConfigPath, "openvr" );
#elif defined ( OSX ) #elif defined ( OSX )
sConfigPath = Path_Join( sConfigPath, ".openvr" ); sConfigPath = Path_Join( sConfigPath, ".openvr" );
#else #else
#warning "Unsupported platform" #warning "Unsupported platform"
...@@ -128,13 +128,17 @@ std::string CVRPathRegistry_Public::GetOpenVRConfigPath() ...@@ -128,13 +128,17 @@ std::string CVRPathRegistry_Public::GetOpenVRConfigPath()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
std::string CVRPathRegistry_Public::GetVRPathRegistryFilename() std::string CVRPathRegistry_Public::GetVRPathRegistryFilename()
{ {
std::string sOverridePath = GetEnvironmentVariable( "VR_PATHREG_OVERRIDE" );
if ( !sOverridePath.empty() )
return sOverridePath;
std::string sPath = GetOpenVRConfigPath(); std::string sPath = GetOpenVRConfigPath();
if ( sPath.empty() ) if ( sPath.empty() )
return ""; return "";
#if defined( _WIN32 ) #if defined( _WIN32 )
sPath = Path_Join( sPath, "openvrpaths.vrpath" ); sPath = Path_Join( sPath, "openvrpaths.vrpath" );
#elif defined ( POSIX ) #elif defined ( POSIX )
sPath = Path_Join( sPath, "openvrpaths.vrpath" ); sPath = Path_Join( sPath, "openvrpaths.vrpath" );
#else #else
#error "Unsupported platform" #error "Unsupported platform"
...@@ -190,7 +194,7 @@ bool CVRPathRegistry_Public::ToJsonString( std::string &sJsonString ) ...@@ -190,7 +194,7 @@ bool CVRPathRegistry_Public::ToJsonString( std::string &sJsonString )
std::string sRegPath = GetVRPathRegistryFilename(); std::string sRegPath = GetVRPathRegistryFilename();
if( sRegPath.empty() ) if( sRegPath.empty() )
return false; return false;
std::string sRegistryContents = Path_ReadTextFile( sRegPath ); std::string sRegistryContents = Path_ReadTextFile( sRegPath );
if( sRegistryContents.empty() ) if( sRegistryContents.empty() )
return false; return false;
...@@ -223,19 +227,30 @@ bool CVRPathRegistry_Public::BLoadFromFile() ...@@ -223,19 +227,30 @@ bool CVRPathRegistry_Public::BLoadFromFile()
Json::Value root; Json::Value root;
Json::Reader reader; Json::Reader reader;
if( !reader.parse( sRegistryContents, root ) ) #if JSON_USE_EXCEPTION
{ try {
VRLog( "Unable to parse %s: %s\n", sRegPath.c_str(), reader.getFormattedErrorMessages().c_str() ); #endif // JSON_USE_EXCEPTION
return false; if ( !reader.parse( sRegistryContents, root ) )
} {
VRLog( "Unable to parse %s: %s\n", sRegPath.c_str(), reader.getFormattedErrorMessages().c_str() );
return false;
}
ParseStringListFromJson( &m_vecRuntimePath, root, "runtime" ); ParseStringListFromJson( &m_vecRuntimePath, root, "runtime" );
ParseStringListFromJson( &m_vecConfigPath, root, "config" ); ParseStringListFromJson( &m_vecConfigPath, root, "config" );
ParseStringListFromJson( &m_vecLogPath, root, "log" ); ParseStringListFromJson( &m_vecLogPath, root, "log" );
if (root.isMember( "external_drivers" ) && root[ "external_drivers" ].isArray() ) if ( root.isMember( "external_drivers" ) && root["external_drivers"].isArray() )
{
ParseStringListFromJson( &m_vecExternalDrivers, root, "external_drivers" );
}
#if JSON_USE_EXCEPTION
}
catch ( ... )
{ {
ParseStringListFromJson( &m_vecExternalDrivers, root, "external_drivers" ); VRLog( "Unable to parse %s: %s\n", sRegPath.c_str(), "exception thrown in JSON library" );
return false;
} }
#endif // JSON_USE_EXCEPTION
return true; return true;
} }
...@@ -252,9 +267,9 @@ bool CVRPathRegistry_Public::BSaveToFile() const ...@@ -252,9 +267,9 @@ bool CVRPathRegistry_Public::BSaveToFile() const
std::string sRegPath = GetVRPathRegistryFilename(); std::string sRegPath = GetVRPathRegistryFilename();
if( sRegPath.empty() ) if( sRegPath.empty() )
return false; return false;
Json::Value root; Json::Value root;
root[ "version" ] = 1; root[ "version" ] = 1;
root[ "jsonid" ] = "vrpathreg"; root[ "jsonid" ] = "vrpathreg";
...@@ -323,7 +338,7 @@ std::string CVRPathRegistry_Public::GetLogPath() const ...@@ -323,7 +338,7 @@ std::string CVRPathRegistry_Public::GetLogPath() const
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Purpose: Returns paths using the path registry and the provided override // Purpose: Returns paths using the path registry and the provided override
// values. Pass NULL for any paths you don't care about. // values. Pass NULL for any paths you don't care about.
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
bool CVRPathRegistry_Public::GetPaths( std::string *psRuntimePath, std::string *psConfigPath, std::string *psLogPath, const char *pchConfigPathOverride, const char *pchLogPathOverride, std::vector<std::string> *pvecExternalDrivers ) bool CVRPathRegistry_Public::GetPaths( std::string *psRuntimePath, std::string *psConfigPath, std::string *psLogPath, const char *pchConfigPathOverride, const char *pchLogPathOverride, std::vector<std::string> *pvecExternalDrivers )
...@@ -398,7 +413,7 @@ bool CVRPathRegistry_Public::GetPaths( std::string *psRuntimePath, std::string * ...@@ -398,7 +413,7 @@ bool CVRPathRegistry_Public::GetPaths( std::string *psRuntimePath, std::string *
if ( nCountEnvironmentVariables == 3 ) if ( nCountEnvironmentVariables == 3 )
{ {
// all three environment variables where set, so we don't need the physical file // all three environment variables were set, so we don't need the physical file
return true; return true;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment