⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ncbi_os_mac.cpp

📁 ncbi源码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/* * =========================================================================== * PRODUCTION $Log: ncbi_os_mac.cpp,v $ * PRODUCTION Revision 1000.1  2004/06/01 19:08:33  gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.8 * PRODUCTION * =========================================================================== *//*  $Id: ncbi_os_mac.cpp,v 1000.1 2004/06/01 19:08:33 gouriano Exp $ * =========================================================================== * *                            PUBLIC DOMAIN NOTICE *               National Center for Biotechnology Information * *  This software/database is a "United States Government Work" under the *  terms of the United States Copyright Act.  It was written as part of *  the author's official duties as a United States Government employee and *  thus cannot be copyrighted.  This software/database is freely available *  to the public for use. The National Library of Medicine and the U.S. *  Government have not placed any restriction on its use or reproduction. * *  Although all reasonable efforts have been taken to ensure the accuracy *  and reliability of the software and data, the NLM and the U.S. *  Government do not and cannot warrant the performance or results that *  may be obtained by using this software or data. The NLM and the U.S. *  Government disclaim all warranties, express or implied, including *  warranties of performance, merchantability or fitness for any particular *  purpose. * *  Please cite the author in any work or product based on this material. * * =========================================================================== * * Authors:  Jim Luther, Joshua Juran, Vlad Lebedev * * File Description: *   Mac specifics * *//* * NOTICE: Portions of this file have been taken and modified from * original sources provided as part of Apple's "MoreFiles" package * that carries the following copyright notice: * *    You may incorporate this sample code into your applications without *    restriction, though the sample code has been provided "AS IS" and the *    responsibility for its operation is 100% yours.  However, what you are *    not permitted to do is to redistribute the source as "DSC Sample Code" *    after having made changes. If you're going to re-distribute the source, *    we require that you make it clear in the source that the code was *    descended from Apple Sample Code, but that you've made changes. */#include <ncbi_pch.hpp>#include <TextUtils.h>#include <corelib/ncbi_os_mac.hpp>extern bool g_Mac_SpecialEnvironment = false;BEGIN_NCBI_SCOPE///////////////////////////////////////////////////////////////////////////////   COSErrException_Mac//static string s_OSErr_ComposeMessage(const OSErr& os_err, const string& what){    string message;    if ( !what.empty() ) {        message = what + ": ";    }    message += os_err;    return message;}COSErrException_Mac::COSErrException_Mac(const OSErr&  os_err,                                         const string& what) THROWS_NONE    : exception(), m_OSErr(os_err){    return;}COSErrException_Mac::~COSErrException_Mac(void) THROWS_NONE{    return;}static	OSErr	GetVolumeInfoNoName(ConstStr255Param pathname,									short vRefNum,									HParmBlkPtr pb){	Str255 tempPathname;	OSErr error;		/* Make sure pb parameter is not NULL */ 	if ( pb != NULL )	{		pb->volumeParam.ioVRefNum = vRefNum;		if ( pathname == NULL )		{			pb->volumeParam.ioNamePtr = NULL;			pb->volumeParam.ioVolIndex = 0;		/* use ioVRefNum only */		}		else		{			BlockMoveData(pathname, tempPathname, pathname[0] + 1);	/* make a copy of the string and */			pb->volumeParam.ioNamePtr = (StringPtr)tempPathname;	/* use the copy so original isn't trashed */			pb->volumeParam.ioVolIndex = -1;	/* use ioNamePtr/ioVRefNum combination */		}		error = PBHGetVInfoSync(pb);		pb->volumeParam.ioNamePtr = NULL;	/* ioNamePtr may point to local	tempPathname, so don't return it */	}	else	{		error = paramErr;	}	return ( error );}static	OSErr GetCatInfoNoName(short vRefNum,							   long dirID,							   ConstStr255Param name,							   CInfoPBPtr pb){	Str31 tempName;	OSErr error;		/* Protection against File Sharing problem */	if ( (name == NULL) || (name[0] == 0) )	{		tempName[0] = 0;		pb->dirInfo.ioNamePtr = tempName;		pb->dirInfo.ioFDirIndex = -1;	/* use ioDirID */	}	else	{		pb->dirInfo.ioNamePtr = (StringPtr)name;		pb->dirInfo.ioFDirIndex = 0;	/* use ioNamePtr and ioDirID */	}	pb->dirInfo.ioVRefNum = vRefNum;	pb->dirInfo.ioDrDirID = dirID;	error = PBGetCatInfoSync(pb);	pb->dirInfo.ioNamePtr = NULL;	return ( error );}static	OSErr	DetermineVRefNum(ConstStr255Param pathname,								 short vRefNum,								 short *realVRefNum){	HParamBlockRec pb;	OSErr error;	error = GetVolumeInfoNoName(pathname,vRefNum, &pb);	if ( error == noErr )	{		*realVRefNum = pb.volumeParam.ioVRefNum;	}	return ( error );}static	OSErr	GetDirectoryID(short vRefNum,							   long dirID,							   ConstStr255Param name,							   long *theDirID,							   Boolean *isDirectory){	CInfoPBRec pb;	OSErr error;	error = GetCatInfoNoName(vRefNum, dirID, name, &pb);	if ( error == noErr )	{		*isDirectory = (pb.hFileInfo.ioFlAttrib & kioFlAttribDirMask) != 0;		if ( *isDirectory )		{			*theDirID = pb.dirInfo.ioDrDirID;		}		else		{			*theDirID = pb.hFileInfo.ioFlParID;		}	}		return ( error );}extern	OSErr	FSpGetDirectoryID(const FSSpec *spec,								  long *theDirID,								  Boolean *isDirectory){	return ( GetDirectoryID(spec->vRefNum, spec->parID, spec->name,			 theDirID, isDirectory) );}static	OSErr	CheckObjectLock(short vRefNum,								long dirID,								ConstStr255Param name){	CInfoPBRec pb;	OSErr error;		error = GetCatInfoNoName(vRefNum, dirID, name, &pb);	if ( error == noErr )	{		/* check locked bit */		if ( (pb.hFileInfo.ioFlAttrib & kioFlAttribLockedMask) != 0 )		{			error = fLckdErr;		}	}		return ( error );}/*****************************************************************************/extern	OSErr	FSpCheckObjectLock(const FSSpec *spec){	return ( CheckObjectLock(spec->vRefNum, spec->parID, spec->name) );}static	OSErr	GetFileSize(short vRefNum,							long dirID,							ConstStr255Param fileName,							long *dataSize,							long *rsrcSize){	HParamBlockRec pb;	OSErr error;		pb.fileParam.ioNamePtr = (StringPtr)fileName;	pb.fileParam.ioVRefNum = vRefNum;	pb.fileParam.ioFVersNum = 0;	pb.fileParam.ioDirID = dirID;	pb.fileParam.ioFDirIndex = 0;	error = PBHGetFInfoSync(&pb);	if ( error == noErr )	{		*dataSize = pb.fileParam.ioFlLgLen;		*rsrcSize = pb.fileParam.ioFlRLgLen;	}		return ( error );}extern	OSErr	FSpGetFileSize(const FSSpec *spec,							   long *dataSize,							   long *rsrcSize){	return ( GetFileSize(spec->vRefNum, spec->parID, spec->name, dataSize, rsrcSize) );}extern	OSErr	GetDirItems(short vRefNum,							long dirID,							ConstStr255Param name,							Boolean getFiles,							Boolean getDirectories,							FSSpecPtr items,							short reqItemCount,							short *actItemCount,							short *itemIndex) /* start with 1, then use what's returned */{	CInfoPBRec pb;	OSErr error;	long theDirID;	Boolean isDirectory;	FSSpec *endItemsArray;		if ( *itemIndex > 0 )	{		/* NOTE: If I could be sure that the caller passed a real vRefNum and real directory */		/* to this routine, I could rip out calls to DetermineVRefNum and GetDirectoryID and this */		/* routine would be much faster because of the overhead of DetermineVRefNum and */		/* GetDirectoryID and because GetDirectoryID blows away the directory index hint the Macintosh */		/* file system keeps for indexed calls. I can't be sure, so for maximum throughput, */		/* pass a big array of FSSpecs so you can get the directory's contents with few calls */		/* to this routine. */				/* get the real volume reference number */		error = DetermineVRefNum(name, vRefNum, &pb.hFileInfo.ioVRefNum);		if ( error == noErr )		{			/* and the real directory ID of this directory (and make sure it IS a directory) */			error = GetDirectoryID(vRefNum, dirID, name, &theDirID, &isDirectory);			if ( error == noErr )			{				if ( isDirectory )				{					*actItemCount = 0;					endItemsArray = items + reqItemCount;					while ( (items < endItemsArray) && (error == noErr) )					{

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -