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

Function GetUserDocumentsPath

samples/shared/pathtools.cpp:786–819  ·  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

784// Purpose: Returns the root of the directory the system wants us to store user documents in
785// -----------------------------------------------------------------------------------------------------
786std::string GetUserDocumentsPath()
787{
788#if defined( WIN32 )
789 WCHAR rwchPath[MAX_PATH];
790
791 if ( !SUCCEEDED( SHGetFolderPathW( NULL, CSIDL_MYDOCUMENTS | CSIDL_FLAG_CREATE, NULL, 0, rwchPath ) ) )
792 {
793 return "";
794 }
795
796 // Convert the path to UTF-8 and store in the output
797 std::string sUserPath = UTF16to8( rwchPath );
798
799 return sUserPath;
800#elif defined( OSX )
801 @autoreleasepool {
802 NSArray *paths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory, NSUserDomainMask, YES );
803 if ( [paths count] == 0 )
804 {
805 return "";
806 }
807
808 return [[paths objectAtIndex:0] UTF8String];
809 }
810#elif defined( LINUX )
811 // @todo: not solved/changed as part of OSX - still not real - just removed old class based steam cut and paste
812 const char *pchHome = getenv( "HOME" );
813 if ( pchHome == NULL )
814 {
815 return "";
816 }
817 return pchHome;
818#endif
819}
820

Callers

nothing calls this directly

Calls 1

UTF16to8Function · 0.70

Tested by

no test coverage detected