28 if (cstr && cstr[0]) {
30 ::CFStringCreateWithCString(kCFAllocatorDefault, cstr, cstr_encoding));
42 CFStringRef new_value = NULL;
45 ::CFStringCreateWithFileSystemRepresentation(kCFAllocatorDefault, path);
52 CFStringRef new_value = NULL;
53 if (cf_type != NULL) {
54 CFTypeID cf_type_id = ::CFGetTypeID(cf_type);
56 if (cf_type_id == ::CFStringGetTypeID()) {
58 new_value = (CFStringRef)::CFRetain(cf_type);
59 }
else if (cf_type_id == ::CFURLGetTypeID()) {
61 ::CFURLCopyFileSystemPath((CFURLRef)cf_type, kCFURLPOSIXPathStyle);
91 const CFStringEncoding encoding = kCFStringEncodingUTF8;
92 CFIndex max_utf8_str_len = CFStringGetLength(cf_str);
94 CFStringGetMaximumSizeForEncoding(max_utf8_str_len, encoding);
95 if (max_utf8_str_len > 0) {
96 str.resize(max_utf8_str_len);
98 if (CFStringGetCString(cf_str, &str[0], str.size(), encoding)) {
99 str.resize(strlen(str.c_str()));
111 if (::glob(path, GLOB_TILDE, NULL, &globbuf) == 0) {
112 expanded_path = globbuf.gl_pathv[0];
113 ::globfree(&globbuf);
115 expanded_path.clear();
117 return expanded_path.c_str();
130 ::CFStringGetMaximumSizeOfFileSystemRepresentation(cf_str);
131 if (max_length > 0) {
132 str.resize(max_length);
134 if (::CFStringGetFileSystemRepresentation(cf_str, &str[0],
136 str.erase(::strlen(str.c_str()));
147 CFStringRef str = get();
149 return CFStringGetLength(str);