MCPcopy Create free account
hub / github.com/SpartanJ/efsw / precomposeFileName

Method precomposeFileName

src/efsw/FileSystem.cpp:100–135  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

98}
99
100std::string FileSystem::precomposeFileName( const std::string& name ) {
101#if EFSW_OS == EFSW_OS_MACOSX
102 CFStringRef cfStringRef =
103 CFStringCreateWithCString( kCFAllocatorDefault, name.c_str(), kCFStringEncodingUTF8 );
104 CFMutableStringRef cfMutable = CFStringCreateMutableCopy( NULL, 0, cfStringRef );
105
106 CFStringNormalize( cfMutable, kCFStringNormalizationFormC );
107
108 const char* c_str = CFStringGetCStringPtr( cfMutable, kCFStringEncodingUTF8 );
109 if ( c_str != NULL ) {
110 std::string result( c_str );
111 CFRelease( cfStringRef );
112 CFRelease( cfMutable );
113 return result;
114 }
115 CFIndex length = CFStringGetLength( cfMutable );
116 CFIndex maxSize = CFStringGetMaximumSizeForEncoding( length, kCFStringEncodingUTF8 );
117 if ( maxSize == kCFNotFound ) {
118 CFRelease( cfStringRef );
119 CFRelease( cfMutable );
120 return std::string();
121 }
122
123 std::string result( maxSize + 1, '\0' );
124 if ( CFStringGetCString( cfMutable, &result[0], result.size(), kCFStringEncodingUTF8 ) ) {
125 result.resize( std::strlen( result.c_str() ) );
126 CFRelease( cfStringRef );
127 CFRelease( cfMutable );
128 } else {
129 result.clear();
130 }
131 return result;
132#else
133 return name;
134#endif
135}
136
137bool FileSystem::isRemoteFS( const std::string& directory ) {
138 return Platform::FileSystem::isRemoteFS( directory );

Callers

nothing calls this directly

Calls 4

c_strMethod · 0.80
sizeMethod · 0.80
resizeMethod · 0.80
clearMethod · 0.45

Tested by

no test coverage detected