这篇教程C++ FSPathMakeRef函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中FSPathMakeRef函数的典型用法代码示例。如果您正苦于以下问题:C++ FSPathMakeRef函数的具体用法?C++ FSPathMakeRef怎么用?C++ FSPathMakeRef使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了FSPathMakeRef函数的27个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: FT_FSPathMakeRes static OSErr FT_FSPathMakeRes( const UInt8* pathname, short* res ) {#if HAVE_FSREF OSErr err; FSRef ref; if ( noErr != FSPathMakeRef( pathname, &ref, FALSE ) ) return FT_Err_Cannot_Open_Resource; /* at present, no support for dfont format */ err = FSOpenResourceFile( &ref, 0, NULL, fsRdPerm, res ); if ( noErr == err ) return err; /* fallback to original resource-fork font */ *res = FSOpenResFile( &ref, fsRdPerm ); err = ResError();#else OSErr err; FSSpec spec; if ( noErr != FT_FSPathMakeSpec( pathname, &spec, FALSE ) ) return FT_Err_Cannot_Open_Resource; /* at present, no support for dfont format without FSRef */ /* (see above), try original resource-fork font */ *res = FSpOpenResFile( &spec, fsRdPerm ); err = ResError();#endif /* HAVE_FSREF */ return err; }
开发者ID:HelstVadsom,项目名称:amazing-maze,代码行数:41,
示例2: m_dirnamewxDirData::wxDirData(const wxString& dirname) : m_dirname(dirname){ m_ok = false; OSErr err; // throw away the trailing slashes size_t n = m_dirname.length(); wxCHECK_RET( n, _T("empty dir name in wxDir") ); while ( n > 0 && wxIsPathSeparator(m_dirname[--n]) ) ; m_dirname.Truncate(n + 1);#ifdef __DARWIN__ FSRef theRef; // get the FSRef associated with the POSIX path err = FSPathMakeRef((const UInt8 *) m_dirname.c_str(), &theRef, NULL); FSGetVRefNum(&theRef, &(m_CPB.hFileInfo.ioVRefNum)); err = FSGetNodeID( &theRef , &m_dirId , &m_isDir ) ;#else FSSpec fsspec ; wxMacFilename2FSSpec( m_dirname , &fsspec ) ; m_CPB.hFileInfo.ioVRefNum = fsspec.vRefNum ; err = FSpGetDirectoryID( &fsspec , &m_dirId , &m_isDir ) ;#endif //wxASSERT_MSG( (err == noErr) || (err == nsvErr) , wxT("Error accessing directory " + m_dirname)) ; if ( (err == noErr) || (err == nsvErr)) m_ok = true; else wxLogError(wxString(wxT("Error accessing directory ")) + m_dirname); m_CPB.hFileInfo.ioNamePtr = m_name ; m_index = 0 ;}
开发者ID:Duion,项目名称:Torsion,代码行数:41,
示例3: promptForFolderchar* promptForFolder(const char *prompt, const char *defaultPath, char* folderPath, int folderPathLen){ char path[PATH_MAX]; OSStatus err; Boolean isDirectory; int len; FSRef ref; /* Display the prompt. */ if (prompt == NULL) prompt = "Please enter the path to a folder:"; printf("%s ", prompt); if (defaultPath != NULL) printf("[%s] ",defaultPath); fflush(stdout); /* Get user input, and trim trailing newlines. */ fgets(path,sizeof(path),stdin); for (len = strlen(path); len > 0 && path[len-1] == '/n';) path[--len] = 0; if (path[0] == 0) strcpy(path,defaultPath); /* Expand magic characters just like a shell (mostly so ~ will work) */ expandPathname(path); /* Convert the path into an FSRef, which is what the burn engine needs. */ err = FSPathMakeRef((const UInt8*)path,&ref,&isDirectory); if (err != noErr) { printf("Bad path. Aborting. (%d)/n", (int)err); exit(1); } if (!isDirectory) { printf("That's a file, not a directory! Aborting./n"); exit(1); } return strncpy(folderPath, path, folderPathLen);}
开发者ID:fruitsamples,项目名称:audioburntest,代码行数:41,
示例4: isLinkbool isLink(const bfs::path& path){ if (isSymlink(path)) { return true; }#ifdef MACOSX // aliases appear as regular files if (isRegularFile(path)) { FSRef ref; if (FSPathMakeRef((const UInt8*)path.c_str(), &ref, NULL) == noErr) { Boolean isAlias = false, isFolder = false; if (FSIsAliasFile(&ref, &isAlias, &isFolder) == noErr) { return isAlias; } } }#endif return false; }
开发者ID:Go-LiDth,项目名称:platform,代码行数:21,
示例5: FSPathMakeFSSpecOSStatus FSPathMakeFSSpec(const UInt8 *path,FSSpec *spec,Boolean *isDirectory) /* can be NULL */{ OSStatus result; FSRef ref; /* check parameters */ require_action(NULL != spec, BadParameter, result = paramErr); /* convert the POSIX path to an FSRef */ result = FSPathMakeRef(path, &ref, isDirectory); require_noerr(result, FSPathMakeRef); /* and then convert the FSRef to an FSSpec */ result = FSGetCatalogInfo(&ref, kFSCatInfoNone, NULL, NULL, spec, NULL); require_noerr(result, FSGetCatalogInfo); FSGetCatalogInfo:FSPathMakeRef:BadParameter: return result;}
开发者ID:Angeldude,项目名称:pd,代码行数:21,
示例6: FSPathMakeRefvoid CResourceFile::LoadFile( const std::string& fpath ){ FSRef fileRef; mResRefNum = -1; OSStatus resErr = FSPathMakeRef( (const UInt8*) fpath.c_str(), &fileRef, NULL ); if( resErr == noErr ) { mResRefNum = FSOpenResFile( &fileRef, fsRdPerm ); if( mResRefNum < 0 ) { fprintf( stderr, "Warning: No Mac resource fork to import./n" ); resErr = fnfErr; } } else { fprintf( stderr, "Error: Error %d locating input file's resource fork./n", (int)resErr ); mResRefNum = -1; }}
开发者ID:UncombedCoconut,项目名称:stackimport,代码行数:21,
示例7: PortBurn_EndTrack/* Finish the current audio track. */int PortBurn_EndTrack(void *handle){ PBHandle *h = (PBHandle *)handle; DRAudioTrackRef track; Boolean isDirectory; const char *filename; FSRef fsref; int index; if (!h) return pbErrNoHandle; if (!h->staging) return pbErrMustCallStartStaging; if (0 != PortBurn_EndStagingTrack(h->staging)) return pbErrCannotStageTrack; index = PortBurn_GetNumStagedTracks(h->staging); if (index <= 0) return pbErrCannotStageTrack; filename = PortBurn_GetStagedFilename(h->staging, index - 1); printf("Filename: '%s'/n", filename); h->err = FSPathMakeRef((const UInt8*)filename, &fsref, &isDirectory); if (h->err != noErr) return pbErrCannotAccessStagedFile; if (isDirectory) return pbErrCannotAccessStagedFile; track = DRAudioTrackCreate(&fsref); CFArrayAppendValue(h->trackArray, track); CFRelease(track); if (track) return pbSuccess; else return pbErrCannotUseStagedFileForBurning;}
开发者ID:AkiraShirase,项目名称:audacity,代码行数:41,
示例8: TRASH_CanTrashFileBOOL TRASH_CanTrashFile(LPCWSTR wszPath){ char *unix_path; OSStatus status; FSRef ref; FSCatalogInfo catalogInfo; TRACE("(%s)/n", debugstr_w(wszPath)); if (!(unix_path = wine_get_unix_file_name(wszPath))) return FALSE; status = FSPathMakeRef((UInt8*)unix_path, &ref, NULL); heap_free(unix_path); if (status == noErr) status = FSGetCatalogInfo(&ref, kFSCatInfoVolume, &catalogInfo, NULL, NULL, NULL); if (status == noErr) status = FSFindFolder(catalogInfo.volume, kTrashFolderType, kCreateFolder, &ref); return (status == noErr);}
开发者ID:ccpgames,项目名称:wine,代码行数:22,
示例9: wd_apple_resolve_aliasint wd_apple_resolve_alias(char *dst, char *src, size_t size) { FSRef fsPath; Boolean isDir, isAlias; strlcpy(dst, src, size); if(!wd_chroot) { if(FSPathMakeRef(src, &fsPath, NULL) != 0) return -1; if(FSIsAliasFile(&fsPath, &isAlias, &isDir) != 0) return -1; if(FSResolveAliasFile(&fsPath, true, &isDir, &isAlias) != 0) return -1; if(FSRefMakePath(&fsPath, dst, size) != 0) return -1; } return 1;}
开发者ID:ProfDrLuigi,项目名称:zanka,代码行数:22,
示例10: definedstd::unique_ptr<ImportFileHandle> QTImportPlugin::Open(const wxString & Filename){ OSErr err; FSRef inRef; Movie theMovie = NULL; Handle dataRef = NULL; OSType dataRefType = 0; short resID = 0;#if defined(__WXMAC__) err = wxMacPathToFSRef(Filename, &inRef);#else // LLL: This will not work for pathnames with Unicode characters...find // another method. err = FSPathMakeRef((UInt8 *)OSFILENAME(Filename), &inRef, NULL);#endif if (err != noErr) { return nullptr; } err = QTNewDataReferenceFromFSRef(&inRef, 0, &dataRef, &dataRefType); if (err != noErr) { return nullptr; } // instantiate the movie err = NewMovieFromDataRef(&theMovie, newMovieActive | newMovieDontAskUnresolvedDataRefs, &resID, dataRef, dataRefType); DisposeHandle(dataRef); if (err != noErr) { return nullptr; } return std::make_unique<QTImportFileHandle>(Filename, theMovie);}
开发者ID:finefin,项目名称:audacity,代码行数:39,
示例11: FT_FSPathMakeRes static OSErr FT_FSPathMakeRes( const UInt8* pathname, ResFileRefNum* res ) { OSErr err; FSRef ref; if ( noErr != FSPathMakeRef( pathname, &ref, FALSE ) ) return FT_Err_Cannot_Open_Resource; /* at present, no support for dfont format */ err = FSOpenResourceFile( &ref, 0, NULL, fsRdPerm, res ); if ( noErr == err ) return err; /* fallback to original resource-fork font */ *res = FSOpenResFile( &ref, fsRdPerm ); err = ResError(); return err; }
开发者ID:32767,项目名称:libgdx,代码行数:22,
示例12: setup/*AudioFile::AudioFile( shared_ptr<IStream> aStream ) : mStream( aStream ){ setup();}*/AudioFile::AudioFile( const std::string &aFilePath ){#if defined( FLI_MAC ) FSRef fsref; OSStatus fileRefError = FSPathMakeRef( (const UInt8 *)aFilePath.c_str(), &fsref, NULL ); if( fileRefError ) { //handle error std::cout << "Input file not found" << std::endl; return; } OSStatus audioFileOpenError = AudioFileOpen(&fsref, fsRdPerm, 0, &mNativeFileRef); if( audioFileOpenError ) { //handle error std::cout << "AudioFileOpen failed" << std::endl; return; } loadHeader(); load();#endif}
开发者ID:AaronMeyers,项目名称:Cinder,代码行数:26,
示例13: mainint main (int argc, const char *argv[]) { SInt32 fileID; FSRef ref, volRef; FSCatalogInfo volCatInfo; OSErr result; unsigned char pathName[255]; // Exit if anything more or less than two arguments are passed in if (argc != 3) { printf("Usage: %s <HFS ID> <volume mount point>/n", argv[0]); return 0; } result = FSPathMakeRef(argv[2], &volRef, NULL); if (result != noErr) { printf("Error %d/n", result); return 10; } result = FSGetCatalogInfo(&volRef, kFSCatInfoVolume, &volCatInfo, NULL, NULL, NULL); if (result != noErr) { printf("Error %d/n", result); return 10; } fileID = atoi(argv[1]); result = FSResolveFileIDRef(volCatInfo.volume, fileID, &ref); if (result != noErr) { printf("Error %d/n", result); return 10; } result = FSRefMakePath(&ref, pathName, sizeof(pathName)); if (result != noErr) { printf("Error %d/n", result); return 10; } printf("%s/n", pathName); return 0;}
开发者ID:c0sco,项目名称:lookupid,代码行数:39,
示例14: myFSCreateResFilestatic OSErr myFSCreateResFile(const char *path, OSType creator, OSType fileType, FSRef *outRef) { int fd = open(path, O_CREAT | O_WRONLY, 0666); if (fd == -1) { perror("opening destination:"); return bdNamErr; } close(fd); FSRef ref; OSErr err = FSPathMakeRef((const UInt8*)path, &ref, NULL); if (err != noErr) return err; HFSUniStr255 rname; FSGetResourceForkName(&rname); err = FSCreateResourceFork(&ref, rname.length, rname.unicode, 0); if (err != noErr) return err; FInfo finfo; err = FSGetFInfo(&ref, &finfo); if (err != noErr) return err; finfo.fdCreator = creator; finfo.fdType = fileType; err = FSSetFInfo(&ref, &finfo); if (err != noErr) return err; *outRef = ref; return noErr;}
开发者ID:specious,项目名称:osxutils,代码行数:38,
示例15: FSPathMakeRef/********** HELPER FUNCTIONS ***********/static const char *GetSpecialPathName(const char *Path){ if(GetProductIsAppBundle(cur_info)) { FSRef Ref; HFSUniStr255 SpecialPathHFS; FSPathMakeRef(Path, &Ref, NULL); FSGetCatalogInfo(&Ref, kFSCatInfoNone, NULL, &SpecialPathHFS, NULL, NULL); CFStringRef cfs = CFStringCreateWithCharacters(kCFAllocatorDefault, SpecialPathHFS.unicode, SpecialPathHFS.length); CFStringGetCString(cfs, SpecialPath, 1024, kCFStringEncodingASCII); CFRelease(cfs); return SpecialPath; /*// Otherwise, it'll show /Users/joeshmo/Desktop. if(strstr(Path, DesktopName) != NULL) return DesktopName; else if(strstr(Path, DocumentsName) != NULL) return DocumentsName; else if(strstr(Path, ApplicationsName) != NULL) return ApplicationsName;*/ } return Path;}
开发者ID:BackupTheBerlios,项目名称:geoirc,代码行数:24,
示例16: switch//staticpascal void LLFilePickerBase::doNavCallbackEvent(NavEventCallbackMessage callBackSelector, NavCBRecPtr callBackParms, void* callBackUD){ switch(callBackSelector) { case kNavCBStart: { LLFilePickerBase* picker = reinterpret_cast<LLFilePickerBase*>(callBackUD); if (picker->getFolder().empty()) break; OSStatus error = noErr; AEDesc theLocation = {typeNull, NULL}; FSSpec outFSSpec; //Convert string to a FSSpec FSRef myFSRef; const char* folder = picker->getFolder().c_str(); error = FSPathMakeRef ((UInt8*)folder, &myFSRef, NULL); if (error != noErr) break; error = FSGetCatalogInfo (&myFSRef, kFSCatInfoNone, NULL, NULL, &outFSSpec, NULL); if (error != noErr) break; error = AECreateDesc(typeFSS, &outFSSpec, sizeof(FSSpec), &theLocation); if (error != noErr) break; error = NavCustomControl(callBackParms->context, kNavCtlSetLocation, (void*)&theLocation); } }}
开发者ID:NickyPerian,项目名称:SingularityViewer,代码行数:38,
示例17: _q_isMacHiddenstatic bool _q_isMacHidden(const QString &path){ OSErr err = noErr; FSRef fsRef;#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4) if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4) { err = FSPathMakeRefWithOptions(reinterpret_cast<const UInt8 *>(QFile::encodeName(QDir::cleanPath(path)).constData()), kFSPathMakeRefDoNotFollowLeafSymlink, &fsRef, 0); } else#endif { QFileInfo fi(path); FSRef parentRef; err = FSPathMakeRef(reinterpret_cast<const UInt8 *>(fi.absoluteDir().absolutePath().toUtf8().constData()), &parentRef, 0); if (err == noErr) { QString fileName = fi.fileName(); err = FSMakeFSRefUnicode(&parentRef, fileName.length(), reinterpret_cast<const UniChar *>(fileName.unicode()), kTextEncodingUnknown, &fsRef); } } if (err != noErr) return false; FSCatalogInfo catInfo; err = FSGetCatalogInfo(&fsRef, kFSCatInfoFinderInfo, &catInfo, NULL, NULL, NULL); if (err != noErr) return false; FileInfo * const fileInfo = reinterpret_cast<FileInfo*>(&catInfo.finderInfo); bool result = (fileInfo->finderFlags & kIsInvisible); return result;}
开发者ID:FilipBE,项目名称:qtextended,代码行数:36,
示例18: get_file_type_from_path /* Return the file type for given pathname */ static OSType get_file_type_from_path( const UInt8* pathname ) {#if HAVE_FSREF FSRef ref; FSCatalogInfo info; if ( noErr != FSPathMakeRef( pathname, &ref, FALSE ) ) return ( OSType ) 0; if ( noErr != FSGetCatalogInfo( &ref, kFSCatInfoFinderInfo, &info, NULL, NULL, NULL ) ) return ( OSType ) 0; return ((FInfo *)(info.finderInfo))->fdType;#else FSSpec spec; FInfo finfo; if ( noErr != FT_FSPathMakeSpec( pathname, &spec, FALSE ) ) return ( OSType ) 0; if ( noErr != FSpGetFInfo( &spec, &finfo ) ) return ( OSType ) 0; return finfo.fdType;#endif /* HAVE_FSREF */ }
开发者ID:Wafflespeanut,项目名称:gecko-dev,代码行数:37,
示例19: FindCustomFolderstatic OSStatus FindCustomFolder (FSRef *folderRef, char *folderPath, const char *folderName){ OSStatus err; CFStringRef fstr; FSRef pref; UniChar buffer[PATH_MAX + 1]; char s[PATH_MAX + 1]; if (saveFolderPath == NULL) return (-1); err = CFStringGetCString(saveFolderPath, s, PATH_MAX, kCFStringEncodingUTF8) ? noErr : -1; if (err == noErr) err = FSPathMakeRef((unsigned char *) s, &pref, NULL); if (err) return (err); fstr = CFStringCreateWithCString(kCFAllocatorDefault, folderName, CFStringGetSystemEncoding()); CFStringGetCharacters(fstr, CFRangeMake(0, CFStringGetLength(fstr)), buffer); err = FSMakeFSRefUnicode(&pref, CFStringGetLength(fstr), buffer, kTextEncodingUnicodeDefault, folderRef); if (err == dirNFErr || err == fnfErr) { err = FSCreateDirectoryUnicode(&pref, CFStringGetLength(fstr), buffer, kFSCatInfoNone, NULL, folderRef, NULL, NULL); if (err == noErr) AddFolderIcon(folderRef, folderName); } if (err == noErr) err = FSRefMakePath(folderRef, (unsigned char *) folderPath, PATH_MAX); CFRelease(fstr); return (err);}
开发者ID:7sevenx7,项目名称:snes9x,代码行数:36,
示例20: memsetvoid nglDataFilesObject::SetDragItemFlavorData(DragRef dragRef, DragItemRef& itemRef, FlavorType flavorType){ OSErr err = noErr; nglString file; std::list<DragItemRef>::iterator iRef = mItemRefs.begin(); for (std::list<nglString>::const_iterator i = GetFiles().begin(); i != GetFiles().end() && iRef != mItemRefs.end(); ++i, ++iRef) { if (itemRef == *iRef) { HFSFlavor hfsInfo; FSRef fileRef; int32 start = 0; int32 len = 1023; char str[1024]; memset(str, 0, 1024); i->Export(start, str, len, eUTF8); err = FSPathMakeRef((const UInt8*)str, &fileRef, NULL); NGL_ASSERT(!err); FSCatalogInfo catInfo; err = FSGetCatalogInfo(&fileRef, kFSCatInfoFinderInfo, &catInfo, NULL, &(hfsInfo.fileSpec), NULL); NGL_ASSERT(!err); FileInfo* finfo = (FileInfo*) &catInfo.finderInfo; hfsInfo.fdFlags = finfo->finderFlags; hfsInfo.fileType = finfo->fileType; hfsInfo.fileCreator = finfo->fileCreator; err = ::SetDragItemFlavorData(dragRef, itemRef, kDragFlavorTypeHFS, &hfsInfo, sizeof (hfsInfo), 0); NGL_ASSERT(!err); //NGL_OUT("Adding file to drag data, itemRef is %d: %s/n", itemRef, (*i).GetChars()); return; } }}
开发者ID:JamesLinus,项目名称:nui3,代码行数:36,
示例21: switch//staticpascal void LLDirPicker::doNavCallbackEvent(NavEventCallbackMessage callBackSelector, NavCBRecPtr callBackParms, void* callBackUD){ switch(callBackSelector) { case kNavCBStart: { if (!sInstance.mFileName) break; OSStatus error = noErr; AEDesc theLocation = {typeNull, NULL}; FSSpec outFSSpec; //Convert string to a FSSpec FSRef myFSRef; const char* filename=sInstance.mFileName->c_str(); error = FSPathMakeRef ((UInt8*)filename, &myFSRef, NULL); if (error != noErr) break; error = FSGetCatalogInfo (&myFSRef, kFSCatInfoNone, NULL, NULL, &outFSSpec, NULL); if (error != noErr) break; error = AECreateDesc(typeFSS, &outFSSpec, sizeof(FSSpec), &theLocation); if (error != noErr) break; error = NavCustomControl(callBackParms->context, kNavCtlSetLocation, (void*)&theLocation); } }}
开发者ID:OS-Development,项目名称:VW.Kirsten,代码行数:37,
示例22: path_to_fsspecbool path_to_fsspec(const char *p_filename, FSSpec* r_fsspec){ bool t_success; t_success = true; FSRef t_ref; if (t_success) { OSStatus t_status; t_status = FSPathMakeRef((const UInt8 *)p_filename, &t_ref, NULL); if (t_status != noErr) t_success = false; } if (t_success) { OSErr t_error; t_error = FSGetCatalogInfo(&t_ref, kFSCatInfoNone, NULL, NULL, r_fsspec, NULL); if (t_error != noErr) t_success = false; } return t_success;}
开发者ID:Bjoernke,项目名称:livecode,代码行数:24,
示例23: file_spec_from_path /* Given a pathname, fill in a file spec. */ static int file_spec_from_path( const char* pathname, FSSpec* spec ) {#if TARGET_API_MAC_CARBON OSErr e; FSRef ref; e = FSPathMakeRef( (UInt8 *)pathname, &ref, false /* not a directory */ ); if ( e == noErr ) e = FSGetCatalogInfo( &ref, kFSCatInfoNone, NULL, NULL, spec, NULL ); return ( e == noErr ) ? 0 : (-1);#else Str255 p_path; FT_ULong path_len; /* convert path to a pascal string */ path_len = ft_strlen( pathname ); if ( path_len > 255 ) return -1; p_path[0] = (unsigned char)path_len; ft_strncpy( (char*)p_path + 1, pathname, path_len ); if ( FSMakeFSSpec( 0, 0, p_path, spec ) != noErr ) return -1; else return 0;#endif }
开发者ID:dikerex,项目名称:theqvd,代码行数:37,
示例24: filecontainer_doopen//.........这里部分代码省略......... if(!record2) { sprintf(sql, "UPDATE files SET valid = 0 WHERE file_id = %s ", record[0]); object_method(x->sqlite, _sym_execstring, sql, NULL); continue; } }#else // WIN_VERSION snprintf(sql, 512, "SELECT file_id_ext FROM attrs / WHERE attr_name = 'platform' AND attr_value = 'mac' AND file_id_ext = %s ", record[0]); object_method(x->sqlite, _sym_execstring, sql, &result2); record2 = (char **)object_method(result2, _sym_nextrecord); if(record2) { snprintf(sql, 512, "SELECT file_id_ext FROM attrs / WHERE attr_name = 'platform' AND attr_value = 'windows' AND file_id_ext = %s ", record[0]); object_method(x->sqlite, _sym_execstring, sql, &result2); record2 = (char **)object_method(result2, _sym_nextrecord); if(!record2) { snprintf(sql, 512, "UPDATE files SET valid = 0 WHERE file_id = %s ", record[0]); object_method(x->sqlite, _sym_execstring, sql, NULL); continue; } }#endif // At this point we have a file (record[0]), and we have determined that it is indeed a file we want to cache // So cache it to a new file in our temp path err = path_createsysfile(record[1], x->temp_path, type, &file_handle); if(err) { // Handle any errors that occur object_error((t_object *)x, "%s - error %d creating file", filename, err); } else { snprintf(sql, 512, "SELECT content FROM files WHERE file_id = %s", record[0]); object_method(x->sqlite, ps_getblob, sql, &blob, &len); err = sysfile_write(file_handle, &len, blob); if(err) { object_error((t_object *)x, "sysfile_write error (%d)", err); } } err = sysfile_seteof(file_handle, len); if(err) { object_error((t_object *)x, "%s - error %d setting EOF", filename, err); } sysfile_close(file_handle); // close file reference sysmem_freeptr(blob); blob = NULL; // Set the moddate#ifdef MAC_VERSION// FSCatalogInfo catalogInfo;// Boolean status; CFGregorianDate gdate; CFAbsoluteTime abstime; CFTimeZoneRef tz; UTCDateTime utc; sscanf(record[2], "%4ld-%02hd-%02hd %02hd:%02hd:%02lf", &gdate.year, (signed short*)&gdate.month, (signed short*)&gdate.day, (signed short*)&gdate.hour, (signed short*)&gdate.minute, &gdate.second); tz = CFTimeZoneCopySystem(); abstime = CFGregorianDateGetAbsoluteTime(gdate, tz); UCConvertCFAbsoluteTimeToUTCDateTime(abstime, &utc); catalogInfo.contentModDate = utc; strcpy(s_tempstr, x->temp_fullpath->s_name); temppath = strchr(s_tempstr, ':'); temppath++; strcat(temppath, "/"); strcat(temppath, record[1]); FSPathMakeRef((UInt8*)temppath, &ref, &isDir); err = FSSetCatalogInfo(&ref, kFSCatInfoContentMod, &catalogInfo);#else // WIN_VERSION char winpath[512]; HANDLE hFile; FILETIME fileTime; SYSTEMTIME systemTime; sscanf(record[2], "%4lu-%02lu-%02lu %02lu:%02lu:%02lu", &systemTime.wYear, &systemTime.wMonth, &systemTime.wDay, &systemTime.wHour, &systemTime.wMinute, &systemTime.wSecond); err = SystemTimeToFileTime(&systemTime, &fileTime); strcpy(s_tempstr, x->temp_fullpath->s_name); path_nameconform(s_tempstr, winpath, PATH_STYLE_NATIVE_WIN, PATH_TYPE_ABSOLUTE); strcat(winpath, "//"); strcat(winpath, record[1]); hFile = CreateFile((LPCSTR)winpath , GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); if(hFile == INVALID_HANDLE_VALUE) { object_error((t_object *)x, "invalid handle value"); goto out; } err = SetFileTime(hFile, &fileTime, &fileTime, &fileTime); if(err == 0) { err = GetLastError(); object_error((t_object *)x, "Error setting date: %i", err); } CloseHandle(hFile);out: ;#endif } object_method(x->sqlite, ps_endtransaction); }
开发者ID:tap,项目名称:TapTools,代码行数:101,
示例25: initializeQuicktimevoid ofQtVideoSaver::setup( int width , int height, string movieName){ w = width; h = height; fileName = (ofToDataPath(movieName)); //pszFlatFilename = flatFileName; initializeQuicktime(); /* Load the FSSpec structure to describe the receiving file. For a description of this and related calls see http://developer.apple.com/quicktime/icefloe/dispatch004.html. ================================================================ */ #ifdef TARGET_WIN32 //FILE * pFile = NULL; //pFile = fopen (fileName.c_str(),"w"); //fclose (pFile); char fileNameStr[255]; sprintf(fileNameStr, "%s", fileName.c_str()); osErr = NativePathNameToFSSpec (fileNameStr, &fsSpec, 0); #endif #ifdef TARGET_OSX /// kill a file and make a new one if needed: FILE * pFile; pFile = fopen (fileName.c_str(),"w"); fclose (pFile); Boolean isdir; osErr = FSPathMakeRef((const UInt8*)fileName.c_str(), &fsref, &isdir); osErr = FSGetCatalogInfo(&fsref, kFSCatInfoNone, NULL, NULL, &fsSpec, NULL); #endif if (osErr && (osErr != fnfErr)) /* File-not-found error is ok */ { printf ("getting FSS spec failed %d/n", osErr); goto bail; } /* Step 1: Create a new, empty movie file and a movie that references that file (CreateMovieFile). ======================================================================== */ osErr = CreateMovieFile ( &fsSpec, /* FSSpec specifier */ FOUR_CHAR_CODE('TVOD'), /* file creator type, TVOD = QT player*/ smCurrentScript, /* movie script system to use */ createMovieFileDeleteCurFile /* movie file creation flags */ | createMovieFileDontCreateResFile, &sResRefNum, /* returned file ref num to data fork */ &movie /* returned handle to open empty movie*/ /* that references the created file */ ); if (osErr) { printf ("CreateMovieFile failed %d/n", osErr); goto bail; } /* Step 2: Add a new track to that movie (NewMovieTrack). ======================================================= */ track = NewMovieTrack ( movie, /* the movie to add track to */ ((long) w << 16), /* width of track in pixels (Fixed) */ FixRatio (h, 1), /* height of track in pixels (Fixed) */ kNoVolume /* default volume level */ ); osErr = GetMoviesError (); if (osErr) { printf ("NewMovieTrack failed %d/n", osErr); goto bail; } /* Step 3: Add a new media to that track (NewTrackMedia). ======================================================= */ media = NewTrackMedia ( track, /* the track to add the media to */ VideoMediaType, /* media type, e.g. SoundMediaType */ 600, /* num media time units that elapse/sec*/ NULL, /* ptr to file that holds media sampls*/ 0 /* type of ptr to media samples */ ); osErr = GetMoviesError (); if (osErr) { printf ("NewTrackMedia failed %d/n", osErr); goto bail; //.........这里部分代码省略.........
开发者ID:jphutson,项目名称:dynamic-images-and-eye-movements,代码行数:101,
示例26: Q_D//.........这里部分代码省略......... if (file == AbsolutePathName) { int slash = ret.lastIndexOf(QLatin1Char('/')); if (slash == -1) return QDir::currentPath(); else if (!slash) return QLatin1String("/"); return ret.left(slash); } return ret; } else if (file == CanonicalName || file == CanonicalPathName) { if (!(fileFlags(ExistsFlag) & ExistsFlag)) return QString(); QString ret = QFSFileEnginePrivate::canonicalized(fileName(AbsoluteName)); if (!ret.isEmpty() && file == CanonicalPathName) { int slash = ret.lastIndexOf(QLatin1Char('/')); if (slash == -1) ret = QDir::currentPath(); else if (slash == 0) ret = QLatin1String("/"); ret = ret.left(slash); } return ret; } else if (file == LinkName) { if (d->isSymlink()) {#if defined(__GLIBC__) && !defined(PATH_MAX)#define PATH_CHUNK_SIZE 256 char *s = 0; int len = -1; int size = PATH_CHUNK_SIZE; while (1) { s = (char *) ::realloc(s, size); if (s == 0) { len = -1; break; } len = ::readlink(d->nativeFilePath.constData(), s, size); if (len < 0) { ::free(s); break; } if (len < size) { break; } size *= 2; }#else char s[PATH_MAX+1]; int len = readlink(d->nativeFilePath.constData(), s, PATH_MAX);#endif if (len > 0) { QString ret; if (S_ISDIR(d->st.st_mode) && s[0] != '/') { QDir parent(d->filePath); parent.cdUp(); ret = parent.path(); if (!ret.isEmpty() && !ret.endsWith(QLatin1Char('/'))) ret += QLatin1Char('/'); } s[len] = '/0'; ret += QFile::decodeName(QByteArray(s));#if defined(__GLIBC__) && !defined(PATH_MAX) ::free(s);#endif if (!ret.startsWith(QLatin1Char('/'))) { if (d->filePath.startsWith(QLatin1Char('/'))) { ret.prepend(d->filePath.left(d->filePath.lastIndexOf(QLatin1Char('/'))) + QLatin1Char('/')); } else { ret.prepend(QDir::currentPath() + QLatin1Char('/')); } } ret = QDir::cleanPath(ret); if (ret.size() > 1 && ret.endsWith(QLatin1Char('/'))) ret.chop(1); return ret; } }#if !defined(QWS) && defined(Q_OS_MAC) { FSRef fref; if (FSPathMakeRef((const UInt8 *)QFile::encodeName(QDir::cleanPath(d->filePath)).data(), &fref, 0) == noErr) { Boolean isAlias, isFolder; if (FSResolveAliasFile(&fref, true, &isFolder, &isAlias) == noErr && isAlias) { AliasHandle alias; if (FSNewAlias(0, &fref, &alias) == noErr && alias) { CFStringRef cfstr; if (FSCopyAliasInfo(alias, 0, 0, &cfstr, 0, 0) == noErr) return QCFString::toQString(cfstr); } } } }#endif return QString(); } return d->filePath;}
开发者ID:FilipBE,项目名称:qtextended,代码行数:101,
示例27: process_spawn//.........这里部分代码省略......... } if( proc->pipeout ) pipe_close_write( proc->pipeout ); if( proc->pipein ) pipe_close_read( proc->pipein ); } wstring_deallocate( wcmdline ); wstring_deallocate( wwd ); string_deallocate( cmdline ); if( proc->code < 0 ) return proc->code; //Error#endif#if FOUNDATION_PLATFORM_MACOSX if( proc->flags & PROCESS_OSX_USE_OPENAPPLICATION ) { proc->pid = 0; LSApplicationParameters params; ProcessSerialNumber psn; FSRef* fsref = memory_allocate( 0, sizeof( FSRef ), 0, MEMORY_TEMPORARY | MEMORY_ZERO_INITIALIZED ); memset( ¶ms, 0, sizeof( LSApplicationParameters ) ); memset( &psn, 0, sizeof( ProcessSerialNumber ) ); char* pathstripped = string_strip( string_clone( proc->path ), "/"" ); OSStatus status = 0; status = FSPathMakeRef( (uint8_t*)pathstripped, fsref, 0 ); if( status < 0 ) { pathstripped = string_append( pathstripped, ".app" ); status = FSPathMakeRef( (uint8_t*)pathstripped, fsref, 0 ); } CFStringRef* args = 0; for( i = 0, size = array_size( proc->args ); i < size; ++i ) //App gets executable path automatically, don't include array_push( args, CFStringCreateWithCString( 0, proc->args[i], kCFStringEncodingUTF8 ) ); CFArrayRef argvref = CFArrayCreate( 0, (const void**)args, (CFIndex)array_size( args ), 0 ); params.flags = kLSLaunchDefaults; params.application = fsref; params.argv = argvref; log_debugf( 0, "Spawn process (LSOpenApplication): %s", pathstripped ); status = LSOpenApplication( ¶ms, &psn ); if( status != 0 ) { proc->code = status; log_warnf( 0, WARNING_BAD_DATA, "Unable to spawn process for executable '%s': %s", proc->path, system_error_message( status ) ); } CFRelease( argvref ); for( i = 0, size = array_size( args ); i < size; ++i ) CFRelease( args[i] ); memory_deallocate( fsref ); string_deallocate( pathstripped );
开发者ID:Jasper-Bekkers,项目名称:ProDBG,代码行数:66,
注:本文中的FSPathMakeRef函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ FSRefMakePath函数代码示例 C++ FSMakeFSSpec函数代码示例 |