with FSFindFolder:
UInt8 path[1024]; FSRef file; FSFindFolder( kOnAppropriateDisk , kCurrentUserFolderType , kCreateFolder , &file ); FSRefMakePath( &file , path , sizeof(path) );
with CSCopyUserName:
char path[1024]; CFStringRef name = CSCopyUserName( true ); CFStringRef full = CFStringCreateWithFormat( NULL , NULL , CFSTR( "/Users/%@" ) , name ); CFStringGetCString( full , path , sizeof(path) , kCFStringEncodingUTF8 );
with NSHomeDirectory:
char path[1024]; CFStringGetCString( (CFStringRef)NSHomeDirectory() , path , sizeof(path) , kCFStringEncodingUTF8 );
note that the path may use UTF8 characters.
drawnonward
source share