示例#1
0
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);
    }
}
示例#2
0
/* 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;
}
示例#3
0
文件: object.cpp 项目: paud/d2x-xl
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);
	}
}
示例#4
0
/* 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;
}
示例#5
0
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);
}
void
nsSMILInstanceTime::HandleChangedInterval(
    const nsSMILTimeContainer* aSrcContainer,
    bool aBeginObjectChanged,
    bool aEndObjectChanged)
{
  // It's possible a sequence of notifications might cause our base interval to
  // be updated and then deleted. Furthermore, the delete might happen whilst
  // we're still in the queue to be notified of the change. In any case, if we
  // don't have a base interval, just ignore the change.
  if (!mBaseInterval)
    return;

  NS_ABORT_IF_FALSE(mCreator, "Base interval is set but creator is not.");

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

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

  mozilla::AutoRestore<bool> setVisited(mVisited);
  mVisited = true;

  nsRefPtr<nsSMILInstanceTime> deathGrip(this);
  mCreator->HandleChangedInstanceTime(*GetBaseTime(), aSrcContainer, *this,
                                      objectChanged);
}
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);
}
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;
	}
}
// NOTE: Cut from UtlFixedLinkedList<>, UNDONE: Find a way to share this code
void CBaseEntityList::CEntInfoList::LinkBefore( CEntInfo *pBefore, CEntInfo *pElement )
{
	Assert( pElement );
	
	// Unlink it if it's in the list at the moment
	Unlink(pElement);
	
	// The element *after* our newly linked one is the one we linked before.
	pElement->m_pNext = pBefore;
	
	if (pBefore == NULL)
	{
		// In this case, we're linking to the end of the list, so reset the tail
		pElement->m_pPrev = m_pTail;
		m_pTail = pElement;
	}
	else
	{
		// Here, we're not linking to the end. Set the prev pointer to point to
		// the element we're linking.
		Assert( IsInList(pBefore) );
		pElement->m_pPrev = pBefore->m_pPrev;
		pBefore->m_pPrev = pElement;
	}
	
	// Reset the head if we linked to the head of the list
	if (pElement->m_pPrev == NULL)
	{
		m_pHead = pElement;
	}
	else
	{
		pElement->m_pPrev->m_pNext = pElement;
	}
}
示例#10
0
int VSIMemFilesystemHandler::Rename( const char *pszOldPath,
                                     const char *pszNewPath )

{
    CPLMutexHolder oHolder( &hMutex );

    CPLString osOldPath = pszOldPath;
    CPLString osNewPath = pszNewPath;

    NormalizePath( osOldPath );
    NormalizePath( osNewPath );

    if ( osOldPath.compare(osNewPath) == 0 )
        return 0;

    if( oFileList.find(osOldPath) == oFileList.end() )
    {
        errno = ENOENT;
        return -1;
    }
    else
    {
        VSIMemFile* poFile = oFileList[osOldPath];

        oFileList.erase( oFileList.find(osOldPath) );

        Unlink(osNewPath);

        oFileList[osNewPath] = poFile;
        poFile->osFilename = osNewPath;

        return 0;
    }
}
示例#11
0
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();
			}
		}
	}
}
示例#12
0
/*
	Link()
*/
BOOL CId3v1Tag::Link(const char* lpcszFileName)
{
	BOOL bRet = FALSE;
	
	Unlink();

	strcpyn(m_szFileName,lpcszFileName,sizeof(m_szFileName));
	{
		CBinFileEx file;

		if(file.OpenExistingReadOnly(m_szFileName))
		{
			if(file.SeekEx((LONGLONG)sizeof(m_ID3v1) * -1,FILE_END)!=FILE_EEOF)
				if(file.Read(m_ID3v1,sizeof(m_ID3v1))!=FILE_EOF)
				{
					SetTagsFromTag();
					bRet = TRUE;
				}
			
			file.Close();
		}
	}

	return(bRet);
}
示例#13
0
void LinkedList<T>::Unlink(T &obj)
{
	Unlink(&obj);
	if (obj.m_listManaged) {
		delete &obj;
	}
}
示例#14
0
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;
}
示例#15
0
CVehicle::~CVehicle ( void )
{
    if ( m_pJackingPlayer && m_pJackingPlayer->GetJackingVehicle () == this )
    {
        if ( m_pJackingPlayer->GetVehicleAction () == CPlayer::VEHICLEACTION_JACKING )
        {
            m_pJackingPlayer->SetVehicleAction ( CPlayer::VEHICLEACTION_NONE );
        }
        m_pJackingPlayer->SetJackingVehicle ( NULL );
    }

    // Unset any tow links
    if ( m_pTowedVehicle )
        m_pTowedVehicle->SetTowedByVehicle ( NULL );

    if ( m_pTowedByVehicle )
        m_pTowedByVehicle->SetTowedVehicle ( NULL );

    // Make sure nobody's syncing us
    SetSyncer ( NULL );

    // Unreference from our occupators
    for ( unsigned int i = 0; i < MAX_VEHICLE_SEATS; i++ )
    {
        if ( m_pOccupants [i] )
        {
            m_pOccupants [i]->SetOccupiedVehicle ( NULL, 0 );
            m_pOccupants [i]->SetVehicleAction ( CPed::VEHICLEACTION_NONE );
        }
    }
    delete m_pUpgrades;

    // Remove us from the vehicle manager
    Unlink ();
}
示例#16
0
// The receiver has terminated. Remove from the Processor's Pending Terminations
// list. Answer whether the process was actually on that list.
void OverlappedCall::RemoveFromPendingTerminations()
{
	ProcessOTE* oteProc = pendingTerms()->remove(m_oteProcess);
	if (oteProc == m_oteProcess)
	{
		Process* myProc = oteProc->m_location;
		HARDASSERT(myProc->Thread() == this);
		myProc->ClearThread();

		// Return it to the scheduling queues - we resume it to cause a scheduling decision to be made. 
		Interpreter::resume(oteProc);
		// Remove the reference that was from the pending terminations list
		oteProc->countDown();
	}
	else
	{
		HARDASSERT(oteProc->isNil());
	}

	m_oteProcess->countDown();
	m_oteProcess = (ProcessOTE*)Pointers.Nil;

	// Remove the call from the active list as it is being destroyed - I don't think we need
	// the lock anymore
	{
		//CMonitorLock lock(s_listMonitor);
		Unlink();
	}
}
示例#17
0
void OpMmapSegment::ReleaseUnused(void)
{
    if ( unused_pages > unused_pages_threshold )
    {
        unsigned int half_unused_pages_threshold = unused_pages_threshold / 2;

        for ( int cls = max_size_class; cls >= 0; cls-- )
        {
            unsigned int anchor = OP_MMAP_UNUSED_SIZECLASS + cls;

            for (;;)
            {
                if ( unused_pages <= half_unused_pages_threshold )
                    return;

                unsigned int idx = page_handle[anchor].prev;

                if ( idx < OP_MMAP_ANCHOR_COUNT )
                    break;

                OP_ASSERT(page_handle[idx].flag == OP_MMAP_FLAG_UNUSED);
                unsigned int pages = page_handle[idx].size;
                void* ptr = (void*)(base + idx * pagesize);
                OpMemory_VirtualFree(mseg, ptr, pages * pagesize,
                                     (OpMemoryClass)unusedtype);

                Unlink(idx);
                Merge(OP_MMAP_FLAG_RESERVED, 0, idx);

                unused_pages -= pages;
            }
        }
    }
}
示例#18
0
Preference::Preference(QWidget *parent):QDialog(parent)
{
    QTextCodec::setCodecForTr(QTextCodec::codecForName("utf-8"));
    ui.setupUi(this);
    ui.preferenceTab->setTabText(ACCOUNT,tr("账号"));
    ui.preferenceTab->setTabText(ADVANCED,tr("高级"));
    ui.preferenceTab->setTabText(ABOUT,tr("关于"));
    connect(ui.preferenceTab,SIGNAL(currentChanged(int)),this,SLOT(ShowData(int)));
    connect(ui.unlinkButton,SIGNAL(clicked()),this,SLOT(Unlink()));
    QSettings settings(qgetenv("HOME")+SYSTEM,QSettings::IniFormat);
    if(settings.value("SavePath").toString().isEmpty())
    {
        QString Home = qgetenv("HOME");
        settings.setValue("SavePath",Home + "/IPan");
    }
    SavePath = settings.value("SavePath").toString();
    ui.dirLine->setText(SavePath);
    emit ChangeSavePath(SavePath);
    connect(ui.moveButton,SIGNAL(clicked()),this,SLOT(MoveDir()));
    connect(ui.closeButton,SIGNAL(clicked()),this,SLOT(CloseWindow()));
    connect(ui.runsysche,SIGNAL(stateChanged(int)),this,SLOT(setRunSys(int)));
    ui.preferenceTab->setCurrentIndex(ACCOUNT);
    if(settings.value("RunSys").toString().isEmpty())
    {
        ui.runsysche->setCheckState(Qt::Unchecked);
    }
    else
    {
        int val = settings.value("RunSys").toInt();
        if(val == 0)
            ui.runsysche->setCheckState(Qt::Unchecked);
        else if(val == 2)
            ui.runsysche->setCheckState(Qt::Checked);
    }
}
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;
    }
  }
}
void CAISenseRecorder::Update()
{
	// TODO: Optimize this so we don't do it every frame.

    LTFLOAT fTime = g_pLTServer->GetTime();

	for ( int iSense = 0 ; iSense < CAISense::kNumSenses ; iSense++ )
	{
		CAISenseRecord** ppRecord = m_alstpSenseRecords[iSense].GetItem(TLIT_FIRST);
		while ( ppRecord && *ppRecord )
		{
			if ( !(*ppRecord)->UpdateLifetime(fTime) )
			{
				Unlink((*ppRecord)->GetObject());
				FACTORY_DELETE((*ppRecord));
				m_alstpSenseRecords[iSense].Remove((*ppRecord));
				ppRecord = m_alstpSenseRecords[iSense].GetItem(TLIT_CURRENT);
			}
			else
			{
				ppRecord = m_alstpSenseRecords[iSense].GetItem(TLIT_NEXT);
			}
		}
	}
}
示例#21
0
/*
===============
idClipModel::Link
===============
*/
void idClipModel::Link( idClip &clp ) {

	assert( idClipModel::entity );
	if ( !idClipModel::entity ) {
		return;
	}

	if ( clipLinks ) {
		Unlink();	// unlink from old position
	}

	if ( bounds.IsCleared() ) {
		return;
	}

	// set the abs box
	if ( axis.IsRotated() ) {
		// expand for rotation
		absBounds.FromTransformedBounds( bounds, origin, axis );
	} else {
		// normal
		absBounds[0] = bounds[0] + origin;
		absBounds[1] = bounds[1] + origin;
	}

	// because movement is clipped an epsilon away from an actual edge,
	// we must fully check even when bounding boxes don't quite touch
	absBounds[0] -= vec3_boxEpsilon;
	absBounds[1] += vec3_boxEpsilon;

	Link_r( clp.clipSectors );
}
示例#22
0
/*
================
idClipModel::SetPosition
================
*/
void idClipModel::SetPosition( const idVec3 &newOrigin, const idMat3 &newAxis ) {
	if ( clipLinks ) {
		Unlink();	// unlink from old position
	}
	origin = newOrigin;
	axis = newAxis;
}
示例#23
0
/*
===============
idInteraction::MakeEmpty

Relinks the interaction at the end of both the light and entity chains
and adds the INTERACTION_EMPTY marker to the interactionTable.

It is necessary to keep the empty interaction so when entities or lights move
they can set all the interactionTable values to NULL. 
===============
*/
void idInteraction::MakeEmpty() {
	// an empty interaction has no surfaces
	numSurfaces = 0;

	Unlink();

	// relink at the end of the entity's list
	this->entityNext = NULL;
	this->entityPrev = this->entityDef->lastInteraction;
	this->entityDef->lastInteraction = this;
	if ( this->entityPrev ) {
		this->entityPrev->entityNext = this;
	} else {
		this->entityDef->firstInteraction = this;
	}

	// relink at the end of the light's list
	this->lightNext = NULL;
	this->lightPrev = this->lightDef->lastInteraction;
	this->lightDef->lastInteraction = this;
	if ( this->lightPrev ) {
		this->lightPrev->lightNext = this;
	} else {
		this->lightDef->firstInteraction = this;
	}

	// store the special marker in the interaction table
	const int interactionIndex = lightDef->index * entityDef->world->interactionTableWidth + entityDef->index;
	assert( entityDef->world->interactionTable[ interactionIndex ] == this );
	entityDef->world->interactionTable[ interactionIndex ] = INTERACTION_EMPTY;
}
示例#24
0
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???
}
示例#25
0
/*
================
idClipModel::~idClipModel
================
*/
idClipModel::~idClipModel( void ) {
	// make sure the clip model is no longer linked
	Unlink();
	if ( traceModelIndex != -1 ) {
		FreeTraceModel( traceModelIndex );
	}
}
示例#26
0
bool OperCFThread::CopyLink( FS* srcFs, FSPath& srcPath, FSNode* srcNode, FS* destFs, FSPath& destPath, bool move )
{
	ASSERT( srcNode->st.IsLnk() );

	if ( IsSameFile( srcFs, srcPath, &( srcNode->st ), destFs, destPath ) )
	{
		RedMessage( _LT( "Can't copy link to itself:\n" ) , srcFs->Uri( srcPath ).GetUtf8() );
		return false;
	}

	int ret_err;

	while ( destFs->Symlink( destPath, srcNode->st.link, &ret_err, Info() ) && !skipNonRegular )
		switch ( RedMessage( _LT( "Can't create symbolic link:\n" ), destFs->Uri( destPath ).GetUtf8(), "to\n",
		                     srcNode->st.link.GetUtf8(),  bSkipSkipallCancel, destFs->StrError( ret_err ).GetUtf8() ) )
		{
			case CMD_CANCEL:
				return false;

			case CMD_SKIPALL:
				skipNonRegular = true;

			case CMD_SKIP:
				return true;
		}

	return !move || Unlink( srcFs, srcPath );
}
示例#27
0
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);
}
示例#28
0
/*
===============
idInteraction::MakeEmpty

Makes the interaction empty and links it at the end of the entity's and light's interaction lists.
===============
*/
void idInteraction::MakeEmpty( void ) {

	// an empty interaction has no surfaces
	numSurfaces = 0;

	Unlink();

	// relink at the end of the entity's list
	this->entityNext = NULL;
	this->entityPrev = this->entityDef->lastInteraction;
	this->entityDef->lastInteraction = this;
	if ( this->entityPrev ) {
		this->entityPrev->entityNext = this;
	} else {
		this->entityDef->firstInteraction = this;
	}

	// relink at the end of the light's list
	this->lightNext = NULL;
	this->lightPrev = this->lightDef->lastInteraction;
	this->lightDef->lastInteraction = this;
	if ( this->lightPrev ) {
		this->lightPrev->lightNext = this;
	} else {
		this->lightDef->firstInteraction = this;
	}
}
示例#29
0
/*
===============
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 );
}
示例#30
-1
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);
}