• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ psp函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中psp函数的典型用法代码示例。如果您正苦于以下问题:C++ psp函数的具体用法?C++ psp怎么用?C++ psp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了psp函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: sptrace_clear

void	sptrace_clear(PsmPartition trace)
{
	PsmAddress	traceHeaderAddress;
	TraceHeader	*trh;
	PsmAddress	elt;
	PsmAddress	nextElt;
	PsmAddress	itemAddress;
	TraceItem	*item;

	if (!trace) return;
	traceHeaderAddress = psm_get_root(trace);
	trh = (TraceHeader *) psp(trace, traceHeaderAddress);
	CHKVOID(trh);
	for (elt = sm_list_first(trace, trh->log); elt; elt = nextElt)
	{
		nextElt = sm_list_next(trace, elt);
		itemAddress = sm_list_data(trace, elt);
		item = (TraceItem *) psp(trace, itemAddress);
		CHKVOID(item);
		if (item->opType == OP_ALLOCATE || item->opType == OP_FREE)
		{
			if (item->refOpNbr == 0)
			{
				continue;	/*	Not matched.	*/
			}

			/*	Delete matched activity from log.	*/

			psm_free(trace, itemAddress);
			CHKVOID(sm_list_delete(trace, elt, NULL, NULL) == 0);
		}
	}
}
开发者ID:NASAHackTO,项目名称:ion-dtn,代码行数:33,代码来源:sptrace.c


示例2: sm_rbt_last

PsmAddress	sm_rbt_last(PsmPartition partition, PsmAddress rbt)
{
	SmRbt		*rbtPtr;
	PsmAddress	node;
	PsmAddress	last = 0;
	SmRbtNode	*nodePtr;

	CHKZERO(partition);
	CHKZERO(rbt);
	rbtPtr = (SmRbt *) psp(partition, rbt);
	CHKZERO(rbtPtr);
	if (lockSmrbt(rbtPtr) == ERROR)
	{
		return 0;
	}

	node = rbtPtr->root;
	while (node)
	{
		last = node;
		nodePtr = (SmRbtNode *) psp(partition, node);
		if (nodePtr == NULL)
		{
			putErrmsg("Corrupt red-black tree.", NULL);
			last = 0;
			break;
		}

		node = nodePtr->child[RIGHT];
	}

	unlockSmrbt(rbtPtr);
	return last;
}
开发者ID:NASAHackTO,项目名称:ion-dtn,代码行数:34,代码来源:smrbt.c


示例3: Sm_list_insert_after

PsmAddress	Sm_list_insert_after(const char *fileName, int lineNbr,
			PsmPartition partition, PsmAddress oldElt,
			PsmAddress data)
{
	SmListElt	*oldEltBuffer;
	PsmAddress	list;
	SmList		*listBuffer;

	CHKZERO(partition);
	CHKZERO(oldElt);
	oldEltBuffer = (SmListElt *) psp(partition, oldElt);
	CHKZERO(oldEltBuffer);
	if ((list = oldEltBuffer->list) == 0)
	{
		putErrmsg(_noListMsg(), NULL);
		return 0;
	}

	listBuffer = (SmList *) psp(partition, list);
	if (lockSmlist(listBuffer) == ERROR)
	{
		putErrmsg(_cannotLockMsg(), NULL);
		return 0;
	}

	return finishInsertingAfter(fileName, lineNbr, partition, oldElt,
			oldEltBuffer, list, listBuffer, data);
}
开发者ID:brnrc,项目名称:ion-dtn,代码行数:28,代码来源:smlist.c


示例4: Sm_rbt_traverse

PsmAddress	Sm_rbt_traverse(PsmPartition partition, PsmAddress fromNode,
			int direction)
{
	SmRbtNode	*nodePtr;
	SmRbt		*rbtPtr;
	int		nextNode;

	CHKZERO(partition);
	CHKZERO(fromNode);
	nodePtr = (SmRbtNode *) psp(partition, fromNode);
	CHKZERO(nodePtr);
	rbtPtr = (SmRbt *) psp(partition, nodePtr->rbt);
	CHKZERO(rbtPtr);
	if (lockSmrbt(rbtPtr) == ERROR)
	{
		return 0;
	}

	if (direction != LEFT)
	{
		direction = RIGHT;
	}

	nextNode = traverseRbt(partition, fromNode, direction);
	unlockSmrbt(rbtPtr);
	return nextNode;
}
开发者ID:NASAHackTO,项目名称:ion-dtn,代码行数:27,代码来源:smrbt.c


示例5: rotateOnce

static PsmAddress	rotateOnce(PsmPartition partition, PsmAddress root,
				int direction)
{
	int		otherDirection = 1 - direction;
	SmRbtNode	*rootPtr;
	PsmAddress	pivot;
	SmRbtNode	*pivotPtr;
	PsmAddress	orphan;
	SmRbtNode	*orphanPtr;

	rootPtr = (SmRbtNode *) psp(partition, root);
	pivot = rootPtr->child[otherDirection];
	pivotPtr = (SmRbtNode *) psp(partition, pivot);
	orphan = pivotPtr->child[direction];
	orphanPtr = (SmRbtNode *) psp(partition, orphan);
	pivotPtr->parent = rootPtr->parent;
	pivotPtr->child[direction] = root;
	pivotPtr->isRed = 0;
	rootPtr->parent = pivot;
	rootPtr->child[otherDirection] = orphan;
	rootPtr->isRed = 1;
	if (orphan)
	{
		orphanPtr->parent = root;
	}

	return pivot;
}
开发者ID:NASAHackTO,项目名称:ion-dtn,代码行数:28,代码来源:smrbt.c


示例6: applyRateControl

static void	applyRateControl(Sdr sdr)
{
	BpVdb		*vdb = getBpVdb();
	PsmPartition	ionwm = getIonwm();
	Throttle	*throttle;
	PsmAddress	elt;
	VInduct		*induct;
	VOutduct	*outduct;
	long		capacityLimit;

	sdr_begin_xn(sdr);	/*	Just to lock memory.		*/

	/*	Recalculate limit on local bundle generation.		*/

	manageProductionThrottle(vdb);

	/*	Enable some bundle acquisition.				*/

	for (elt = sm_list_first(ionwm, vdb->inducts); elt;
			elt = sm_list_next(ionwm, elt))
	{
		induct = (VInduct *) psp(ionwm, sm_list_data(ionwm, elt));
		throttle = &(induct->acqThrottle);
		capacityLimit = throttle->nominalRate << 1;
		throttle->capacity += throttle->nominalRate;
		if (throttle->capacity > capacityLimit)
		{
			throttle->capacity = capacityLimit;
		}

		if (throttle->capacity > 0)
		{
			sm_SemGive(throttle->semaphore);
		}
	}

	/*	Enable some bundle transmission.			*/

	for (elt = sm_list_first(ionwm, vdb->outducts); elt;
			elt = sm_list_next(ionwm, elt))
	{
		outduct = (VOutduct *) psp(ionwm, sm_list_data(ionwm, elt));
		throttle = &(outduct->xmitThrottle);
		capacityLimit = throttle->nominalRate << 1;
		throttle->capacity += throttle->nominalRate;
		if (throttle->capacity > capacityLimit)
		{
			throttle->capacity = capacityLimit;
		}

		if (throttle->capacity > 0)
		{
			sm_SemGive(throttle->semaphore);
		}
	}

	sdr_exit_xn(sdr);	/*	Unlock memory.			*/
}
开发者ID:b,项目名称:ION,代码行数:58,代码来源:bpclock.c


示例7: postProbeEvent

PsmAddress	postProbeEvent(IonNode *node, Embargo *embargo)
{
	PsmPartition	ionwm = getIonwm();
	PsmAddress	addr;
	IonProbe	*probe;
	IonVdb		*ionvdb;
	IonNeighbor	*neighbor;
	PsmAddress	nextElt;
	unsigned int	rtlt;		/*	Round-trip light time.	*/
	int		interval = 6;	/*	Minimum 6-sec interval.	*/
	PsmAddress	elt;
	IonProbe	*pr;

	CHKZERO(node);
	CHKZERO(embargo);
	addr = psm_zalloc(ionwm, sizeof(IonProbe));
	if (addr == 0)
	{
		putErrmsg("Can't create probe event.", NULL);
		return 0;
	}

	probe = (IonProbe *) psp(ionwm, addr);
	CHKZERO(probe);
	probe->time = getUTCTime();
	probe->destNodeNbr = node->nodeNbr;
	probe->neighborNodeNbr = embargo->nodeNbr;

	/*	Schedule next probe of this embargoed neighbor for the
	 *	time that is the current time plus 2x the round-trip
	 *	light time from the local node to the neighbor (but
	 *	at least 6 seconds).					*/
	 
	ionvdb = getIonVdb();
	neighbor = findNeighbor(ionvdb, embargo->nodeNbr, &nextElt);
	if (neighbor)
	{
		rtlt = (neighbor->owltOutbound + neighbor->owltInbound) << 1;
		if (rtlt > interval)
		{
			interval = rtlt;
		}
	}

	probe->time += interval;
	for (elt = sm_list_last(ionwm, ionvdb->probes); elt;
			elt = sm_list_prev(ionwm, elt))
	{
		pr = (IonProbe *) psp(ionwm, sm_list_data(ionwm, elt));
		CHKZERO(pr);
		if (pr->time <= probe->time)
		{
			return sm_list_insert_after(ionwm, elt, addr);
		}
	}

	return sm_list_insert_first(ionwm, ionvdb->probes, addr);
}
开发者ID:michirod,项目名称:cgr-jni,代码行数:58,代码来源:rfx.c


示例8: Sm_list_insert

PsmAddress	Sm_list_insert(const char *fileName, int lineNbr,
			PsmPartition partition, PsmAddress list,
			PsmAddress data, SmListCompareFn compare, void *argData)
{
	SmList		*listBuffer;
	PsmAddress	elt;
	SmListElt	*eltBuffer;

	if (compare == (SmListCompareFn) NULL)
	{
		/*	List is assumed to be unsorted.  We simply
			add the new element at the end of the list.	*/

		return Sm_list_insert_last(fileName, lineNbr, partition,
				list, data);
	}

	/*	Using user-specified comparison function.  List is
		assumed to be in sorted order.				*/

	CHKZERO(partition);
	CHKZERO(list);
	listBuffer = (SmList *) psp(partition, list);
	CHKZERO(listBuffer);
	if (lockSmlist(listBuffer) == ERROR)
	{
		putErrmsg(_cannotLockMsg(), NULL);
		return 0;
	}

	/*	Find position to insert new data into list.
		Start from end of list to keep sort stable;
		sort sequence is implicitly FIFO within key,
		i.e., we insert element AFTER the last element
		in the table with the same key value.			*/

	for (elt = listBuffer->last; elt != 0; elt = eltBuffer->prev)
	{
		eltBuffer = (SmListElt *) psp(partition, elt);
		CHKZERO(eltBuffer);
		if (compare(partition, eltBuffer->data, argData) <= 0)
		{
			break;
		}
	}

	/* insert into list */

	if (elt == 0)
	{
		return finishInsertingFirst(fileName, lineNbr, partition, list,
				listBuffer, data);
	}

	return finishInsertingAfter(fileName, lineNbr, partition, elt,
			eltBuffer, list, listBuffer, data);
}
开发者ID:brnrc,项目名称:ion-dtn,代码行数:57,代码来源:smlist.c


示例9: Sm_list_insert_before

PsmAddress	Sm_list_insert_before(const char *fileName, int lineNbr,
			PsmPartition partition, PsmAddress oldElt,
			PsmAddress data)
{
	SmListElt	*oldEltBuffer;
	PsmAddress	list;
	SmList		*listBuffer;
	PsmAddress	elt;
	SmListElt	*eltBuffer;

	CHKZERO(partition);
	CHKZERO(oldElt);
	oldEltBuffer = (SmListElt *) psp(partition, oldElt);
	CHKZERO(oldEltBuffer);
	if ((list = oldEltBuffer->list) == 0)
	{
		putErrmsg(_noListMsg(), NULL);
		return 0;
	}

	listBuffer = (SmList *) psp(partition, list);
	if (lockSmlist(listBuffer) == ERROR)
	{
		putErrmsg(_cannotLockMsg(), NULL);
		return 0;
	}

	elt = Psm_zalloc(fileName, lineNbr, partition, sizeof(SmListElt));
	if (elt == 0)
	{
		unlockSmlist(listBuffer);
		putErrmsg(_noSpaceForEltMsg(), NULL);
		return 0;
	}

	eltBuffer = (SmListElt *) psp(partition, elt);
	eraseListElt(eltBuffer);
	eltBuffer->list = list;
	eltBuffer->data = data;
	eltBuffer->prev = oldEltBuffer->prev;
	eltBuffer->next = oldElt;
	if (oldEltBuffer->prev != 0)
	{
		eltBuffer = (SmListElt *) psp(partition, oldEltBuffer->prev);
		CHKZERO(eltBuffer);
		eltBuffer->next = elt;
	}
	else
	{
		listBuffer->first = elt;
	}

	oldEltBuffer->prev = elt;
	listBuffer->length += 1;
	unlockSmlist(listBuffer);
	return elt;
}
开发者ID:brnrc,项目名称:ion-dtn,代码行数:57,代码来源:smlist.c


示例10: sptrace_log_free

void	sptrace_log_free(PsmPartition trace, unsigned long addr,
		char *fileName, int lineNbr)
{
	PsmAddress	elt;
	TraceItem	*item;
	TraceItem	*refitem;

	if (!trace) return;
	logEvent(trace, OP_FREE, addr, -1, NULL, fileName, lineNbr, &elt);
	if (elt)	/*	Event was logged.			*/
	{
		item = (TraceItem *) psp(trace, sm_list_data(trace, elt));

		/*	Find matching allocation, close it out.		*/

		elt = sm_list_prev(trace, elt);
		while (elt)
		{
			refitem = (TraceItem *) psp(trace,
					sm_list_data(trace, elt));
			CHKVOID(refitem);
			if (refitem->objectAddress != item->objectAddress)
			{
				elt = sm_list_prev(trace, elt);
				continue;
			}

			/*	Found match.				*/

			switch (refitem->opType)
			{
			case OP_MEMO:	/*	Ignore it.		*/
				elt = sm_list_prev(trace, elt);
				continue;

			case OP_FREE:	/*	Duplicate free.		*/
				return;
			}

			/*	Found most recent open allocation.	*/

			item->refTaskId = refitem->taskId;
			item->refFileName = refitem->fileName;
			item->refLineNbr = refitem->lineNbr;
			item->refOpNbr = refitem->opNbr;
			item->objectSize = refitem->objectSize;
			refitem->refTaskId = item->taskId;
			refitem->refFileName = item->fileName;
			refitem->refLineNbr = item->lineNbr;
			refitem->refOpNbr = item->opNbr;
			return;
		}
	}
}
开发者ID:NASAHackTO,项目名称:ion-dtn,代码行数:54,代码来源:sptrace.c


示例11: treeBroken

int	treeBroken(PsmPartition partition, PsmAddress rbt)
{
	SmRbt	*rbtPtr;

	rbtPtr = (SmRbt *) psp(partition, rbt);
	return (subtreeBlackHeight(partition, rbtPtr->root) == 0);
}
开发者ID:NASAHackTO,项目名称:ion-dtn,代码行数:7,代码来源:smrbt.c


示例12: DOS_FCBOpen

bool DOS_FCBOpen(Bit16u seg,Bit16u offset) { 
	DOS_FCB fcb(seg,offset);
	char shortname[DOS_FCBNAME];Bit16u handle;
	fcb.GetName(shortname);

	/* First check if the name is correct */
	Bit8u drive;
	char fullname[DOS_PATHLENGTH];
	if (!DOS_MakeName(shortname,fullname,&drive)) return false;
	
	/* Check, if file is already opened */
	for (Bit8u i=0;i<DOS_FILES;i++) {
		DOS_PSP psp(dos.psp());
		if (Files[i] && Files[i]->IsOpen() && Files[i]->IsName(fullname)) {
			handle = psp.FindEntryByHandle(i);
			if (handle==0xFF) {
				// This shouldnt happen
				LOG(LOG_FILES,LOG_ERROR)("DOS: File %s is opened but has no psp entry.",shortname);
				return false;
			}
			fcb.FileOpen((Bit8u)handle);
			return true;
		}
	}
	
	if (!DOS_OpenFile(shortname,OPEN_READWRITE,&handle)) return false;
	fcb.FileOpen((Bit8u)handle);
	return true;
}
开发者ID:Avin15,项目名称:dospad,代码行数:29,代码来源:dos_files.cpp


示例13: DOS_DuplicateEntry

bool DOS_DuplicateEntry(Bit16u entry,Bit16u * newentry) {
    // Dont duplicate console handles
    /*	if (entry<=STDPRN) {
    		*newentry = entry;
    		return true;
    	};
    */
    Bit8u handle=RealHandle(entry);
    if (handle>=DOS_FILES) {
        DOS_SetError(DOSERR_INVALID_HANDLE);
        return false;
    };
    if (!Files[handle] || !Files[handle]->IsOpen()) {
        DOS_SetError(DOSERR_INVALID_HANDLE);
        return false;
    };
    DOS_PSP psp(dos.psp());
    *newentry = psp.FindFreeFileEntry();
    if (*newentry==0xff) {
        DOS_SetError(DOSERR_TOO_MANY_OPEN_FILES);
        return false;
    }
    Files[handle]->AddRef();
    psp.SetFileHandle(*newentry,handle);
    return true;
}
开发者ID:svn2github,项目名称:dosbox,代码行数:26,代码来源:dos_files.cpp


示例14: removeEmbargo

void	removeEmbargo(IonNode *node, uvast neighborNodeNbr)
{
	PsmPartition	ionwm = getIonwm();
	PsmAddress	elt;
	PsmAddress	addr;
	Embargo		*embargo;

	CHKVOID(node);
	for (elt = sm_list_first(ionwm, node->embargoes); elt;
			elt = sm_list_next(ionwm, elt))
	{
		addr = sm_list_data(ionwm, elt);
		embargo = (Embargo *) psp(ionwm, addr);
		CHKVOID(embargo);
		if (embargo->nodeNbr < neighborNodeNbr)
		{
			continue;
		}

		if (embargo->nodeNbr > neighborNodeNbr)
		{
			return;	/*	Embargo not found.		*/
		}

		break;		/*	Found the embargo to remove.	*/
	}

	if (elt == 0)
	{
		return;		/*	Embargo not found.		*/
	}

	oK(sm_list_delete(ionwm, elt, NULL, NULL));
	psm_free(ionwm, addr);
}
开发者ID:michirod,项目名称:cgr-jni,代码行数:35,代码来源:rfx.c


示例15: Sm_list_create

PsmAddress	Sm_list_create(const char *fileName, int lineNbr,
			PsmPartition partition)
{
	sm_SemId	lock;
	PsmAddress	list;
	SmList		*listBuffer;

	lock = sm_SemCreate(SM_NO_KEY, SM_SEM_FIFO);
	if (lock < 0)
	{
		putErrmsg("Can't create semaphore for list.", NULL);
		return 0;
	}

	list = Psm_zalloc(fileName, lineNbr, partition, sizeof(SmList));
	if (list == 0)
	{
		sm_SemDelete(lock);
		putErrmsg("Can't allocate space for list header.", NULL);
		return 0;
	}

	listBuffer = (SmList *) psp(partition, list);
	eraseList(listBuffer);
	listBuffer->lock = lock;
	return list;
}
开发者ID:brnrc,项目名称:ion-dtn,代码行数:27,代码来源:smlist.c


示例16: Sm_rbt_create

PsmAddress	Sm_rbt_create(char *file, int line, PsmPartition partition)
{
	sm_SemId	lock;
	PsmAddress	rbt;
	SmRbt		*rbtPtr;

	lock = sm_SemCreate(SM_NO_KEY, SM_SEM_FIFO);
	if (lock < 0)
	{
		putErrmsg("Can't create semaphore for rbt.", NULL);
		return 0;
	}

	rbt = Psm_zalloc(file, line, partition, sizeof(SmRbt));
	if (rbt == 0)
	{
		sm_SemDelete(lock);
		putErrmsg("Can't allocate space for rbt object.", NULL);
		return 0;
	}

	rbtPtr = (SmRbt *) psp(partition, rbt);
	eraseTree(rbtPtr);
	rbtPtr->lock = lock;
	return rbt;
}
开发者ID:NASAHackTO,项目名称:ion-dtn,代码行数:26,代码来源:smrbt.c


示例17: getIonwm

IonNode	*addNode(IonVdb *ionvdb, uvast nodeNbr)
{
	PsmPartition	ionwm = getIonwm();
	PsmAddress	addr;
	PsmAddress	elt;
	IonNode		*node;

	addr = psm_zalloc(ionwm, sizeof(IonNode));
	if (addr == 0)
	{
		putErrmsg("Can't add node.", NULL);
		return NULL;
	}

	node = (IonNode *) psp(ionwm, addr);
	CHKNULL(node);
	memset((char *) node, 0, sizeof(IonNode));
	node->nodeNbr = nodeNbr;
	elt = sm_rbt_insert(ionwm, ionvdb->nodes, addr, rfx_order_nodes, node);
	if (elt == 0)
	{
		psm_free(ionwm, addr);
		putErrmsg("Can't add node.", NULL);
		return NULL;
	}

	node->embargoes = sm_list_create(ionwm);
	return node;
}
开发者ID:michirod,项目名称:cgr-jni,代码行数:29,代码来源:rfx.c


示例18: createNode

static PsmAddress	createNode(char *file, int line, PsmPartition partition,
				PsmAddress rbt, PsmAddress parent,
				PsmAddress data, SmRbtNode **buffer)
{
	PsmAddress	node;
	SmRbtNode	*nodePtr;

	node = Psm_zalloc(file, line, partition, sizeof(SmRbtNode));
	if (node == 0)
	{
		putErrmsg("Can't allocate space for rbt node.", NULL);
		return 0;
	}

	nodePtr = (SmRbtNode *) psp(partition, node);
	nodePtr->rbt = rbt;
	nodePtr->parent = parent;
	nodePtr->child[LEFT] = 0;
	nodePtr->child[RIGHT] = 0;
	nodePtr->data = data;
	if (buffer)	/*	Tree already has a root.		*/
	{
		nodePtr->isRed = 1;
		*buffer = nodePtr;
	}
	else		/*	This is the first node in the tree.	*/
	{
		nodePtr->isRed = 0;	/*	Root is always black.	*/
	}

	return node;
}
开发者ID:NASAHackTO,项目名称:ion-dtn,代码行数:32,代码来源:smrbt.c


示例19: dropVdb

static void	dropVdb(PsmPartition wm, PsmAddress vdbAddress)
{
	IonVdb		*vdb;

	vdb = (IonVdb *) psp(wm, vdbAddress);

	/*	Time-ordered list of probes can simply be destroyed.	*/

	sm_list_destroy(wm, vdb->probes, rfx_erase_data, NULL);

	/*	Three of the red-black tables in the Vdb are
	 *	emptied and recreated by rfx_stop().  Destroy them.	*/

	sm_rbt_destroy(wm, vdb->contactIndex, NULL, NULL);
	sm_rbt_destroy(wm, vdb->rangeIndex, NULL, NULL);
	sm_rbt_destroy(wm, vdb->timeline, NULL, NULL);

	/*	cgr_stop clears all routing objects, so nodes and
	 *	neighbors themselves can now be deleted.		*/

	sm_rbt_destroy(wm, vdb->nodes, destroyIonNode, NULL);
	sm_rbt_destroy(wm, vdb->neighbors, rfx_erase_data, NULL);

	/*	Safely delete the ZCO availability semaphore.		*/

	sm_SemEnd(vdb->zcoSemaphore);
	sm_SemDelete(vdb->zcoSemaphore);
	vdb->zcoSemaphore = SM_SEM_NONE;
	vdb->zcoClaimants = 0;
	vdb->zcoClaims = 0;
	zco_unregister_callback();
}
开发者ID:pantuza,项目名称:pleiades-DTN,代码行数:32,代码来源:ion.c


示例20: DOS_FCBRenameFile

bool DOS_FCBRenameFile(Bit16u seg, Bit16u offset) {
    DOS_FCB fcbold(seg,offset);
    DOS_FCB fcbnew(seg,offset+16);
    if(!fcbold.Valid()) return false;
    char oldname[DOS_FCBNAME];
    char newname[DOS_FCBNAME];
    fcbold.GetName(oldname);
    fcbnew.GetName(newname);

    /* Check, if sourcefile is still open. This was possible in DOS, but modern oses don't like this */
    Bit8u drive;
    char fullname[DOS_PATHLENGTH];
    if (!DOS_MakeName(oldname,fullname,&drive)) return false;

    DOS_PSP psp(dos.psp());
    for (Bit8u i=0; i<DOS_FILES; i++) {
        if (Files[i] && Files[i]->IsOpen() && Files[i]->IsName(fullname)) {
            Bit16u handle = psp.FindEntryByHandle(i);
            //(more than once maybe)
            if (handle == 0xFF) {
                DOS_CloseFile(i,true);
            } else {
                DOS_CloseFile(handle);
            }
        }
    }

    /* Rename the file */
    return DOS_Rename(oldname,newname);
}
开发者ID:svn2github,项目名称:dosbox,代码行数:30,代码来源:dos_files.cpp



注:本文中的psp函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ psprintf函数代码示例发布时间:2022-05-30
下一篇:
C++ psmx_errno函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap