📄 macstuff.h
字号:
#ifndef _MACSTUFF_H#define _MACSTUFF_H 1/*These Functions are part of MoreFiles version 1.4.8More Files fixes many of the broken or underfunctionalparts of the file system.MoreFilesA collection of File Manager and related routinesby Jim Luther (Apple Macintosh Developer Technical Support Emeritus)with significant code contributions by Nitin Ganatra(Apple Macintosh Developer Technical Support Emeritus)Copyright 1992-1998 Apple Computer, Inc.Portions copyright 1995 Jim LutherAll rights reserved.More Files can be found on the MetroWerks CD and Developer CD fromApple. You can also down load the latest version from: http://members.aol.com/JumpLong/MoreFiles_1.4.7.sit.hqxJim Luther's Home-page: http://members.aol.com/JumpLong/I'm including the files in the Info-Zip project directly.(see macstuff.c / macstuff.h)*/#define __MACOSSEVENFIVEONEORLATER 1#define __MACOSSEVENFIVEORLATER 1#define __MACOSSEVENORLATER 1#include <Errors.h>#include <Files.h>/* * Like the MoreFiles routines these fix problems in the standard * Mac calls. */int FSpLocationFromPath (int length,const char *path, FSSpecPtr theSpec);OSErr FSpPathFromLocation (FSSpecPtr theSpec,int *length, Handle *fullPath);#define hasDesktopMgr(volParms) (((volParms).vMAttrib & (1L << bHasDesktopMgr)) != 0)/* * The following routines are utility functions. They are exported * here because they are needed and they are not officially supported, * however. The first set are from the MoreFiles package. */int FSpGetDefaultDir (FSSpecPtr theSpec);int FSpSetDefaultDir (FSSpecPtr dirSpec);pascal OSErr FSpGetDirectoryID(const FSSpec *spec,long *theDirID, Boolean *isDirectory);pascal short FSpOpenResFileCompat(const FSSpec *spec, SignedByte permission);pascal void FSpCreateResFileCompat(const FSSpec *spec,OSType creator, OSType fileType, ScriptCode scriptTag);OSErr FSpFindFolder (short vRefNum, OSType folderType, Boolean createFolder, FSSpec *spec);/*****************************************************************************/pascal OSErr GetVolumeInfoNoName(ConstStr255Param pathname, short vRefNum, HParmBlkPtr pb);/* Call PBHGetVInfoSync ignoring returned name. GetVolumeInfoNoName uses pathname and vRefNum to call PBHGetVInfoSync in cases where the returned volume name is not needed by the caller. The pathname and vRefNum parameters are not touched, and the pb parameter is initialized by PBHGetVInfoSync except that ioNamePtr in the parameter block is always returned as NULL (since it might point to GetVolumeInfoNoName's local variable tempPathname). I noticed using this code in several places, so here it is once. This reduces the code size of MoreFiles. pathName input: Pointer to a full pathname or nil. If you pass in a partial pathname, it is ignored. A full pathname to a volume must end with a colon character (:). vRefNum input: Volume specification (volume reference number, working directory number, drive number, or 0). pb input: A pointer to HParamBlockRec. output: The parameter block as filled in by PBHGetVInfoSync except that ioNamePtr will always be NULL. Result Codes noErr 0 No error nsvErr -35 No such volume paramErr -50 No default volume, or pb was NULL*//*****************************************************************************/pascal OSErr GetFilenameFromPathname(ConstStr255Param pathname, Str255 filename);/* Get the object name from the end of a full or partial pathname. The GetFilenameFromPathname function gets the file (or directory) name from the end of a full or partial pathname. Returns notAFileErr if the pathname is nil, the pathname is empty, or the pathname cannot refer to a filename (with a noErr result, the pathname could still refer to a directory). pathname input: A full or partial pathname. filename output: The file (or directory) name. Result Codes noErr 0 No error notAFileErr -1302 The pathname is nil, the pathname is empty, or the pathname cannot refer to a filename __________ See also: GetObjectLocation.*//*****************************************************************************/pascal OSErr FSMakeFSSpecCompat(short vRefNum, long dirID, ConstStr255Param fileName, FSSpec *spec);/* Initialize a FSSpec record. The FSMakeFSSpecCompat function fills in the fields of an FSSpec record. If the file system can't create the FSSpec, then the compatibility code creates a FSSpec that is exactly like an FSSpec except that spec.name for a file may not have the same capitalization as the file's catalog entry on the disk volume. That is because fileName is parsed to get the name instead of getting the name back from the file system. This works fine with System 6 where FSMakeSpec isn't available. vRefNum input: Volume specification. dirID input: Directory ID. fileName input: Pointer to object name, or nil when dirID specifies a directory that's the object. spec output: A file system specification to be filled in by FSMakeFSSpecCompat. Result Codes noErr 0 No error nsvErr -35 Volume doesnt exist fnfErr -43 File or directory does not exist (FSSpec is still valid)*/#if !SystemSevenOrLaterstatic Boolean FSHasFSSpecCalls(void);static Boolean QTHasFSSpecCalls(void);#endif /* !SystemSevenOrLater *//*****************************************************************************/pascal OSErr GetObjectLocation(short vRefNum, long dirID, ConstStr255Param pathname, short *realVRefNum, long *realParID, Str255 realName, Boolean *isDirectory);/* Get a file system object's location. The GetObjectLocation function gets a file system object's location - that is, its real volume reference number, real parent directory ID, and name. While we're at it, determine if the object is a file or directory. If GetObjectLocation returns fnfErr, then the location information returned is valid, but it describes an object that doesn't exist. You can use the location information for another operation, such as creating a file or directory. vRefNum input: Volume specification. dirID input: Directory ID. pathname input: Pointer to object name, or nil when dirID specifies a directory that's the object. realVRefNum output: The real volume reference number. realParID output: The parent directory ID of the specified object. realName output: The name of the specified object (the case of the object name may not be the same as the object's catalog entry on disk - since the Macintosh file system is not case sensitive, it shouldn't matter). isDirectory output: True if object is a directory; false if object is a file. Result Codes noErr 0 No error nsvErr -35 No such volume ioErr -36 I/O error bdNamErr -37 Bad filename fnfErr -43 File not found paramErr -50 No default volume dirNFErr -120 Directory not found or incomplete pathname notAFileErr -1302 The pathname is nil, the pathname is empty, or the pathname cannot refer to a filename afpAccessDenied -5000 User does not have the correct access afpObjectTypeErr -5025 Directory not found or incomplete pathname __________ See also: FSMakeFSSpecCompat*/pascal OSErr FSpGetDirectoryID(const FSSpec *spec, long *theDirID, Boolean *isDirectory);pascal OSErr GetDirectoryID(short vRefNum,long dirID,ConstStr255Param name, long *theDirID,Boolean *isDirectory);/*****************************************************************************/pascal OSErr GetCatInfoNoName(short vRefNum, long dirID, ConstStr255Param name, CInfoPBPtr pb);/* Call PBGetCatInfoSync ignoring returned name. GetCatInfoNoName uses vRefNum, dirID and name to call PBGetCatInfoSync in cases where the returned object is not needed by the caller. The vRefNum, dirID and name parameters are not touched, and the pb parameter is initialized by PBGetCatInfoSync except that ioNamePtr in the parameter block is always returned as NULL (since it might point to GetCatInfoNoName's local variable tempName). I noticed using this code in several places, so here it is once. This reduces the code size of MoreFiles. vRefNum input: Volume specification. dirID input: Directory ID. name input: Pointer to object name, or nil when dirID specifies a directory that's the object. pb input: A pointer to CInfoPBRec. output: The parameter block as filled in by PBGetCatInfoSync except that ioNamePtr will always be NULL. Result Codes noErr 0 No error nsvErr -35 No such volume ioErr -36 I/O error bdNamErr -37 Bad filename fnfErr -43 File not found paramErr -50 No default volume dirNFErr -120 Directory not found or incomplete pathname afpAccessDenied -5000 User does not have the correct access afpObjectTypeErr -5025 Directory not found or incomplete pathname*//*****************************************************************************/pascal OSErr DetermineVRefNum(ConstStr255Param pathname, short vRefNum, short *realVRefNum);/* Determine the real volume reference number. The DetermineVRefNum function determines the volume reference number of a volume from a pathname, a volume specification, or a combination of the two. WARNING: Volume names on the Macintosh are *not* unique -- Multiple mounted volumes can have the same name. For this reason, the use of a volume name or full pathname to identify a specific volume may not produce the results you expect. If more than one volume has the same name and a volume name or full pathname is used, the File Manager currently uses the first volume it finds with a matching name in the volume queue. pathName input: Pointer to a full pathname or nil. If you pass in a partial pathname, it is ignored. A full pathname to a volume must end with a colon character (:). vRefNum input: Volume specification (volume reference number, working directory number, drive number, or 0). realVRefNum output: The real volume reference number. Result Codes noErr 0 No error nsvErr -35 No such volume paramErr -50 No default volume*//*****************************************************************************/pascal OSErr FSpGetFullPath(const FSSpec *spec, short *fullPathLength, Handle *fullPath);/* Get a full pathname to a volume, directory or file. The GetFullPath function builds a full pathname to the specified object. The full pathname is returned in the newly created handle fullPath and the length of the full pathname is returned in fullPathLength. Your program is responsible for disposing of the fullPath handle. spec input: An FSSpec record specifying the object. fullPathLength output: The number of characters in the full pathname. If the function fails to create a full pathname, it sets fullPathLength to 0. fullPath output: A handle to the newly created full pathname buffer. If the function fails to create a full pathname, it sets fullPath to NULL. Result Codes noErr 0 No error nsvErr -35 No such volume ioErr -36 I/O error bdNamErr -37 Bad filename fnfErr -43 File or directory does not exist paramErr -50 No default volume memFullErr -108 Not enough memory dirNFErr -120 Directory not found or incomplete pathname afpAccessDenied -5000 User does not have the correct access afpObjectTypeErr -5025 Directory not found or incomplete pathname __________ See also: GetFullPath*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -