28 if (cstr && cstr[0]) {
30 ::CFStringCreateWithCString(kCFAllocatorDefault, cstr, cstr_encoding));
45 ::CFStringCreateWithFileSystemRepresentation(kCFAllocatorDefault, path);
53 if (cf_type != NULL) {
54 CFTypeID cf_type_id = ::CFGetTypeID(cf_type);
56 if (cf_type_id == ::CFStringGetTypeID()) {
59 }
else if (cf_type_id == ::CFURLGetTypeID()) {
61 ::CFURLCopyFileSystemPath((CFURLRef)cf_type, kCFURLPOSIXPathStyle);
70 std::string expanded_path;
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()));
109 std::string &expanded_path) {
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()));
149 return CFStringGetLength(str);
void reset(CFStringRef ptr=NULL)
CFCString(CFStringRef cf_str=NULL)
CFStringRef SetFileSystemRepresentationFromCFType(CFTypeRef cf_type)
CFCString & operator=(const CFCString &rhs)
static const char * ExpandTildeInPath(const char *path, std::string &expanded_path)
const char * UTF8(std::string &str)
CFIndex GetLength() const
static const char * FileSystemRepresentation(CFStringRef cf_str, std::string &str)
const char * GetFileSystemRepresentation(std::string &str)
CFStringRef SetFileSystemRepresentationAndExpandTilde(const char *path)
CFStringRef SetFileSystemRepresentation(const char *path)