本文整理汇总了C++中FSPathMakeRef函数的典型用法代码示例。如果您正苦于以下问题:C++ FSPathMakeRef函数的具体用法?C++ FSPathMakeRef怎么用?C++ FSPathMakeRef使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FSPathMakeRef函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: m_dirname
wxDirData::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 ;
}
示例3: promptForFolder
char* 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);
}
示例4: isLink
bool
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;
}
示例5: FSPathMakeFSSpec
OSStatus 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;
}
示例6: FSPathMakeRef
void 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;
}
}
示例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;
}
示例8: TRASH_CanTrashFile
BOOL 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);
}
示例9: wd_apple_resolve_alias
int 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;
}
示例10: defined
std::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);
}
示例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;
}
示例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
}
示例13: main
int 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;
}
示例14: myFSCreateResFile
static 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;
}
示例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;
}