本文整理匯總了C++中CFURLGetFileSystemRepresentation函數的典型用法代碼示例。如果您正苦於以下問題:C++ CFURLGetFileSystemRepresentation函數的具體用法?C++ CFURLGetFileSystemRepresentation怎麽用?C++ CFURLGetFileSystemRepresentation使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了CFURLGetFileSystemRepresentation函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: start
/* -----------------------------------------------------------------------------
plugin entry point, called by pppd
----------------------------------------------------------------------------- */
int start(CFBundleRef ref)
{
CFStringRef strref;
CFURLRef urlref;
bundle = ref;
CFRetain(bundle);
url = CFBundleCopyBundleURL(bundle);
// hookup our handlers
old_check_options = the_channel->check_options;
the_channel->check_options = serial_check_options;
old_connect = the_channel->connect;
the_channel->connect = serial_connect;
old_process_extra_options = the_channel->process_extra_options;
the_channel->process_extra_options = serial_process_extra_options;
add_notifier(&connect_fail_notify, serial_connect_notifier, 0);
add_notifier(&lcp_lowerdown_notify, serial_lcpdown_notifier, 0);
cancelstrref = CFBundleCopyLocalizedString(bundle, CFSTR("Cancel"), CFSTR("Cancel"), NULL);
if (cancelstrref == 0) return 1;
CFStringGetCString(cancelstrref, (char*)cancelstr, sizeof(cancelstr), kCFStringEncodingUTF8);
icstrref = CFBundleCopyLocalizedString(bundle, CFSTR("Network Connection"), CFSTR("Network Connection"), NULL);
if (icstrref == 0) return 1;
CFStringGetCString(icstrref, (char*)icstr, sizeof(icstr), kCFStringEncodingUTF8);
urlref = CFBundleCopyResourceURL(bundle, CFSTR("NetworkConnect.icns"), NULL, NULL);
if (urlref == 0 || ((strref = CFURLGetString(urlref)) == 0)) {
if (urlref)
CFRelease(urlref);
return 1;
}
CFStringGetCString(strref, (char*)iconstr, sizeof(iconstr), kCFStringEncodingUTF8);
iconstrref = CFStringCreateCopy(NULL, strref);
CFRelease(urlref);
urlref = CFBundleCopyBuiltInPlugInsURL(bundle);
if (urlref == 0 || ((CFURLGetFileSystemRepresentation(urlref, TRUE, pathccl, sizeof(pathccl))) == FALSE)) {
if (urlref)
CFRelease(urlref);
return 1;
}
strlcat((char*)pathccl, SUFFIX_CCLENGINE, sizeof(pathccl));
CFRelease(urlref);
// add the socket specific options
add_options(serial_options);
return 0;
}
示例2: _CFBundleDlfcnPreflight
CF_EXPORT Boolean _CFBundleDlfcnPreflight(CFBundleRef bundle, CFErrorRef *error) {
Boolean retval = true;
CFErrorRef localError = NULL;
if (!bundle->_isLoaded) {
CFURLRef executableURL = CFBundleCopyExecutableURL(bundle);
char buff[CFMaxPathSize];
retval = false;
if (executableURL && CFURLGetFileSystemRepresentation(executableURL, true, (uint8_t *)buff, CFMaxPathSize)) {
#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED
retval = dlopen_preflight(buff);
#endif
if (!retval && error) {
CFArrayRef archs = CFBundleCopyExecutableArchitectures(bundle);
CFStringRef debugString = NULL;
const char *errorString = dlerror();
if (errorString && strlen(errorString) > 0) debugString = CFStringCreateWithFileSystemRepresentation(kCFAllocatorSystemDefault, errorString);
if (archs) {
Boolean hasSuitableArch = false, hasRuntimeMismatch = false;
CFIndex i, count = CFArrayGetCount(archs);
SInt32 arch, curArch = _CFBundleCurrentArchitecture();
for (i = 0; !hasSuitableArch && i < count; i++) {
if (CFNumberGetValue((CFNumberRef)CFArrayGetValueAtIndex(archs, i), kCFNumberSInt32Type, (void *)&arch) && arch == curArch) hasSuitableArch = true;
}
#if defined(BINARY_SUPPORT_DYLD)
if (hasSuitableArch) {
uint32_t mainFlags = 0;
if (_CFBundleGrokObjCImageInfoFromMainExecutable(NULL, &mainFlags) && (mainFlags & 0x2) != 0) {
#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED
uint32_t bundleFlags = 0;
if (_CFBundleGetObjCImageInfo(bundle, NULL, &bundleFlags) && (bundleFlags & 0x2) == 0) hasRuntimeMismatch = true;
#endif
}
}
#endif /* BINARY_SUPPORT_DYLD */
if (hasRuntimeMismatch) {
localError = _CFBundleCreateErrorDebug(CFGetAllocator(bundle), bundle, CFBundleExecutableRuntimeMismatchError, debugString);
} else if (!hasSuitableArch) {
localError = _CFBundleCreateErrorDebug(CFGetAllocator(bundle), bundle, CFBundleExecutableArchitectureMismatchError, debugString);
} else {
localError = _CFBundleCreateErrorDebug(CFGetAllocator(bundle), bundle, CFBundleExecutableLoadError, debugString);
}
CFRelease(archs);
} else {
localError = _CFBundleCreateErrorDebug(CFGetAllocator(bundle), bundle, CFBundleExecutableLoadError, debugString);
}
if (debugString) CFRelease(debugString);
}
} else {
if (error) localError = _CFBundleCreateError(CFGetAllocator(bundle), bundle, CFBundleExecutableNotFoundError);
}
if (executableURL) CFRelease(executableURL);
}
if (!retval && error) *error = localError;
return retval;
}
示例3: setcwd
void setcwd(void) {
// make sure cwd is where the app is (launching from Finder sets it to / by default)
unsigned char parentdir[MAXPATHLEN];
CFURLRef url = CFBundleCopyResourcesDirectoryURL(CFBundleGetMainBundle());
if (CFURLGetFileSystemRepresentation(url, true, parentdir, MAXPATHLEN)) {
chdir((char *)parentdir);
}
CFRelease(url);
}
示例4: getExecutablePath
std::string getExecutablePath()
{
CFURLRef url = CFBundleCopyBundleURL(CFBundleGetMainBundle());
FixedStrT<512> buf;
CFURLGetFileSystemRepresentation(url, true,
(UInt8*) buf.str(), buf.capacity());
return buf.str();
}
示例5: application_path
const String application_path() {
cf::Url url(CFBundleCopyResourcesDirectoryURL(CFBundleGetMainBundle()));
cf::String url_string(CFStringCreateCopy(NULL, CFURLGetString(url.c_obj())));
char path_buffer[PATH_MAX];
if (!CFURLGetFileSystemRepresentation(
url.c_obj(), true, reinterpret_cast<UInt8*>(path_buffer), PATH_MAX)) {
throw Exception("couldn't get application_path()");
}
return String(utf8::decode(path_buffer));
}
示例6: CFBundleCopyResourcesDirectoryURL
char *HostFilesys::getDataFolder(char *buffer, unsigned int bufsize)
{
UInt8 main_bundle_loc[MAXPATHLEN];
CFURLRef url = CFBundleCopyResourcesDirectoryURL(CFBundleGetMainBundle());
CFURLGetFileSystemRepresentation(url, true, main_bundle_loc, sizeof(main_bundle_loc));
CFRelease(url);
//printf("Data folder ---------> %s\n", main_bundle_loc);
return safe_strncpy(buffer, (char*)main_bundle_loc, bufsize);
}
示例7: _CFGetFileProperties
__private_extern__ SInt32 _CFGetFileProperties(CFAllocatorRef alloc, CFURLRef pathURL, Boolean *exists, SInt32 *posixMode, int64_t *size, CFDateRef *modTime, SInt32 *ownerID, CFArrayRef *dirContents) {
char path[CFMaxPathSize];
if (!CFURLGetFileSystemRepresentation(pathURL, true, (uint8_t *)path, CFMaxPathLength)) {
return -1;
}
return _CFGetPathProperties(alloc, path, exists, posixMode, size, modTime, ownerID, dirContents);
}
示例8: bundle_path
char* bundle_path() {
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(mainBundle);
int len = 4096;
char* path = malloc(len);
CFURLGetFileSystemRepresentation(resourcesURL, TRUE, (UInt8*)path, len);
return path;
}
開發者ID:big538,項目名稱:iOS-10.1.1-Project-0-Exploit-For-Jailbreak---F.C.E.-365-Fork-,代碼行數:10,代碼來源:drop_payload.c
示例9: DAMountRemoveMountPoint
void DAMountRemoveMountPoint( CFURLRef mountpoint )
{
char path[MAXPATHLEN];
/*
* Obtain the mount point path.
*/
if ( CFURLGetFileSystemRepresentation( mountpoint, TRUE, ( void * ) path, sizeof( path ) ) )
{
if ( ___isautofs( path ) == 0 )
{
Boolean remove;
remove = FALSE;
if ( strncmp( path, kDAMainMountPointFolder, strlen( kDAMainMountPointFolder ) ) == 0 )
{
if ( strrchr( path + strlen( kDAMainMountPointFolder ), '/' ) == path + strlen( kDAMainMountPointFolder ) )
{
remove = TRUE;
}
}
///w:start
// if ( remove == FALSE )
///w:stop
{
char file[MAXPATHLEN];
strlcpy( file, path, sizeof( file ) );
strlcat( file, "/", sizeof( file ) );
strlcat( file, kDAMainMountPointFolderCookieFile, sizeof( file ) );
/*
* Remove the mount point cookie file.
*/
if ( unlink( file ) == 0 )
{
remove = TRUE;
}
}
if ( remove )
{
/*
* Remove the mount point.
*/
rmdir( path );
}
}
}
}
示例10: InitDirs
void InitDirs(const std::string& argv0)
{
if (g_initialized)
return;
// store working dir
fs::initial_path();
fs::path bundle_path;
fs::path app_path;
CFBundleRef bundle = CFBundleGetMainBundle();
char bundle_dir[MAXPATHLEN];
if (bundle) {
CFURLRef bundleurl = CFBundleCopyBundleURL(bundle);
CFURLGetFileSystemRepresentation(bundleurl, true, reinterpret_cast<UInt8*>(bundle_dir), MAXPATHLEN);
} else {
// executable is not the main binary in application bundle (i.e. Server or AI)
uint32_t size = sizeof(bundle_dir);
if (_NSGetExecutablePath(bundle_dir, &size) != 0) {
std::cerr << "_NSGetExecutablePath() failed: buffer too small; need size " << size << std::endl;
exit(-1);
}
}
bundle_path = fs::path(bundle_dir);
// search bundle_path for a directory named "FreeOrion.app", exiting if not found, else constructing a path to application bundle contents
fs::path::iterator appiter = std::find(bundle_path.begin(), bundle_path.end(), "FreeOrion.app");
if (appiter == bundle_path.end()) {
std::cerr << "Error: Application bundle must be named 'FreeOrion.app' and executables must not be called from outside of it." << std::endl;
exit(-1);
} else {
for (fs::path::iterator piter = bundle_path.begin(); piter != appiter; ++piter) {
app_path /= *piter;
}
app_path /= "FreeOrion.app/Contents";
}
s_root_data_dir = app_path / "Resources";
s_user_dir = fs::path(getenv("HOME")) / "Library" / "Application Support" / "FreeOrion";
s_bin_dir = app_path / "Executables";
s_config_path = s_user_dir / "config.xml";
s_python_home = app_path / "Frameworks" / "Python.framework" / "Versions" / "Current";
fs::path p = s_user_dir;
if (!exists(p))
fs::create_directories(p);
p /= "save";
if (!exists(p))
fs::create_directories(p);
g_initialized = true;
}
示例11: _CFWriteBytesToFile
__private_extern__ Boolean _CFWriteBytesToFile(CFURLRef url, const void *bytes, CFIndex length) {
struct stat statBuf;
int fd = -1;
int mode;
char path[CFMaxPathSize];
if (!CFURLGetFileSystemRepresentation(url, true, (uint8_t *)path, CFMaxPathSize)) {
return false;
}
#if DEPLOYMENT_TARGET_WINDOWS || 0
mode = 0666;
if (0 == stat(path, &statBuf)) {
mode = statBuf.st_mode;
} else if (thread_errno() != ENOENT) {
return false;
}
fd = open(path, O_WRONLY|O_CREAT|O_TRUNC|CF_OPENFLGS, 0666|_S_IWRITE);
if (fd < 0) {
return false;
}
if (length && write(fd, bytes, length) != length) {
int saveerr = thread_errno();
close(fd);
thread_set_errno(saveerr);
return false;
}
FlushFileBuffers((HANDLE)_get_osfhandle(fd));
close(fd);
#else
int no_hang_fd = open("/dev/autofs_nowait", 0);
mode = 0666;
if (0 == stat(path, &statBuf)) {
mode = statBuf.st_mode;
} else if (thread_errno() != ENOENT) {
close(no_hang_fd);
return false;
}
fd = open(path, O_WRONLY|O_CREAT|O_TRUNC|CF_OPENFLGS, 0666);
if (fd < 0) {
close(no_hang_fd);
return false;
}
if (length && write(fd, bytes, length) != length) {
int saveerr = thread_errno();
close(fd);
close(no_hang_fd);
thread_set_errno(saveerr);
return false;
}
fsync(fd);
close(fd);
close(no_hang_fd);
#endif
return true;
}
示例12: _CFReadBytesFromFile
__private_extern__ Boolean _CFReadBytesFromFile(CFAllocatorRef alloc, CFURLRef url, void **bytes, CFIndex *length, CFIndex maxLength) {
// maxLength is the number of bytes desired, or 0 if the whole file is desired regardless of length.
struct stat statBuf;
int fd = -1;
char path[CFMaxPathSize];
if (!CFURLGetFileSystemRepresentation(url, true, path, CFMaxPathSize)) {
return false;
}
*bytes = NULL;
__CFSetNastyFile(url);
#if defined(__WIN32__)
fd = open(path, O_RDONLY|CF_OPENFLGS, 0666|_S_IREAD);
#else
fd = open(path, O_RDONLY|CF_OPENFLGS, 0666);
#endif
if (fd < 0) {
return false;
}
if (fstat(fd, &statBuf) < 0) {
int saveerr = thread_errno();
close(fd);
thread_set_errno(saveerr);
return false;
}
if ((statBuf.st_mode & S_IFMT) != S_IFREG) {
close(fd);
thread_set_errno(EACCES);
return false;
}
if (statBuf.st_size == 0) {
*bytes = CFAllocatorAllocate(alloc, 4, 0); // don't return constant string -- it's freed!
if (__CFOASafe) __CFSetLastAllocationEventName(*bytes, "CFUtilities (file-bytes)");
*length = 0;
} else {
CFIndex desiredLength;
if ((maxLength >= statBuf.st_size) || (maxLength == 0)) {
desiredLength = statBuf.st_size;
} else {
desiredLength = maxLength;
}
*bytes = CFAllocatorAllocate(alloc, desiredLength, 0);
if (__CFOASafe) __CFSetLastAllocationEventName(*bytes, "CFUtilities (file-bytes)");
if (read(fd, *bytes, desiredLength) < 0) {
CFAllocatorDeallocate(alloc, *bytes);
close(fd);
return false;
}
*length = desiredLength;
}
close(fd);
return true;
}
示例13: SecExtractFilesystemPathForKeychainFile
static bool SecExtractFilesystemPathForKeychainFile(CFStringRef file, UInt8 *buffer, CFIndex maxBufLen)
{
bool translated = false;
CFURLRef fileURL = SecCopyURLForFileInKeychainDirectory(file);
if (fileURL && CFURLGetFileSystemRepresentation(fileURL, false, buffer, maxBufLen))
translated = true;
CFReleaseSafe(fileURL);
return translated;
}
示例14: cfString
string cfString(CFURLRef inUrl)
{
if (!inUrl)
CFError::throwMe();
UInt8 buffer[PATH_MAX+1];
if (CFURLGetFileSystemRepresentation(inUrl, true, buffer, sizeof(buffer)))
return string(reinterpret_cast<char *>(buffer));
else
CFError::throwMe();
}
示例15: stream
bool SFB::Audio::WAVEMetadata::_WriteMetadata(CFErrorRef *error)
{
UInt8 buf [PATH_MAX];
if(!CFURLGetFileSystemRepresentation(mURL, false, buf, PATH_MAX))
return false;
std::unique_ptr<TagLib::FileStream> stream(new TagLib::FileStream((const char *)buf));
if(!stream->isOpen()) {
if(error) {
SFB::CFString description = CFCopyLocalizedString(CFSTR("The file “%@” could not be opened for writing."), "");
SFB::CFString failureReason = CFCopyLocalizedString(CFSTR("Input/output error"), "");
SFB::CFString recoverySuggestion = CFCopyLocalizedString(CFSTR("The file may have been renamed, moved, deleted, or you may not have appropriate permissions."), "");
*error = CreateErrorForURL(Metadata::ErrorDomain, Metadata::InputOutputError, description, mURL, failureReason, recoverySuggestion);
}
return false;
}
TagLib::RIFF::WAV::File file(stream.get(), false);
if(!file.isValid()) {
if(error) {
SFB::CFString description = CFCopyLocalizedString(CFSTR("The file “%@” is not a valid WAVE file."), "");
SFB::CFString failureReason = CFCopyLocalizedString(CFSTR("Not a WAVE file"), "");
SFB::CFString recoverySuggestion = CFCopyLocalizedString(CFSTR("The file's extension may not match the file's type."), "");
*error = CreateErrorForURL(Metadata::ErrorDomain, Metadata::InputOutputError, description, mURL, failureReason, recoverySuggestion);
}
return false;
}
// An Info tag is only written if present, but ID3v2 tags are always written
// TODO: Should other field names from the Info tag be handled?
if(file.InfoTag())
SetTagFromMetadata(*this, file.InfoTag());
SetID3v2TagFromMetadata(*this, file.ID3v2Tag());
if(!file.save()) {
if(error) {
SFB::CFString description = CFCopyLocalizedString(CFSTR("The file “%@” is not a valid WAVE file."), "");
SFB::CFString failureReason = CFCopyLocalizedString(CFSTR("Unable to write metadata"), "");
SFB::CFString recoverySuggestion = CFCopyLocalizedString(CFSTR("The file's extension may not match the file's type."), "");
*error = CreateErrorForURL(Metadata::ErrorDomain, Metadata::InputOutputError, description, mURL, failureReason, recoverySuggestion);
}
return false;
}
return true;
}