本文整理汇总了C++中FSMakeFSSpec函数的典型用法代码示例。如果您正苦于以下问题:C++ FSMakeFSSpec函数的具体用法?C++ FSMakeFSSpec怎么用?C++ FSMakeFSSpec使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FSMakeFSSpec函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetBasePath
void SetBasePath(void)
{
OSErr error;
FSSpec where;
//Handle theString;
Str255 name;
short vRef;
long dirID;
long nDirID;
error = FindFolder(kOnSystemDisk, kPreferencesFolderType, kDontCreateFolder, &vRef, &dirID);
GetIndString(name, kTransportPath, 1);
if (name[0] != '0') {
error = FSMakeFSSpec(vRef, dirID, name, &where); // First, check to see if the directory exists
if (error != noErr) {
// Create it
error = FSpDirCreate(&where, smSystemScript, &nDirID);
}
p2cstr(name);
strncat((char *)name, "Serial", 63); // It won't matter if this exists or not; we'll get the parent directory ID this way
c2pstr((char *)name);
error = FSMakeFSSpec(vRef, dirID, name, &where);
gvRef = where.vRefNum;
gparID = where.parID;
}
}
示例2: file_attr
short file_attr(const char *path) {
#ifdef TARGET_API_MAC_CARBON
Str255 fname;
FSSpec fss;
FSRef fsr;
FSCatalogInfo fsci;
short ret;
mkstr255(fname, path);
if ((FSMakeFSSpec(0, 0, fname, &fss) != noErr) ||
(FSpMakeFSRef(&fss, &fsr) != noErr) ||
(FSGetCatalogInfo(&fsr, kFSCatInfoNodeFlags, &fsci,
NULL, NULL, NULL) != noErr)) {
return(-1);
}
if (fsci.nodeFlags & kFSNodeIsDirectoryMask) {
ret = FILEATTR_DIRECTORY;
}
else {
ret = FILEATTR_ARCHIVE;
}
if (fsci.nodeFlags & kFSNodeLockedMask) {
ret |= FILEATTR_READONLY;
}
return(ret);
#else
Str255 fname;
FSSpec fss;
CInfoPBRec pb;
short ret;
mkstr255(fname, path);
FSMakeFSSpec(0, 0, fname, &fss);
pb.dirInfo.ioNamePtr = fss.name;
pb.dirInfo.ioVRefNum = fss.vRefNum;
pb.dirInfo.ioDrDirID = fss.parID;
if (fss.name[0] == 0) {
pb.dirInfo.ioFDirIndex = -1;
}
else {
pb.dirInfo.ioFDirIndex = 0;
}
if (PBGetCatInfo(&pb, false) != noErr) {
return(-1);
}
if (pb.hFileInfo.ioFlAttrib & ioDirMask) {
ret = FILEATTR_DIRECTORY;
}
else {
ret = FILEATTR_ARCHIVE;
}
if (pb.hFileInfo.ioFlAttrib & 0x01) {
ret |= FILEATTR_READONLY;
}
return(ret);
#endif
}
示例3: CleanTemp
void CleanTemp(void)
{
OSErr err = noErr;
short vRefNum;
long dirID;
FSSpec viewerFSp;
XPISpec *xpiList, *currXPI = 0, *nextXPI = 0;
#ifdef MIW_DEBUG
Boolean isDir = false;
#endif
#ifndef MIW_DEBUG
/* get "viewer" in "Temporary Items" folder */
ERR_CHECK(FindFolder(kOnSystemDisk, kTemporaryFolderType, kCreateFolder, &vRefNum, &dirID));
err = FSMakeFSSpec(vRefNum, dirID, kViewerFolder, &viewerFSp);
#else
/* for DEBUG builds temp is "<currProcessVolume>:Temp NSInstall:" */
ERR_CHECK(GetCWD(&dirID, &vRefNum));
err = FSMakeFSSpec(vRefNum, 0, kTempFolder, &viewerFSp);
if (err == fnfErr)
return; /* no debug temp exists */
err = FSpGetDirectoryID(&viewerFSp, &dirID, &isDir);
if (err != noErr || !isDir)
return;
err = FSMakeFSSpec(vRefNum, dirID, kViewerFolder, &viewerFSp);
#endif
/* whack the viewer folder if it exists */
if (err == noErr)
{
ERR_CHECK(DeleteDirectory(viewerFSp.vRefNum, viewerFSp.parID, viewerFSp.name));
}
/* clean out the zippies (.xpi's) */
xpiList = (XPISpec *) NewPtrClear(sizeof(XPISpec));
if (!xpiList)
return;
IterateDirectory(vRefNum, dirID, "\p", 1, CheckIfXPI, (void*)&xpiList);
if (xpiList)
{
currXPI = xpiList;
while(currXPI)
{
nextXPI = currXPI->next; /* save nextXPI before we blow away currXPI */
if (currXPI->FSp)
{
FSpDelete(currXPI->FSp);
DisposePtr((Ptr)currXPI->FSp);
}
DisposePtr((Ptr)currXPI);
currXPI = nextXPI;
}
}
}
示例4: FSMakeFSSpecFromPath
/* This function is an adaptation of the function FSpLocationFromPath in
tclMacUtils.c in the Tcl 8.0 distribution */
OSErr FSMakeFSSpecFromPath(ConstStr255Param fileName, FSSpecPtr spec)
{
Boolean isDir, wasAlias;
int pos, end;
OSErr err;
Str255 Name;
short vRefNum;
long dirID;
/* get the initial directory information and set up first path component */
CopyNamePart(Name, fileName, 1);
if (Name[0] < fileName[0] && Name[1] != ':') { /* absolute path */
Name[0]++;
Name[Name[0]] = ':';
if ((err = FSMakeFSSpec(0, 0, Name, spec)) != noErr)
return err;
if ((err = FSpGetDirectoryID(spec, &dirID, &isDir)) != noErr)
return err;
if (! isDir)
return dirNFErr;
vRefNum = spec->vRefNum;
pos = Name[0] + 1;
CopyNamePart(Name, fileName, pos);
}
else {
dirID = 0;
vRefNum = 0;
pos = 1;
isDir = true;
}
/* process remaining path parts */
end = fileName[0] + 1;
while (true) {
if ((err = FSMakeFSSpec(vRefNum, dirID, Name[0] == 0 ? NULL : Name,
spec)) != noErr ||
(err = ResolveAliasFile(spec, true, &isDir, &wasAlias)) != noErr)
return err;
pos += Name[0];
if (pos < end) {
if ((err = FSpGetDirectoryID(spec, &dirID, &isDir)) != noErr)
return err;
if (! isDir)
return dirNFErr;
vRefNum = spec->vRefNum;
CopyNamePart(Name, fileName, pos);
}
else
return noErr;
}
}
示例5: FSMakeFSSpecCompat
pascal OSErr FSMakeFSSpecCompat(short vRefNum,
long dirID,
ConstStr255Param fileName,
FSSpec *spec)
{
OSErr result;
#if !__MACOSSEVENORLATER
if ( !FSHasFSSpecCalls() && !QTHasFSSpecCalls() )
{
Boolean isDirectory;
result = GetObjectLocation(vRefNum, dirID, fileName,
&(spec->vRefNum), &(spec->parID), spec->name,
&isDirectory);
}
else
#endif /* !__MACOSSEVENORLATER */
{
/* Let the file system create the FSSpec if it can since it does the job */
/* much more efficiently than I can. */
result = FSMakeFSSpec(vRefNum, dirID, fileName, spec);
/* Fix a bug in Macintosh PC Exchange's MakeFSSpec code where 0 is */
/* returned in the parID field when making an FSSpec to the volume's */
/* root directory by passing a full pathname in MakeFSSpec's */
/* fileName parameter. Fixed in Mac OS 8.1 */
if ( (result == noErr) && (spec->parID == 0) )
spec->parID = fsRtParID;
}
return ( result );
}
示例6: preloadTransport
/*----------------------------------------------------------------------
Called internally to load a code fragment.
----------------------------------------------------------------------*/
OSErr preloadTransport(StringPtr transportName, CFragConnectionID* connID)
{
OSErr anErr;
FSSpec spec;
Ptr mainAddr;
Str255 errName;
Str255 fragName;
CFragSymbolClass symClass;
// we need to setup our function pointers for the selected
// transport. We do this by looking for a file with a code
// fragment and then we load all of the function pointers
// from it for later use throughout the application
// create a pascal string which is the file name which has the
// fragment in it
anErr = FSMakeFSSpec(gvRef, gparID, transportName, &spec);
if (anErr == noErr) {
anErr = GetDiskFragment(
&spec,
0,
kCFragGoesToEOF,
fragName,
kLoadCFrag,
connID,
&mainAddr,
errName
);
}
return anErr;
}
示例7: __PHYSFS_platformIsSymLink
int __PHYSFS_platformIsSymLink(const char *fname)
{
OSErr err;
FSSpec spec;
Boolean a = 0;
Boolean f = 0;
CInfoPBRec infoPB;
char *ptr;
char *dir = alloca(strlen(fname) + 1);
BAIL_IF_MACRO(dir == NULL, ERR_OUT_OF_MEMORY, 0);
strcpy(dir, fname);
ptr = strrchr(dir, ':');
if (ptr == NULL) /* just a volume name? Can't be a symlink. */
return(0);
/* resolve aliases up to the actual file... */
*ptr = '\0';
BAIL_IF_MACRO(fnameToFSSpec(dir, &spec) != noErr, NULL, 0);
*ptr = strlen(ptr + 1); /* ptr is now a pascal string. Yikes! */
memset(&infoPB, '\0', sizeof (CInfoPBRec));
infoPB.dirInfo.ioNamePtr = spec.name;
infoPB.dirInfo.ioVRefNum = spec.vRefNum;
infoPB.dirInfo.ioDrDirID = spec.parID;
infoPB.dirInfo.ioFDirIndex = 0;
BAIL_IF_MACRO(oserr(PBGetCatInfoSync(&infoPB)) != noErr, NULL, 0);
err = FSMakeFSSpec(spec.vRefNum, infoPB.dirInfo.ioDrDirID,
(const unsigned char *) ptr, &spec);
BAIL_IF_MACRO(oserr(err) != noErr, NULL, 0);
BAIL_IF_MACRO(oserr(IsAliasFile(&spec, &a, &f)) != noErr, NULL, 0);
return(a);
} /* __PHYSFS_platformIsSymlink */
示例8: mkstr255
void *file_list1st(const char *dir, FLINFO *fli) {
FLISTH ret;
Str255 fname;
FSSpec fss;
FSRef fsr;
FSIterator fsi;
mkstr255(fname, dir);
if ((FSMakeFSSpec(0, 0, fname, &fss) != noErr) ||
(FSpMakeFSRef(&fss, &fsr) != noErr) ||
(FSOpenIterator(&fsr, kFSIterateFlat, &fsi) != noErr)) {
goto ff1_err1;
}
ret = _MALLOC(sizeof(_FLHDL), dir);
if (ret == NULL) {
goto ff1_err2;
}
((FLHDL)ret)->eoff = FALSE;
((FLHDL)ret)->fsi = fsi;
if (file_listnext(ret, fli) == SUCCESS) {
return(ret);
}
ff1_err2:
FSCloseIterator(fsi);
ff1_err1:
return(NULL);
}
示例9: LoadXPIStub
/*-------------------------------------------------------------------
* XPI Stub Load/Unload
*-------------------------------------------------------------------*/
OSErr
LoadXPIStub(XPI_InitProc* pfnInit, XPI_InstallProc* pfnInstall, XPI_ExitProc* pfnExit,
CFragConnectionID* connID, FSSpec& aTargetDir, Str255 errName)
{
OSErr err;
FSSpec fslib;
Str63 fragName = XPISTUB_DLL;
Ptr mainAddr, symAddr;
CFragSymbolClass symClass;
long tgtDirID;
Boolean isDir;
err = FSpGetDirectoryID( &aTargetDir, &tgtDirID, &isDir );
if (err!=noErr)
return err;
else if (!isDir)
return paramErr;
err = FSMakeFSSpec(aTargetDir.vRefNum, tgtDirID, fragName, &fslib);
if (err!=noErr)
return err;
err = GetDiskFragment(&fslib, 0, kCFragGoesToEOF, nil, /*kPrivateCFragCopy*/kReferenceCFrag, connID, &mainAddr, errName);
if ( err == noErr && *connID != NULL)
{
ERR_CHECK_RET( FindSymbol(*connID, "\pXPI_Init", &symAddr, &symClass), err );
*pfnInit = (XPI_InitProc) symAddr;
ERR_CHECK_RET( FindSymbol(*connID, "\pXPI_Install", &symAddr, &symClass), err);
*pfnInstall = (XPI_InstallProc) symAddr;
ERR_CHECK_RET( FindSymbol(*connID, "\pXPI_Exit", &symAddr, &symClass), err);
*pfnExit = (XPI_ExitProc) symAddr;
}
示例10: SaveDriverState
/*__________________________________________________________________________*/
Boolean SaveDriverState (short refnum, StringPtr file, OSType creator, OSType type)
{
FSSpec spec; OSErr err; TDriverInfos dInfos;
long size, dirID; short vrefNum, ref;
Ptr ptr;
if (FindMidiShareFolder (true, &vrefNum, &dirID) != noErr) return false;
if (!MidiGetDriverInfos (refnum, &dInfos)) return false;
size = Get1DriverStateSize (dInfos.slots);
if (!size) return true;
ptr = NewPtrSys(size);
if (!ptr) return false;
Get1DriverState (refnum, dInfos.slots, ptr, size);
err = FSMakeFSSpec(vrefNum, dirID, file, &spec);
if (err == fnfErr)
err = FSpCreate (&spec, creator, type, smSystemScript);
if (err != noErr) goto err;
err = FSpOpenDF (&spec, fsWrPerm, &ref);
if (err != noErr) goto err;
err = FSWrite (ref, &size, ptr);
FSClose (ref);
DisposePtr (ptr);
return err == noErr;
err:
DisposePtr (ptr);
return false;
}
示例11: vr_findVerRegName
extern char* vr_findVerRegName()
{
FSSpec regSpec;
OSErr err;
short foundVRefNum;
long foundDirID;
int bCreate = 0;
/* quick exit if we have the info */
if ( verRegName != NULL )
return verRegName;
err = FindFolder(kOnSystemDisk,'pref', false, &foundVRefNum, &foundDirID);
if (err == noErr)
{
err = FSMakeFSSpec(foundVRefNum, foundDirID, MAC_VERREG, ®Spec);
if (err == -43) /* if file doesn't exist */
{
err = FSpCreate(®Spec, 'MOSS', 'REGS', smSystemScript);
bCreate = 1;
}
if (err == noErr)
{
Handle thePath;
short pathLen;
err = FSpGetFullPath(®Spec, &pathLen, &thePath);
if (err == noErr && thePath)
{
/* we have no idea if this moves memory, so better lock the handle */
#if defined(STANDALONE_REGISTRY) || defined(USE_STDIO_MODES)
HLock(thePath);
verRegName = (char *)XP_ALLOC(pathLen + 1);
XP_STRNCPY(verRegName, *thePath, pathLen);
verRegName[pathLen] = '\0';
#else
/* Since we're now using NSPR, this HAS to be a unix path! */
const char* src;
char* dst;
HLock(thePath);
verRegName = (char*)XP_ALLOC(pathLen + 2);
src = *(char**)thePath;
dst = verRegName;
*dst++ = '/';
while (pathLen--)
{
char c = *src++;
*dst++ = (c == ':') ? '/' : c;
}
*dst = '\0';
#endif
}
DisposeHandle(thePath);
}
}
return verRegName;
}
示例12: GetSharedLibraryFilterProc
static pascal void
GetSharedLibraryFilterProc(const CInfoPBRec* const inCpb, Boolean* inWantQuit, void *inFilterData)
{
GetSharedLibraryFilterProcData* pFilterData = (GetSharedLibraryFilterProcData*) inFilterData;
if ((inCpb->hFileInfo.ioFlAttrib & (1 << ioDirFlg)) == 0)
{
FSSpec fragSpec;
OSErr tempErr;
Str255 errName;
Boolean crap;
UInt32 codeOffset;
UInt32 codeLength;
// it's a file
// ¥ fix-me do we really want to allow all 'APPL's' for in which to find this library?
switch (inCpb->hFileInfo.ioFlFndrInfo.fdType)
{
case kCFragLibraryFileType:
case 'APPL':
tempErr = FSMakeFSSpec(inCpb->hFileInfo.ioVRefNum, inCpb->hFileInfo.ioFlParID, inCpb->hFileInfo.ioNamePtr, &fragSpec);
// this shouldn't fail
if (noErr != tempErr)
{
return;
}
// resolve an alias if this was one
tempErr = ResolveAliasFile(&fragSpec, true, &crap, &crap);
// if got here we have a shlb (or app-like shlb)
if (noErr != tempErr)
{
// probably couldn't resolve an alias
return;
}
break;
default:
return;
}
// see if this symbol is in this fragment
if (LibInPefContainer(&fragSpec, pFilterData->inName, &codeOffset, &codeLength))
tempErr = GetDiskFragment(&fragSpec, codeOffset, codeLength, fragSpec.name, kLoadCFrag, &pFilterData->outID, &pFilterData->outAddress, errName);
else
return;
// stop if we found a library by that name
if (noErr == tempErr)
{
*inWantQuit = true;
pFilterData->outFound = true;
pFilterData->outError = tempErr;
}
}
// FSpIterateDirectory will automagically call us for subsequent sub-dirs if necessary
}
示例13: opendir
DIR *
opendir (const char *name) /* Open a directory stream on NAME. */
/* Return a DIR stream on the directory, or NULL if it could not be opened. */
{
CInfoPBRec cat_info;
FSSpec spec;
Boolean targetIsFolder, wasAliased;
if (indx) { // We don't support more than one dir open at a time
closedir((DIR *)1); // Fail hard
return((DIR *)0);
}
dir_volume=0; // Default to the application directory
dir_ID=0;
while (name[0]=='.') ++name; // Don't allow leading '.', avoids device names
CToPCpy(fname,name);
if (!FSMakeFSSpec(0,0,fname,&spec)) { // Figure out where user is pointing
ResolveAliasFile(&spec, true, &targetIsFolder, &wasAliased);
cat_info.dirInfo.ioCompletion=(IOCompletionUPP)0;
cat_info.dirInfo.ioNamePtr=spec.name;
cat_info.dirInfo.ioVRefNum=spec.vRefNum;
cat_info.dirInfo.ioFDirIndex = 0; // Use full spec
cat_info.dirInfo.ioDrDirID=spec.parID;
cat_info.dirInfo.ioFVersNum=0;
if (!PBGetCatInfoSync(&cat_info) && (cat_info.dirInfo.ioFlAttrib&16))
spec.parID=cat_info.dirInfo.ioDrDirID; // Found it, save it's volume and dirID
dir_volume=spec.vRefNum;
dir_ID=spec.parID;
}
else return ((DIR *)0);
indx=1;
return((DIR *)1);
}
示例14: ExtractSingleItem
/* This function extracts a single FSRef from a NavReplyRecord. */
static OSErr ExtractSingleItem(const NavReplyRecord *reply, FSRef *item)
{
FSSpec fss;
SInt32 itemCount;
DescType junkType;
AEKeyword junkKeyword;
Size junkSize;
OSErr osErr;
osErr = AECountItems(&reply->selection, &itemCount);
if( itemCount != 1 ) /* we only work with one object at a time */
osErr = paramErr;
if( osErr == noErr )
osErr = AEGetNthPtr(&reply->selection, 1, typeFSS, &junkKeyword, &junkType, &fss, sizeof(fss), &junkSize);
if( osErr == noErr )
{
mycheck(junkType == typeFSS);
mycheck(junkSize == sizeof(FSSpec));
/* We call FSMakeFSSpec because sometimes Nav is braindead */
/* and gives us an invalid FSSpec (where the name is empty). */
/* While FSpMakeFSRef seems to handle that (and the file system */
/* engineers assure me that that will keep working (at least */
/* on traditional Mac OS) because of the potential for breaking */
/* existing applications), I'm still wary of doing this so */
/* I regularise the FSSpec by feeding it through FSMakeFSSpec. */
if( fss.name[0] == 0 )
osErr = FSMakeFSSpec(fss.vRefNum, fss.parID, fss.name, &fss);
if( osErr == noErr )
osErr = FSpMakeFSRef(&fss, item);
}
return osErr;
}
示例15: getCurrentResourceFSSpec
// --------------------------------------------------------------------------------------
static OSErr getCurrentResourceFSSpec(FSSpec *curResSpec)
{
OSErr error;
FCBPBPtr fileInfo; // file control block parameter block pointer
StrFileName fileName;
/* In the age of application packages and bundles, it's less likely that the
current resource file is the application file itself. It's more likely to be
a flattened resource file in a bundle so we need a generic method instead of
the traditional Process Manager method of getting the current application's
FSSpec of it's executable file */
fileInfo = (FCBPBPtr)NewPtr(sizeof(FCBPBRec));
fileInfo->ioNamePtr = fileName; // to hold the resource file's name
fileInfo->ioVRefNum = 0; // 0 to search through all open files on all volumes
fileInfo->ioRefNum = CurResFile(); // get info about the main resource file
// by using its reference number
fileInfo->ioFCBIndx = 0; // 0 to ignore this parameter and use the
// ioRefNum parameter instead
error = PBGetFCBInfoSync(fileInfo); // synchronous because we don't have
// anything else to do while we're waiting on the filesystem
if (error == noErr) // if we got the necessary file info, make an FSSpec out of it
FSMakeFSSpec(fileInfo->ioFCBVRefNum, fileInfo->ioFCBParID, fileName, curResSpec);
DisposePtr((Ptr)fileInfo);
return error;
}