当前位置: 首页>>代码示例>>C++>>正文


C++ Unlink函数代码示例

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


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

示例1: MoveFile

void MoveFile(const std::string &src, std::string dest,
              TFileOpCB cb, void *prvdata)
{
    
    MakeOptDest(src, dest);
    
    if (src == dest)
        return;
    
    int ret = rename(src.c_str(), dest.c_str());
    if (ret != -1)
        return; // Hooray, quick and fast move :)
    else if (errno != EXDEV)
        throw Exceptions::CExMove(errno);
    
    // Couldn't rename file because it's on another disk; copy & delete
    
    try
    {
        CopyFile(src, dest, cb, prvdata);
    }
    catch(Exceptions::CExChMod &)
    {
        // Always unlink
        Unlink(src);
        throw;
    }

    Unlink(src);
}
开发者ID:BackupTheBerlios,项目名称:nixstaller-svn,代码行数:30,代码来源:utils.cpp

示例2: MOZ_ASSERT

/* static */ bool
FFmpegRuntimeLinker::Link()
{
  if (sLinkStatus) {
    return sLinkStatus == LinkStatus_SUCCEEDED;
  }

  MOZ_ASSERT(NS_IsMainThread());

  for (size_t i = 0; i < ArrayLength(sLibs); i++) {
    const AvCodecLib* lib = &sLibs[i];
    sLinkedLib = dlopen(lib->Name, RTLD_NOW | RTLD_LOCAL);
    if (sLinkedLib) {
      if (Bind(lib->Name, lib->Version)) {
        sLib = lib;
        sLinkStatus = LinkStatus_SUCCEEDED;
        return true;
      }
      // Shouldn't happen but if it does then we try the next lib..
      Unlink();
    }
  }

  FFMPEG_LOG("H264/AAC codecs unsupported without [");
  for (size_t i = 0; i < ArrayLength(sLibs); i++) {
    FFMPEG_LOG("%s %s", i ? "," : "", sLibs[i].Name);
  }
  FFMPEG_LOG(" ]\n");

  Unlink();

  sLinkStatus = LinkStatus_FAILED;
  return false;
}
开发者ID:hansman,项目名称:gecko-dev,代码行数:34,代码来源:FFmpegRuntimeLinker.cpp

示例3: doRmSource

static void doRmSource(Spec spec)
	/*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
	/*@modifies rpmGlobalMacroContext, fileSystem, internalState  @*/
{
    struct Source *sp;
    int rc;

#if 0
    rc = Unlink(spec->specFile);
#endif

    for (sp = spec->sources; sp != NULL; sp = sp->next) {
	const char *dn, *fn;
	if (sp->flags & RPMFILE_GHOST)
	    continue;
#if defined(RPM_VENDOR_OPENPKG) /* splitted-source-directory */
	if (! (dn = getSourceDir(sp->flags, sp->source)))
#else
	if (! (dn = getSourceDir(sp->flags)))
#endif
	    continue;
	fn = rpmGenPath(NULL, dn, sp->source);
	rc = Unlink(fn);
	fn = _free(fn);
    }
}
开发者ID:hahnakane,项目名称:junkcode,代码行数:26,代码来源:build.c

示例4: Unlink

void CObject::Unlink (bool bForce)
{
	ubyte nType = m_nLinkedType;

if (bForce || (nType != OBJ_NONE)) {
#if DBG
	if (this - gameData.objs.objects == nDbgObj) {
		nDbgObj = nDbgObj;
		//PrintLog ("unlinking object #%d, type %d\n", objP - gameData.objs.objects, nType);
		}
#endif
	m_nLinkedType = OBJ_NONE;
	Unlink (gameData.objs.lists.all, 0);
	if (nType == OBJ_PLAYER)
		Unlink (gameData.objs.lists.players, 1);
	else if (nType == OBJ_ROBOT)
		Unlink (gameData.objs.lists.robots, 1);
	else if (nType != OBJ_REACTOR) {
		if (nType == OBJ_WEAPON)
			Unlink (gameData.objs.lists.weapons, 1);
		else if (nType == OBJ_POWERUP)
			Unlink (gameData.objs.lists.powerups, 1);
		else if (nType == OBJ_EFFECT)
			Unlink (gameData.objs.lists.effects, 1);
		else if (nType == OBJ_LIGHT)
			Unlink (gameData.objs.lists.lights, 1);
		Unlink (gameData.objs.lists.statics, 2);
		return;
		}
	Unlink (gameData.objs.lists.actors, 2);
	}
}
开发者ID:paud,项目名称:d2x-xl,代码行数:32,代码来源:object.cpp

示例5: xiogetlock

/* returns 0 if it could create lock; 1 if the lock exists; -1 on error */
int xiogetlock(const char *lockfile) {
   char *s;
   struct stat strat;
   int fd;
   pid_t pid;
   char pidbuf[3*sizeof(pid_t)+1];
   size_t bytes;

   if (Lstat(lockfile, &strat) == 0) {
      return 1;
   }
   switch (errno) {
   case ENOENT: break;
   default:
      Error3("Lstat(\"%s\", %p): %s", lockfile, &strat, strerror(errno));
      return -1;
   }
   /* in this moment, the file did not exist */

   if ((s = Malloc(strlen(lockfile)+8)) == NULL) {
      errno = ENOMEM;
      return -1;
   }
   strcpy(s, lockfile);
   strcat(s, ".XXXXXX");

   if ((fd = Mkstemp(s)) < 0) {
      Error2("mkstemp(\"%s\"): %s", s, strerror(errno));
      return -1;
   }
  
   pid = Getpid();
   bytes = sprintf(pidbuf, F_pid, pid);
   if (writefull(fd, pidbuf, bytes) < 0) {
      Error4("write(%d, %p, "F_Zu"): %s", fd, pidbuf, bytes, strerror(errno));
      return -1;
   }
   Close(fd);

   /* Chmod(lockfile, 0600); */
   if (Link(s, lockfile) < 0) {
      int _errno = errno;
      Error3("link(\"%s\", \"%s\"): %s", s, lockfile, strerror(errno));
      Unlink(s);
      errno = _errno;
      return -1;
   }
   Unlink(s);

   return 0;
}
开发者ID:Adastra-thw,项目名称:Tortazo,代码行数:52,代码来源:xiolockfile.c

示例6: OP_ASSERT

void OpMmapSegment::Merge(UINT8 flag, UINT8 type, UINT16 idx)
{
    OP_ASSERT(flag == OP_MMAP_FLAG_UNUSED ||
              flag == OP_MMAP_FLAG_RESERVED);

    UINT16 pages = page_handle[idx].size;

    if ( page_handle[idx - 1].flag == flag )
    {
        UINT16 size2 = page_handle[idx - 1].size;
        idx -= size2;
        OP_ASSERT(page_handle[idx].size == size2);
        OP_ASSERT(page_handle[idx].flag == flag);
        pages += size2;
        Unlink(idx);
    }

    UINT16 idx2 = idx + pages;

    if ( page_handle[idx2].flag == flag )
    {
        UINT16 size2 = page_handle[idx2].size;
        OP_ASSERT(page_handle[idx2 + size2 - 1].size == size2);
        OP_ASSERT(page_handle[idx2 + size2 - 1].flag == flag);
        pages += size2;
        Unlink(idx2);
    }

    unsigned int cls;
    unsigned int size_class = ComputeSizeClass(pages);
    SetDetails(idx, pages, flag);
    page_handle[idx].type = type;

    switch ( flag )
    {
    case OP_MMAP_FLAG_UNUSED:
        cls = OP_MMAP_UNUSED_SIZECLASS + size_class;
        break;

    case OP_MMAP_FLAG_RESERVED:
        cls = OP_MMAP_RESERVED_SIZECLASS + size_class;
        break;

    default:
        OP_ASSERT(!"Critical - Illegal merge operation");
        return;
    }

    Link(cls, idx);
}
开发者ID:prestocore,项目名称:browser,代码行数:50,代码来源:memory_mmap.cpp

示例7: FREE_HSTRING

AI_Helicopter::~AI_Helicopter()
{
	FREE_HSTRING(m_hstrDeathMessage);
	FREE_HSTRING(m_hstrDeath0_3rdMessage);
	FREE_HSTRING(m_hstrDeath1_3rdMessage);
	FREE_HSTRING(m_hstrDeath2_3rdMessage);

	if ( m_pHelicopterState )
	{
		FACTORY_DELETE(m_pHelicopterState);
        m_pHelicopterState = LTNULL;
        m_pVehicleState = LTNULL;
        m_pState = LTNULL;
	}

	if ( -1 != m_iObjectGunner && m_apObjects[m_iObjectGunner] )
	{
		HOBJECT hGunner = m_apObjects[m_iObjectGunner]->m_hObject;
		if ( hGunner )
		{
			CCharacter* pGunner = (CCharacter*)g_pLTServer->HandleToObject(hGunner);
			if ( pGunner )
			{
				Unlink(hGunner);
				pGunner->RemoveObject();
			}
		}
	}
}
开发者ID:Arc0re,项目名称:lithtech,代码行数:29,代码来源:AIHelicopter.cpp

示例8: NS_ABORT_IF_FALSE

void
nsSMILInstanceTime::HandleChangedInterval(
    const nsSMILTimeContainer* aSrcContainer,
    PRBool aBeginObjectChanged,
    PRBool aEndObjectChanged)
{
  NS_ABORT_IF_FALSE(mBaseInterval,
      "Got call to HandleChangedInterval on an independent instance time.");
  NS_ABORT_IF_FALSE(mCreator, "Base interval is set but creator is not.");

  if (mVisited) {
    // Break the cycle here
    Unlink();
    return;
  }

  PRBool objectChanged = mCreator->DependsOnBegin() ? aBeginObjectChanged :
                                                      aEndObjectChanged;

  AutoBoolSetter setVisited(mVisited);

  nsRefPtr<nsSMILInstanceTime> deathGrip(this);
  mCreator->HandleChangedInstanceTime(*GetBaseTime(), aSrcContainer, *this,
                                      objectChanged);
}
开发者ID:LittleForker,项目名称:mozilla-central,代码行数:25,代码来源:nsSMILInstanceTime.cpp

示例9: Assert

void CBaseEntityList::CEntInfoList::LinkAfter( CEntInfo *pAfter, CEntInfo *pElement )
{
	Assert( pElement );
	
	// Unlink it if it's in the list at the moment
	if ( IsInList(pElement) )
		Unlink(pElement);
	
	// The element *before* our newly linked one is the one we linked after
	pElement->m_pPrev = pAfter;
	if (pAfter == NULL)
	{
		// In this case, we're linking to the head of the list, reset the head
		pElement->m_pNext = m_pHead;
		m_pHead = pElement;
	}
	else
	{
		// Here, we're not linking to the end. Set the next pointer to point to
		// the element we're linking.
		Assert( IsInList(pAfter) );
		pElement->m_pNext = pAfter->m_pNext;
		pAfter->m_pNext = pElement;
	}
	
	// Reset the tail if we linked to the tail of the list
	if (pElement->m_pNext == NULL )
	{
		m_pTail = pElement;
	}
	else
	{
		pElement->m_pNext->m_pPrev = pElement;
	}
}
开发者ID:Adidasman1,项目名称:source-sdk-2013,代码行数:35,代码来源:entitylist_base.cpp

示例10: while

void TransactionLevelGCManager::Running(const int &thread_id) {

  uint32_t backoff_shifts = 0;

  while (true) {
    auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance();
    auto max_cid = txn_manager.GetMaxCommittedCid();

    PL_ASSERT(max_cid != MAX_CID);

    int reclaimed_count = Reclaim(thread_id, max_cid);

    int unlinked_count = Unlink(thread_id, max_cid);

    if (is_running_ == false) {
      return;
    }

    if (reclaimed_count == 0 && unlinked_count == 0) {
      // sleep at most 0.8192 s
      if (backoff_shifts < 13) {
        ++backoff_shifts;
      }
      uint64_t sleep_duration = 1UL << backoff_shifts;
      sleep_duration *= 100;
      std::this_thread::sleep_for(std::chrono::microseconds(sleep_duration));
    } else {
      backoff_shifts >>= 1;
    }
  }
}
开发者ID:jessesleeping,项目名称:iso_peloton,代码行数:31,代码来源:transaction_level_gc_manager.cpp

示例11: switch

bool OperCFThread::DeleteFile( FS* fs, FSPath& path ) //return true if not concelled
{
	if ( Info()->Stopped() ) { return false; }

	if ( !commitAll )
	{
		switch ( RedMessage( _LT( "Do you want to delete file?\n" ), fs->Uri( path ).GetUtf8(), bDeleteAllSkipCancel ) )
		{
			case CMD_SKIP:
				return true;

			case CMD_ALL:
				commitAll = true;
				break;

			case CMD_OK:
				break;

			default:
				return false;
		}
	}

	return Unlink( fs, path ); //skip all???
}
开发者ID:FaionWeb,项目名称:WCMCommander,代码行数:25,代码来源:fileopers.cpp

示例12: exec_hashtable_cmd

void exec_hashtable_cmd(char *cmd, char *key, int val){
	int		readfifo, writefifo;
	size_t	len;
	ssize_t	n;
	char	*ptr, fifoname[MAXLINE], buff[MAXLINE];
	pid_t	pid;

	/* create FIFO with our PID as part of name */
	pid = getpid();
	snprintf(fifoname, sizeof(fifoname), "/tmp/fifo.%ld", (long) pid);
	if ((mkfifo(fifoname, FILE_MODE) < 0) && (errno != EEXIST))
		err_sys("can't create %s", fifoname);

	// readline need a \n 
	snprintf(buff, sizeof(buff), "%ld,%s,%s,%d\n", (long) pid, cmd, key, val);
	len = strlen(buff);

	/* open FIFO to server and write hashtable command to FIFO */
	writefifo = Open(SERV_FIFO, O_WRONLY, 0);
	Write(writefifo, buff, len);

	/* now open our FIFO; blocks until server opens for writing */
	readfifo = Open(fifoname, O_RDONLY, 0);

	/* read from IPC, get hashtable op result */
	memset(buff, 0, sizeof(buff));
	n = Read(readfifo, buff, MAXLINE);
	printf("**reply from server : %s\n", buff);

	Close(readfifo);
	Unlink(fifoname);
}
开发者ID:vonzhou,项目名称:hashtable-worker,代码行数:32,代码来源:client01.c

示例13: Unlink

/*
===============
idInteraction::UnlinkAndFree

Removes links and puts it back on the free list.
===============
*/
void idInteraction::UnlinkAndFree( void ) {

	// clear the table pointer
	idRenderWorldLocal *renderWorld = this->lightDef->world;
	if ( renderWorld->interactionTable ) {
		int index = this->lightDef->index * renderWorld->interactionTableWidth + this->entityDef->index;
		if ( renderWorld->interactionTable[index] != this ) {
			common->Error( "idInteraction::UnlinkAndFree: interactionTable wasn't set" );
		}
		renderWorld->interactionTable[index] = NULL;
	}

	Unlink();

	FreeSurfaces();

	// free the interaction area references
	areaNumRef_t *area, *nextArea;
	for ( area = frustumAreas; area; area = nextArea ) {
		nextArea = area->next;
		renderWorld->areaNumRefAllocator.Free( area );
	}

	// put it back on the free list
	renderWorld->interactionAllocator.Free( this );
}
开发者ID:sbrown345,项目名称:doom3_emscripten,代码行数:33,代码来源:Interaction.cpp

示例14: Unlink

void LinkedList<T>::Unlink(T &obj)
{
	Unlink(&obj);
	if (obj.m_listManaged) {
		delete &obj;
	}
}
开发者ID:angelog,项目名称:Scratch,代码行数:7,代码来源:LinkedList.hpp

示例15: Unlink

void HashBase::Set(int i, unsigned _hash) {
	if(map) {
		Link& lnk = link[i];
		Unlink(i, lnk);
		int& mi = Maph(_hash & ~UNSIGNED_HIBIT);
		int ii = mi;
		if(ii < 0)
			mi = lnk.prev = lnk.next = i;
		else
		if(i < ii) {
			LinkBefore(i, lnk, ii);
			mi = i;
		}
		else {
			int l = ii;
			int h = link[ii].prev;
			if(h - i < i - l) {
				while(i < h) {
					h = link[h].prev;
				}
				LinkBefore(i, lnk, link[h].next);
			}
			else {
				l = link[l].next;
				while(i > l && l != ii) {
					l = link[l].next;
				}
				LinkBefore(i, lnk, l);
			}
		}
	}
	hash[i] = _hash & ~UNSIGNED_HIBIT;
}
开发者ID:dreamsxin,项目名称:ultimatepp,代码行数:33,代码来源:Hash.cpp


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