MCPcopy Create free account
hub / github.com/ValveSoftware/openvr / GetUserDocumentsPath

Function GetUserDocumentsPath

src/vrcore/pathtools_public.cpp:928–961  ·  view source on GitHub ↗

----------------------------------------------------------------------------------------------------- Purpose: Returns the root of the directory the system wants us to store user documents in -----------------------------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

926// Purpose: Returns the root of the directory the system wants us to store user documents in
927// -----------------------------------------------------------------------------------------------------
928std::string GetUserDocumentsPath()
929{
930#if defined( WIN32 )
931 WCHAR rwchPath[MAX_PATH];
932
933 if ( !SUCCEEDED( SHGetFolderPathW( NULL, CSIDL_MYDOCUMENTS | CSIDL_FLAG_CREATE, NULL, 0, rwchPath ) ) )
934 {
935 return "";
936 }
937
938 // Convert the path to UTF-8 and store in the output
939 std::string sUserPath = UTF16to8( rwchPath );
940
941 return sUserPath;
942#elif defined( OSX )
943 @autoreleasepool {
944 NSArray *paths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory, NSUserDomainMask, YES );
945 if ( [paths count] == 0 )
946 {
947 return "";
948 }
949
950 return [[paths objectAtIndex:0] UTF8String];
951 }
952#elif defined( LINUX )
953 // @todo: not solved/changed as part of OSX - still not real - just removed old class based steam cut and paste
954 const char *pchHome = getenv( "HOME" );
955 if ( pchHome == NULL )
956 {
957 return "";
958 }
959 return pchHome;
960#endif
961}
962
963
964// -----------------------------------------------------------------------------------------------------

Callers

nothing calls this directly

Calls 1

UTF16to8Function · 0.70

Tested by

no test coverage detected