Пример #1
0
Texture2D::~Texture2D()
{
    Release();
}
Пример #2
0
/// 解码
bool MailList::DecordFromByteArray(uchar* pByte, long& pos)
{
	Release();
	char strTemp[102400];
	long lNum = _GetLongFromByteArray(pByte,pos);
	for (int i=0; i<lNum; ++i)
	{
		tagMailParam* ptgMailParam = new tagMailParam;
		DWORD dwID = _GetDwordFromByteArray(pByte,pos);

		_GetStringFromByteArray(pByte, pos, strTemp);
		ptgMailParam->strSubject = strTemp;

		_GetStringFromByteArray(pByte, pos, strTemp);
		ptgMailParam->strWriter = strTemp;

		_GetStringFromByteArray(pByte, pos, strTemp);
		ptgMailParam->strText = strTemp;
		ptgMailParam->lGold = _GetLongFromByteArray(pByte, pos);

		long lTNum = _GetLongFromByteArray(pByte, pos);
		for (int k=0; k<lTNum; ++k)
		{
			tagTimer* ptgTimer = new tagTimer;
			_GetBufferFromByteArray(pByte, pos, ptgTimer, sizeof(tagTimer));
			ptgMailParam->ltgTimer.push_back(ptgTimer);
		}
		long lENum = _GetLongFromByteArray(pByte, pos);
		for (int l=0; l<lENum; ++l)
		{
			tagMailEvent* ptgMailEvent = new tagMailEvent;

			_GetStringFromByteArray(pByte, pos, strTemp);
			ptgMailEvent->strEventName = strTemp;
			ptgMailEvent->lBeginTime = _GetLongFromByteArray(pByte, pos);
			ptgMailEvent->lEndTime = _GetLongFromByteArray(pByte, pos);
			ptgMailParam->ltgMailEvent.push_back(ptgMailEvent);
		}


		long lRNum = _GetLongFromByteArray(pByte, pos);
		for (int j=0; j<lRNum; ++j)
		{
			_GetStringFromByteArray(pByte, pos, strTemp);
			string strReName = strTemp;
			ptgMailParam->strReceiverList.push_back(strReName);
		}

//		long lGNum = _GetLongFromByteArray(pByte, pos);
// 		for (int index=0; index<lGNum; ++index)
// 		{
// 			tagSGoods* ptgSGoods = new tagSGoods;
// 			ptgSGoods->lIndex = _GetLongFromByteArray(pByte, pos);
// 			ptgSGoods->lNum = _GetLongFromByteArray(pByte, pos);
// 			ptgMailParam->lSGoods.push_back(ptgSGoods);
// 		}

		long lCNum = _GetLongFromByteArray(pByte, pos);
		for (int index=0; index<lCNum; ++index)
		{
			tagMailCondition* ptgMailCondition = new tagMailCondition;
			_GetStringFromByteArray(pByte, pos, strTemp);
			ptgMailCondition->strName = strTemp;
			ptgMailCondition->lValue = _GetLongFromByteArray(pByte, pos);
			_GetStringFromByteArray(pByte, pos, strTemp);
			ptgMailCondition->strOperator = strTemp;
			ptgMailParam->lMailCondition.push_back(ptgMailCondition);
		}

		m_mapMail[dwID] = ptgMailParam;
	}	
	return true;
}
Пример #3
0
bool DIBitmap::Create(int w, int h, int d, RGBQUAD* pColorTable) 
{
	if (hMemDC != NULL || hBmp != NULL) {
		return false;	// 既に出来てるよ
	}

	// メモリDC
	hMemDC = CreateCompatibleDC(NULL);
	if (hMemDC == NULL) {
		return false;
	}

	// BITMAPINFO設定
	BITMAPINFO* pInfo;
	int biSize = sizeof(BITMAPINFO);
	int dCnt = GetBitmapColorCount(d);

	if (d <= 8) {
		// カラーテーブルあり
		biSize += sizeof(RGBQUAD) * (dCnt - 1);

		pInfo = (BITMAPINFO*)malloc(biSize);
		if (pInfo == NULL) {
			return false;
		}

		if (pColorTable == NULL) {
			// テーブルの指定が無いのでとりあえず真っ黒パレット
			for (int i = 0; i < dCnt; ++i) {
				pInfo->bmiColors[i].rgbRed = 0;
				pInfo->bmiColors[i].rgbGreen = 0;
				pInfo->bmiColors[i].rgbBlue = 0;
				pInfo->bmiColors[i].rgbReserved = 0;
			}
		} else {
			// テーブルをコピー
			for (int i = 0; i < dCnt; ++i) {
				pInfo->bmiColors[i].rgbRed = pColorTable[i].rgbRed;
				pInfo->bmiColors[i].rgbGreen = pColorTable[i].rgbGreen;
				pInfo->bmiColors[i].rgbBlue = pColorTable[i].rgbBlue;
				pInfo->bmiColors[i].rgbReserved = 0;
			}
		}
	} else {
		// カラーテーブル無し
		pInfo = (BITMAPINFO*)malloc(biSize);
		if (pInfo == NULL) {
			Release();
			return false;
		}
	}

	SetBitmapInfo(pInfo, w, h, d);

	// DIBセクション作成
	pBits = NULL;

	hBmp = CreateDIBSection(NULL, pInfo, DIB_RGB_COLORS, &pBits, NULL, 0);
	if (hBmp == NULL) {
		free(pInfo);
		Release();
		return false;
	}

	free(pInfo);

	// 関連付け
	SelectObject(hMemDC, hBmp);

	this->w = w;
	this->h = h > 0 ? h : -h;
	this->d = d;

	return true;
}
Пример #4
0
CEnemy01::~CEnemy01()
{
	Release();
}
Пример #5
0
OGRErr FGdbDriver::CommitTransaction(OGRDataSource*& poDSInOut, int& bOutHasReopenedDS)
{
    CPLMutexHolderOptionalLockD(hMutex);

    bOutHasReopenedDS = FALSE;


    OGRMutexedDataSource* poMutexedDS = (OGRMutexedDataSource*)poDSInOut;
    FGdbDataSource* poDS = (FGdbDataSource* )poMutexedDS->GetBaseDataSource();
    FGdbDatabaseConnection* pConnection = poDS->GetConnection();
    if( !pConnection->IsLocked() )
    {
        CPLError(CE_Failure, CPLE_NotSupported,
                 "No transaction in progress");
        return OGRERR_FAILURE;
    }

    bOutHasReopenedDS = TRUE;

    CPLString osName(poMutexedDS->GetName());
    CPLString osNameOri(osName);
    if( osName[osName.size()-1] == '/' || osName[osName.size()-1] == '\\' )
        osName.resize(osName.size()-1);

#ifndef WIN32
    int bPerLayerCopyingForTransaction = poDS->HasPerLayerCopyingForTransaction();
#endif

    pConnection->m_nRefCount ++;
    delete poDSInOut;
    poDSInOut = NULL;
    poMutexedDS = NULL;
    poDS = NULL;

    pConnection->CloseGeodatabase();

    CPLString osEditedName(osName);
    osEditedName += ".ogredited";
    
#ifndef WIN32
    if( bPerLayerCopyingForTransaction )
    {
        int bError = FALSE;
        char** papszFiles;
        std::vector<CPLString> aosTmpFilesToClean;
        
        // Check for files present in original copy that are not in edited copy
        // That is to say deleted layers
        papszFiles = VSIReadDir(osName);
        for(char** papszIter = papszFiles; !bError && *papszIter; ++papszIter)
        {
            if( strcmp(*papszIter, ".") == 0 || strcmp(*papszIter, "..") == 0 )
                continue;
            VSIStatBufL sStat;
            if( (*papszIter)[0] == 'a' &&
                VSIStatL( CPLFormFilename(osEditedName, *papszIter, NULL), &sStat ) != 0 )
            {
                if( EQUAL(CPLGetConfigOption("FGDB_SIMUL_FAIL", ""), "CASE1") || 
                    VSIRename( CPLFormFilename(osName, *papszIter, NULL),
                               CPLFormFilename(osName, *papszIter, "tmp") ) != 0 )
                {
                    CPLError(CE_Failure, CPLE_AppDefined, "Cannot rename %s to %s",
                             CPLFormFilename(osName, *papszIter, NULL),
                             CPLFormFilename(osName, *papszIter, "tmp"));
                    bError = TRUE;
                }
                else
                    aosTmpFilesToClean.push_back(CPLFormFilename(osName, *papszIter, "tmp"));
            }
        }
        CSLDestroy(papszFiles);

        // Move modified files from edited directory to main directory
        papszFiles = VSIReadDir(osEditedName);
        for(char** papszIter = papszFiles; !bError && *papszIter; ++papszIter)
        {
            if( strcmp(*papszIter, ".") == 0 || strcmp(*papszIter, "..") == 0 )
                continue;
            struct stat sStat;
            if( lstat( CPLFormFilename(osEditedName, *papszIter, NULL), &sStat ) != 0 )
            {
                CPLError(CE_Failure, CPLE_AppDefined, "Cannot stat %s",
                         CPLFormFilename(osEditedName, *papszIter, NULL));
                bError = TRUE;
            }
            else if( !S_ISLNK(sStat.st_mode) )
            {
                // If there was such a file in original directory, first rename it
                // as a temporary file
                if( lstat( CPLFormFilename(osName, *papszIter, NULL), &sStat ) == 0 )
                {
                    if( EQUAL(CPLGetConfigOption("FGDB_SIMUL_FAIL", ""), "CASE2") || 
                        VSIRename( CPLFormFilename(osName, *papszIter, NULL),
                                   CPLFormFilename(osName, *papszIter, "tmp") ) != 0 )
                    {
                        CPLError(CE_Failure, CPLE_AppDefined, "Cannot rename %s to %s",
                                 CPLFormFilename(osName, *papszIter, NULL),
                                 CPLFormFilename(osName, *papszIter, "tmp"));
                        bError = TRUE;
                    }
                    else
                        aosTmpFilesToClean.push_back(CPLFormFilename(osName, *papszIter, "tmp"));
                }
                if( !bError )
                {
                    if( EQUAL(CPLGetConfigOption("FGDB_SIMUL_FAIL", ""), "CASE3") || 
                        CPLMoveFile( CPLFormFilename(osName, *papszIter, NULL),
                                     CPLFormFilename(osEditedName, *papszIter, NULL) ) != 0 )
                    {
                        CPLError(CE_Failure, CPLE_AppDefined, "Cannot move %s to %s",
                                 CPLFormFilename(osEditedName, *papszIter, NULL),
                                 CPLFormFilename(osName, *papszIter, NULL));
                        bError = TRUE;
                    }
                    else
                        CPLDebug("FileGDB", "Move %s to %s",
                                 CPLFormFilename(osEditedName, *papszIter, NULL),
                                 CPLFormFilename(osName, *papszIter, NULL));
                }
            }
        }
        CSLDestroy(papszFiles);

        if( !bError )
        {
            for(size_t i=0;i<aosTmpFilesToClean.size();i++)
            {
                if( EQUAL(CPLGetConfigOption("FGDB_SIMUL_FAIL", ""), "CASE4") || 
                    VSIUnlink(aosTmpFilesToClean[i]) != 0 )
                {
                    CPLError(CE_Warning, CPLE_AppDefined,
                             "Cannot remove %s. Manual cleanup required", aosTmpFilesToClean[i].c_str());
                }
            }
        }

        if( bError )
        {
            CPLError(CE_Failure, CPLE_AppDefined,
                     "An error occurred while moving files from %s back to %s. "
                     "Manual cleaning must be done and dataset should be closed",
                     osEditedName.c_str(),
                     osName.c_str());
            pConnection->SetLocked(FALSE);
            Release(osName);
            return OGRERR_FAILURE;
        }
        else if( EQUAL(CPLGetConfigOption("FGDB_SIMUL_FAIL", ""), "CASE5") || 
                 CPLUnlinkTree(osEditedName) != 0 )
        {
            CPLError(CE_Warning, CPLE_AppDefined,
                    "Cannot remove %s. Manual cleanup required", osEditedName.c_str());
        }
    }
    else
#endif
    {
        CPLString osTmpName(osName);
        osTmpName += ".ogrtmp";
        
        /* Install the backup copy as the main database in 3 steps : */
        /* first rename the main directory  in .tmp */
        /* then rename the edited copy under regular name */
        /* and finally dispose the .tmp directory */
        /* That way there's no risk definitely losing data */
        if( EQUAL(CPLGetConfigOption("FGDB_SIMUL_FAIL", ""), "CASE1") || 
            VSIRename(osName, osTmpName) != 0 )
        {
            CPLError(CE_Failure, CPLE_AppDefined,
                    "Cannot rename %s to %s. Edited database during transaction is in %s"
                    "Dataset should be closed",
                    osName.c_str(), osTmpName.c_str(), osEditedName.c_str());
            pConnection->SetLocked(FALSE);
            Release(osName);
            return OGRERR_FAILURE;
        }
        
        if( EQUAL(CPLGetConfigOption("FGDB_SIMUL_FAIL", ""), "CASE2") || 
            VSIRename(osEditedName, osName) != 0 )
        {
            CPLError(CE_Failure, CPLE_AppDefined,
                    "Cannot rename %s to %s. The original geodatabase is in '%s'. "
                    "Dataset should be closed",
                    osEditedName.c_str(), osName.c_str(), osTmpName.c_str());
            pConnection->SetLocked(FALSE);
            Release(osName);
            return OGRERR_FAILURE;
        }

        if( EQUAL(CPLGetConfigOption("FGDB_SIMUL_FAIL", ""), "CASE3") || 
            CPLUnlinkTree(osTmpName) != 0 )
        {
            CPLError(CE_Warning, CPLE_AppDefined,
                    "Cannot remove %s. Manual cleanup required", osTmpName.c_str());
        }
    }

    pConnection->m_pGeodatabase = new Geodatabase;
    long hr = ::OpenGeodatabase(StringToWString(osName), *(pConnection->m_pGeodatabase));
    if( EQUAL(CPLGetConfigOption("FGDB_SIMUL_FAIL", ""), "CASE_REOPEN") || FAILED(hr))
    {
        delete pConnection->m_pGeodatabase;
        pConnection->m_pGeodatabase = NULL;
        pConnection->SetLocked(FALSE);
        Release(osName);
        GDBErr(hr, "Failed to re-open Geodatabase. Dataset should be closed");
        return OGRERR_FAILURE;
    }

    FGdbDataSource* pDS = new FGdbDataSource(this, pConnection);
    pDS->Open(osNameOri, TRUE, NULL);
    //pDS->SetPerLayerCopyingForTransaction(bPerLayerCopyingForTransaction);
    poDSInOut = new OGRMutexedDataSource(pDS, TRUE, hMutex, TRUE);

    pConnection->SetLocked(FALSE);

    return OGRERR_NONE;
}
Пример #6
0
scRenderSystem::~scRenderSystem(void)
{
	Release();
}
Пример #7
0
udtThread::~udtThread()
{
	Release();
}
Пример #8
0
 DiGLIndexBuffer::~DiGLIndexBuffer()
 {
     Release();
 }
nsresult
nsMsgSendLater::StartNextMailFileSend(nsresult prevStatus)
{
    bool hasMoreElements = false;
    if ((!mEnumerator) ||
            NS_FAILED(mEnumerator->HasMoreElements(&hasMoreElements)) ||
            !hasMoreElements)
    {
        // Notify that this message has finished being sent.
        NotifyListenersOnProgress(mTotalSendCount, mMessagesToSend.Count(), 100, 100);

        // EndSendMessages resets everything for us
        EndSendMessages(prevStatus, nullptr, mTotalSendCount, mTotalSentSuccessfully);

        // XXX Should we be releasing references so that we don't hold onto items
        // unnecessarily.
        return NS_OK;
    }

    // If we've already sent a message, and are sending more, send out a progress
    // update with 100% for both send and copy as we must have finished by now.
    if (mTotalSendCount)
        NotifyListenersOnProgress(mTotalSendCount, mMessagesToSend.Count(), 100, 100);

    nsCOMPtr<nsISupports> currentItem;
    nsresult rv = mEnumerator->GetNext(getter_AddRefs(currentItem));
    NS_ENSURE_SUCCESS(rv, rv);

    mMessage = do_QueryInterface(currentItem);
    if (!mMessage)
        return NS_ERROR_NOT_AVAILABLE;

    if (!mMessageFolder)
        return NS_ERROR_UNEXPECTED;

    nsCString messageURI;
    mMessageFolder->GetUriForMsg(mMessage, messageURI);

    rv = nsMsgCreateTempFile("nsqmail.tmp", getter_AddRefs(mTempFile));
    NS_ENSURE_SUCCESS(rv, rv);

    nsCOMPtr<nsIMsgMessageService> messageService;
    rv = GetMessageServiceFromURI(messageURI, getter_AddRefs(messageService));
    if (NS_FAILED(rv) && !messageService)
        return NS_ERROR_FACTORY_NOT_LOADED;

    ++mTotalSendCount;

    nsCString identityKey;
    rv = mMessage->GetStringProperty(HEADER_X_MOZILLA_IDENTITY_KEY,
                                     getter_Copies(identityKey));
    NS_ENSURE_SUCCESS(rv, rv);

    nsCOMPtr<nsIMsgIdentity> identity;
    rv = GetIdentityFromKey(identityKey.get(), getter_AddRefs(identity));
    NS_ENSURE_SUCCESS(rv, rv);

    // Notify that we're just about to start sending this message
    NotifyListenersOnMessageStartSending(mTotalSendCount, mMessagesToSend.Count(),
                                         identity);

    // Setup what we need to parse the data stream correctly
    m_inhead = true;
    m_headersFP = 0;
    m_headersPosition = 0;
    m_bytesRead = 0;
    m_position = 0;
    m_flagsPosition = 0;
    m_headersSize = 0;
    PR_FREEIF(mLeftoverBuffer);

    // Now, get our stream listener interface and plug it into the DisplayMessage
    // operation
    AddRef();

    rv = messageService->DisplayMessage(messageURI.get(),
                                        static_cast<nsIStreamListener*>(this),
                                        nullptr, nullptr, nullptr, nullptr);

    Release();

    return rv;
}
Пример #10
0
	bool DisplaySurfaceManager::Create(const boost::any& _rConfig)
	{
		Release();
		return true;
	}
Пример #11
0
//---------------------------------------------------------------------------- 
// Nome: ~CShot(void)
// Desc: destrutor padrão 
// Pams: nenhum
//---------------------------------------------------------------------------- 
CShot::~CShot(void)
{
	Release();
}
Пример #12
0
CMachineMng::~CMachineMng()
{
	Release();
}
Пример #13
0
H264DecoderFrameList::~H264DecoderFrameList(void)
{
    Release();

} // H264DecoderFrameList::~H264DecoderFrameList(void)
Пример #14
0
bool Texture2D::Create()
{
    Release();

    if (!graphics_ || !width_ || !height_)
        return false;

    if (graphics_->IsDeviceLost())
    {
        URHO3D_LOGWARNING("Texture creation while device is lost");
        return true;
    }

    IDirect3DDevice9* device = graphics_->GetImpl()->GetDevice();
    // If creating a depth-stencil texture, and it is not supported, create a depth-stencil surface instead
    if (usage_ & D3DUSAGE_DEPTHSTENCIL && !graphics_->GetImpl()->CheckFormatSupport((D3DFORMAT)format_, usage_, D3DRTYPE_TEXTURE))
    {
        HRESULT hr = device->CreateDepthStencilSurface(
            (UINT)width_,
            (UINT)height_,
            (D3DFORMAT)format_,
            D3DMULTISAMPLE_NONE,
            0,
            FALSE,
            (IDirect3DSurface9**)&renderSurface_->surface_,
            0);
        if (FAILED(hr))
        {
            URHO3D_SAFE_RELEASE(renderSurface_->surface_);
            URHO3D_LOGD3DERROR("Could not create depth-stencil surface", hr);
            return false;
        }

        levels_ = 1;
    }
    else
    {
        HRESULT hr = graphics_->GetImpl()->GetDevice()->CreateTexture(
            (UINT)width_,
            (UINT)height_,
            requestedLevels_,
            usage_,
            (D3DFORMAT)format_,
            (D3DPOOL)pool_,
            (IDirect3DTexture9**)&object_,
            0);
        if (FAILED(hr))
        {
            URHO3D_SAFE_RELEASE(object_);
            URHO3D_LOGD3DERROR("Could not create texture", hr);
            return false;
        }

        levels_ = ((IDirect3DTexture9*)object_)->GetLevelCount();

        if (usage_ & (D3DUSAGE_RENDERTARGET | D3DUSAGE_DEPTHSTENCIL))
        {
            hr = ((IDirect3DTexture9*)object_)->GetSurfaceLevel(0, (IDirect3DSurface9**)&renderSurface_->surface_);
            if (FAILED(hr))
                URHO3D_LOGD3DERROR("Could not get rendertarget surface", hr);
        }
    }

    return true;
}
Пример #15
0
int main() {
	
	int myLineID;
	int firstTime;
	int ifBribed;
	int appClerkCV;
	int appClerkLock;
	int yieldCalls;
	int id;
	int i;	
	int start;
	int currentCustomer;
	int cash;


	createServerMVs(1,1);
	initialize(&appClerk, 0, 1);

	Acquire(appClerk.newClerkIdLock);

	/*
	myLineID = appClerk.newClerkId;
	id = appClerk.newClerkId;
	appClerk.newClerkId++;
	*/
	myLineID = GetMV(appClerk.newClerkId, 0);
	id = myLineID;
	SetMV(appClerk.newClerkId, 0, id + 1);
	Release(appClerk.newClerkIdLock);	

	firstTime = 1;
	start = 1;

	while(start == 1) {		
		waitForLine(&appClerk, id, firstTime);
		currentCustomer = GetMV(appClerk.currentCustomer, id);

		Uprintf("ApplicationClerk #%d has received SSN %d from Customer #%d.\n", 60, id, currentCustomer,currentCustomer,0);
		
		/*
		appClerkCV = appClerk.clerkCV[myLineID];
		appClerkLock = appClerk.clerkLock[myLineID];
		*/

		appClerkCV = GetMV(appClerk.clerkCV, myLineID);
		appClerkLock = GetMV(appClerk.clerkLock, myLineID);

		/*input the socialSecurityNum into the completed applications*/
		/*customersWithCompletedApps[appClerk.currentCustomer[id]] = 1;*/

		SetMV(customersWithCompletedApps, currentCustomer, 1);

		yieldCalls = Rand(80, 21);
		for(i = 0; i < yieldCalls; i++) { /*delay in filing the application*/
			Yield();
		}

		Signal(appClerkCV, appClerkLock);
		Wait(appClerkCV, appClerkLock);
		/*currentCustomer = GetMV(appClerk.currentCustomer, id);*/
		Uprintf("ApplicationClerk #%d has recorded a completed application for Customer #%d.\n", 76, id, currentCustomer,0,0);
		
		if(ifBribed == 1) {
			Uprintf("ApplicationClerk #%d has received $500 from Customer #%d.\n", 58, id, currentCustomer,0,0);			
			/*appClerk.cashReceived+=500;*/
			cash = GetMV(appClerk.cashReceived, 0) + 500;
			SetMV(appClerk.cashReceived, 0, cash);
		}

		firstTime = 0;
		Release(appClerkLock);
	}
	return 0;
}
Пример #16
0
 CKVector::~CKVector()
 {
     Release();
 }
Пример #17
0
bool MyDatabase::Close()
{
	return !Release();
}
Пример #18
0
GLSLShader::~GLSLShader()
{
    Release();
}
Пример #19
0
CLogo_Button::~CLogo_Button(void)
{
	Release();
}
Пример #20
0
// Destructor
OsFileIteratorBase::~OsFileIteratorBase()
{
    Release();
}
Пример #21
0
//##ModelId=41C92C0C0196
GemContainer::~GemContainer()
{
	// TODO: Add your specialized code here.
	Release();
}
Пример #22
0
OsStatus OsFileIteratorBase::findFirst(OsPathBase& entry, const char* filterExp,
                                       OsFileType filetype)
{
    OsFileType entryType;
    UtlBoolean bDone = FALSE;
    UtlString name;
    OsStatus stat = OS_FILE_NOT_FOUND;
    UtlBoolean bFirstTime = TRUE;

    UtlBoolean bFoundOne = false;
    mMatchAttrib = filetype;
    mFileCount = 0;

    entry = "";

    Release();

    mFilterExp = new RegEx(filterExp);

    //add a sep on the end if there is not already one there
    if (   mUserSpecifiedPath.length()
        && *(mUserSpecifiedPath.data()+mUserSpecifiedPath.length()-1) != OsPathBase::separator
        )
    {
        mUserSpecifiedPath += OsPathBase::separator;
    }

    mFullSearchSpec = mUserSpecifiedPath;

    while (!bDone)
    {
        //returns OS_SUCCESS or OS_FILE_NOT_FOUND
        //because we may have found a file that is not the one we want, the next
        //search we do we should use NextEntry
        if (bFirstTime)
        {
            stat = getFirstEntryName(name, entryType);
        }
        else
        {
            stat = getNextEntryName(name, entryType);
        }
        //so we don't use FirstEntry next time
        bFirstTime = FALSE;

        if (stat == OS_SUCCESS)
        {
            if (entryType == mMatchAttrib || mMatchAttrib == ANY_FILE)
            {
                //now check if if meets our regexp criteria
                if (mFilterExp->Search(name.data()))
                {
                    entry = name;
                    stat = OS_SUCCESS;
                    bDone = TRUE;
                    bFoundOne = TRUE;
                    mFileCount++;
                }
            }
        }
        else
        {
            bDone = TRUE;
        }
    }

    if (!bFoundOne)
    {
        stat = OS_FILE_NOT_FOUND;
    }
    return stat;
}
Пример #23
0
OGRErr FGdbDriver::StartTransaction(OGRDataSource*& poDSInOut, int& bOutHasReopenedDS)
{
    CPLMutexHolderOptionalLockD(hMutex);

    bOutHasReopenedDS = FALSE;

    OGRMutexedDataSource* poMutexedDS = (OGRMutexedDataSource*)poDSInOut;
    FGdbDataSource* poDS = (FGdbDataSource* )poMutexedDS->GetBaseDataSource();
    if( !poDS->GetUpdate() )
        return OGRERR_FAILURE;
    FGdbDatabaseConnection* pConnection = poDS->GetConnection();
    if( pConnection->GetRefCount() != 1 )
    {
        CPLError(CE_Failure, CPLE_AppDefined,
                 "Cannot start transaction as database is opened in another connection");
        return OGRERR_FAILURE;
    }
    if( pConnection->IsLocked() )
    {
        CPLError(CE_Failure, CPLE_AppDefined,
                 "Transaction is already in progress");
        return OGRERR_FAILURE;
    }

    bOutHasReopenedDS = TRUE;

    CPLString osName(poMutexedDS->GetName());
    CPLString osNameOri(osName);
    if( osName[osName.size()-1] == '/' || osName[osName.size()-1] == '\\' )
        osName.resize(osName.size()-1);

#ifndef WIN32
    int bPerLayerCopyingForTransaction = poDS->HasPerLayerCopyingForTransaction();
#endif

    pConnection->m_nRefCount ++;
    delete poDSInOut;
    poDSInOut = NULL;
    poMutexedDS = NULL;
    poDS = NULL;

    pConnection->CloseGeodatabase();

    CPLString osEditedName(osName);
    osEditedName += ".ogredited";

    CPLPushErrorHandler(CPLQuietErrorHandler);
    CPL_IGNORE_RET_VAL(CPLUnlinkTree(osEditedName));
    CPLPopErrorHandler();

    OGRErr eErr = OGRERR_NONE;
    
    CPLString osDatabaseToReopen;
#ifndef WIN32
    if( bPerLayerCopyingForTransaction )
    {
        int bError = FALSE;
        
        if( VSIMkdir( osEditedName, 0755 ) != 0 )
        {
            CPLError( CE_Failure, CPLE_AppDefined, 
                      "Cannot create directory '%s'.",
                      osEditedName.c_str() );
            bError = TRUE;
        }

        // Only copy a0000000X.Y files with X >= 1 && X <= 8, gdb and timestamps
        // and symlink others
        char** papszFiles = VSIReadDir(osName);
        for(char** papszIter = papszFiles; !bError && *papszIter; ++papszIter)
        {
            if( strcmp(*papszIter, ".") == 0 || strcmp(*papszIter, "..") == 0 )
                continue;
            if( ((*papszIter)[0] == 'a' && atoi((*papszIter)+1) >= 1 &&
                 atoi((*papszIter)+1) <= 8) || EQUAL(*papszIter, "gdb") ||
                 EQUAL(*papszIter, "timestamps") )
            {
                if( CPLCopyFile(CPLFormFilename(osEditedName, *papszIter, NULL),
                                CPLFormFilename(osName, *papszIter, NULL)) != 0 )
                {
                    bError = TRUE;
                    CPLError(CE_Failure, CPLE_AppDefined,
                             "Cannot copy %s", *papszIter);
                }
            }
            else
            {
                CPLString osSourceFile;
                if( CPLIsFilenameRelative(osName) )
                    osSourceFile = CPLFormFilename(CPLSPrintf("../%s", CPLGetFilename(osName.c_str())), *papszIter, NULL);
                else
                    osSourceFile = osName;
                if( EQUAL(CPLGetConfigOption("FGDB_SIMUL_FAIL", ""), "CASE1") ||
                    CPLSymlink( osSourceFile,
                                CPLFormFilename(osEditedName.c_str(), *papszIter, NULL),
                                NULL ) != 0 )
                {
                    bError = TRUE;
                    CPLError(CE_Failure, CPLE_AppDefined,
                             "Cannot symlink %s", *papszIter);
                }
            }
        }
        CSLDestroy(papszFiles);

        if( bError )
        {
            eErr = OGRERR_FAILURE;
            osDatabaseToReopen = osName;
        }
        else
            osDatabaseToReopen = osEditedName;
    }
    else
#endif
    {
        if( EQUAL(CPLGetConfigOption("FGDB_SIMUL_FAIL", ""), "CASE1") ||
            CPLCopyTree( osEditedName, osName ) != 0 )
        {
            CPLError(CE_Failure, CPLE_AppDefined,
                    "Cannot backup geodatabase");
            eErr = OGRERR_FAILURE;
            osDatabaseToReopen = osName;
        }
        else
            osDatabaseToReopen = osEditedName;
    }

    pConnection->m_pGeodatabase = new Geodatabase;
    long hr = ::OpenGeodatabase(StringToWString(osDatabaseToReopen), *(pConnection->m_pGeodatabase));
    if( EQUAL(CPLGetConfigOption("FGDB_SIMUL_FAIL", ""), "CASE2") || FAILED(hr))
    {
        delete pConnection->m_pGeodatabase;
        pConnection->m_pGeodatabase = NULL;
        Release(osName);
        GDBErr(hr, CPLSPrintf("Failed to open %s. Dataset should be closed",
                              osDatabaseToReopen.c_str()));

        return OGRERR_FAILURE;
    }

    FGdbDataSource* pDS = new FGdbDataSource(this, pConnection);
    pDS->Open(osDatabaseToReopen, TRUE, osNameOri);

#ifndef WIN32
    if( eErr == OGRERR_NONE && bPerLayerCopyingForTransaction )
    {
        pDS->SetPerLayerCopyingForTransaction(bPerLayerCopyingForTransaction);
        pDS->SetSymlinkFlagOnAllLayers();
    }
#endif

    poDSInOut = new OGRMutexedDataSource(pDS, TRUE, hMutex, TRUE);

    if( eErr == OGRERR_NONE )
        pConnection->SetLocked(TRUE);
    return eErr;
}
GoodsAllPurposeOpt::~GoodsAllPurposeOpt(void)
{
	Release(FALSE);
}
Пример #25
0
OGRErr FGdbDriver::RollbackTransaction(OGRDataSource*& poDSInOut, int& bOutHasReopenedDS)
{
    CPLMutexHolderOptionalLockD(hMutex);

    bOutHasReopenedDS = FALSE;

    OGRMutexedDataSource* poMutexedDS = (OGRMutexedDataSource*)poDSInOut;
    FGdbDataSource* poDS = (FGdbDataSource* )poMutexedDS->GetBaseDataSource();
    FGdbDatabaseConnection* pConnection = poDS->GetConnection();
    if( !pConnection->IsLocked() )
    {
        CPLError(CE_Failure, CPLE_NotSupported,
                 "No transaction in progress");
        return OGRERR_FAILURE;
    }

    bOutHasReopenedDS = TRUE;

    CPLString osName(poMutexedDS->GetName());
    CPLString osNameOri(osName);
    if( osName[osName.size()-1] == '/' || osName[osName.size()-1] == '\\' )
        osName.resize(osName.size()-1);

    //int bPerLayerCopyingForTransaction = poDS->HasPerLayerCopyingForTransaction();

    pConnection->m_nRefCount ++;
    delete poDSInOut;
    poDSInOut = NULL;
    poMutexedDS = NULL;
    poDS = NULL;

    pConnection->CloseGeodatabase();

    CPLString osEditedName(osName);
    osEditedName += ".ogredited";

    OGRErr eErr = OGRERR_NONE;
    if( EQUAL(CPLGetConfigOption("FGDB_SIMUL_FAIL", ""), "CASE1") || 
        CPLUnlinkTree(osEditedName) != 0 )
    {
        CPLError(CE_Warning, CPLE_AppDefined,
                 "Cannot remove %s. Manual cleanup required", osEditedName.c_str());
        eErr = OGRERR_FAILURE;
    }

    pConnection->m_pGeodatabase = new Geodatabase;
    long hr = ::OpenGeodatabase(StringToWString(osName), *(pConnection->m_pGeodatabase));
    if (EQUAL(CPLGetConfigOption("FGDB_SIMUL_FAIL", ""), "CASE2") ||
        FAILED(hr))
    {
        delete pConnection->m_pGeodatabase;
        pConnection->m_pGeodatabase = NULL;
        pConnection->SetLocked(FALSE);
        Release(osName);
        GDBErr(hr, "Failed to re-open Geodatabase. Dataset should be closed");
        return OGRERR_FAILURE;
    }

    FGdbDataSource* pDS = new FGdbDataSource(this, pConnection);
    pDS->Open(osNameOri, TRUE, NULL);
    //pDS->SetPerLayerCopyingForTransaction(bPerLayerCopyingForTransaction);
    poDSInOut = new OGRMutexedDataSource(pDS, TRUE, hMutex, TRUE);

    pConnection->SetLocked(FALSE);

    return eErr;
}
//! 开始物品操作
BOOL GoodsAllPurposeOpt::BeginOpt(
	 const	CGUID	&OwnerGuid,			//! 所属玩家GUID
	 DWORD			dwTitleID,			//! 标题ID
	 DWORD			dwButtonID,			//! 按钮ID
	 LPCSTR			pText,				//! 基本说明文字
	 LPCSTR			pOnPushScript,		//! 响应物品放入的脚本名
	 LPCSTR			pOnFinishScript,	//! 相应按钮按下的脚本名
	 LONG			lRadius,			//! 会话时允许的活动半径
	 LONG			lPosX,				//! 活动范围中心X坐标
	 LONG			lPosY,				//! 活动范围中心Y坐标
	 const	CGUID	&RegionGuid,		//! 所在地图GUID
	 DWORD			dwMaxPushNum			//! 最大放置物品的数量(不超过MAX_ALLPURPOSE_CONTAINER_SIZE)
)
{
	Release(FALSE);

	if(NULL == pText || NULL == pOnPushScript || NULL == pOnFinishScript || 0 >= lRadius || 0 > lPosX || 0 > lPosY || MAX_ALLPURPOSE_CONTAINER_SIZE < dwMaxPushNum || 0 == dwMaxPushNum)
		return FALSE;

	//if(NULL == GetGame()->GetScriptFileData(pOnPushScript) || GetGame()->GetScriptFileData(pOnFinishScript))
		//return FALSE;

	m_OwnerGuid			= OwnerGuid;
	m_dwTitleID			= dwTitleID;
	m_dwButtonID		= dwButtonID;
	m_dwMaxPushNum		= dwMaxPushNum;

	memcpy(m_szText, pText, min(STR_TXT_SIZE - 1, strlen(pText)));
	memcpy(m_szOnPushScript, pOnPushScript, min(STR_INFO_SIZE - 1, strlen(pOnPushScript)));
	memcpy(m_szOnFinishScript, pOnFinishScript, min(STR_INFO_SIZE - 1, strlen(pOnFinishScript)));

	m_lRadius			= lRadius;
	m_lPosX				= lPosX;
	m_lPosY				= lPosY;
	m_RegionGuid		= RegionGuid;

	//! 
	CMessage msgOpen(MSG_S2C_GOODS_AllPurpose_Open);

	DBWriteSet OpendbWriteSet;
	msgOpen.GetDBWriteSet(OpendbWriteSet);
	OpendbWriteSet.AddToByteArray(dwMaxPushNum);
	OpendbWriteSet.AddToByteArray(m_dwTitleID);
	OpendbWriteSet.AddToByteArray(m_dwButtonID);
	OpendbWriteSet.AddToByteArray(m_lRadius);
	OpendbWriteSet.AddToByteArray(m_lPosX);
	OpendbWriteSet.AddToByteArray(m_lPosY);

	msgOpen.SendToPlayer(OwnerGuid, false);

	//! 
	CMessage msgTxt(MSG_S2C_GOODS_AllPurpose_UpdateTxt);

	DBWriteSet TxtdbWriteSet;
	msgTxt.GetDBWriteSet(TxtdbWriteSet);
	TxtdbWriteSet.AddToByteArray(m_szText);

	msgTxt.SendToPlayer(m_OwnerGuid, false);

	return TRUE;
}
void VStringInputMapManager::OneTimeDeInit()
{
  Release();
}
Пример #28
0
int waitForLine(struct Monitor *clerk, int myLineID, int firstTime) {
	
	int ifBribed;
	int senLineCount;
	int bribeLineCount;
	int lineCount;
	int senLineCV;
	int bribeLineCV;
	int lineCV;
	int start;
	int clerkLock;
	int clerkCV;
	int clerkType;
	int senWorking;

	Acquire(clerk->lineLock);

	ifBribed = 0;
	start = 1;
	clerkType = GetMV(clerk->clerkType, 0);

	while(start == 1) {
		
		bribeLineCount = GetMV(clerk->bribeLineCount, myLineID);
		lineCount = GetMV(clerk->lineCount, myLineID);
		senWorking = GetMV(senatorWorking, 0);

		if(senWorking != NULL){

			senLineCount = GetMV(clerk->senLineCount, myLineID);

			if(senLineCount > 0) {
				/*Signal(clerk->senLineCV[myLineID], clerk->lineLock);*/
				/*clerk->clerkState[myLineID] = 0;*/
				senLineCV = GetMV(clerk->senLineCV, myLineID);
				Signal(senLineCV, clerk->lineLock);
				SetMV(clerk->clerkState, myLineID, 0);
				break;
			} else {
				/*clerk->clerkState[myLineID] = 1;*/ /*set state to break*/
				SetMV(clerk->clerkState, myLineID, 1);
				Wait(clerk->breakCV, clerk->lineLock);
				continue;
			}
		} else if (bribeLineCount > 0) { /*if there is someone in the bribe line, signal them first*/
			/* Signal(clerk->bribeLineCV[myLineID], clerk->lineLock); */
			bribeLineCV = GetMV(clerk->bribeLineCV, myLineID);
			Signal(bribeLineCV, clerk->lineLock);
			ifBribed = 1;
			/* clerk->clerkState[myLineID] = 0; */ /*set state to busy*/
			SetMV(clerk->clerkState, myLineID, 0);

			if(clerkType == 0) {
				Uprintf("ApplicationClerk #%d has signalled a Customer to come to their counter.\n", 72, myLineID, 0, 0, 0);
			} else if(clerkType == 1) {
				Uprintf("PictureClerk #%d has signalled a Customer to come to their counter.\n", 68, myLineID, 0, 0, 0);
			} else if(clerkType == 3) {
				Uprintf("Cashier #%d has signalled a Customer to come to their counter.\n", 63, myLineID, 0, 0, 0);
			} else if(clerkType == 2) {
				Uprintf("PassportClerk #%d has signalled a Customer to come to their counter.\n", 69, myLineID, 0, 0, 0);
			}
			break;
		} else if (lineCount > 0) { /*signal someone in normal line*/
			/*Signal(clerk->lineCV[myLineID], clerk->lineLock);*/
			lineCV = GetMV(clerk->lineCV, myLineID);
			Signal(lineCV, clerk->lineLock);
			/*clerk->clerkState[myLineID] = 0; */ /*set state to busy*/
			SetMV(clerk->clerkState, myLineID, 0);
			
			if(clerkType == 0) {
				Uprintf("ApplicationClerk #%d has signalled a Customer to come to their counter.\n", 72, myLineID, 0, 0, 0);
			} else if(clerkType == 1) {
				Uprintf("PictureClerk #%d has signalled a Customer to come to their counter.\n", 68, myLineID, 0, 0, 0);
			} else if(clerkType == 3) {
				Uprintf("Cashier #%d has signalled a Customer to come to their counter.\n", 63, myLineID, 0, 0, 0);
			} else if(clerkType == 2) {
				Uprintf("PassportClerk #%d has signalled a Customer to come to their counter.\n", 69, myLineID, 0, 0, 0);
			}
			break;
		} else { /*no one is in either line, we must go to sleep*/

			firstTime = 0;
			if (firstTime == 0) {
				if(clerkType == 0) {
					Uprintf("ApplicationClerk #%d is going on break.\n", 40, myLineID, 0, 0, 0);
				} else if(clerkType == 1) {
					Uprintf("PictureClerk #%d is going on break.\n", 36, myLineID, 0, 0, 0);
				} else if(clerkType == 3) {
					Uprintf("Cashier #%d is going on break.\n", 31, myLineID, 0, 0, 0);
				} else if(clerkType == 2) {
					Uprintf("PassportClerk #%d is going on break.\n", 37, myLineID, 0, 0, 0);
				}				
				/*clerk->clerkState[myLineID] = 1;*/ /*set state to break*/
				SetMV(clerk->clerkState, myLineID, 1);

				Wait(clerk->breakCV, clerk->lineLock);
				
				if(clerkType == 0) {
					Uprintf("ApplicationClerk #%d is coming off break.\n", 43, myLineID, 0, 0, 0);
				} else if(clerkType == 1) {
					Uprintf("PictureClerk #%d is coming off break.\n", 38, myLineID, 0, 0, 0);
				} else if(clerkType == 3) {
					Uprintf("Cashier #%d is coming off break.\n", 33, myLineID, 0, 0, 0);
				} else if(clerkType == 2) {
					Uprintf("PassportClerk #%d is coming off break.\n", 39, myLineID, 0, 0, 0);
				}			
			}

			/*clerk->clerkState[myLineID] = 0;*/ /*set state to busy*/
			SetMV(clerk->clerkState, myLineID, 0);
			continue;
		}
	}

	/*grab the clerkLock so we can properly signal the waiting customer
	to avoid a race condition and guarentee the correct order of events*/
	clerkLock = GetMV(clerk->clerkLock, myLineID);
	/*Acquire(clerk->clerkLock[myLineID]);*/
	Acquire(clerkLock);

	/*now we can let go of line lock since we properly acquired the clerk lock*/
	Release(clerk->lineLock);
	clerkCV = GetMV(clerk->clerkCV, myLineID);
	/*Wait(clerk->clerkCV[myLineID], clerk->clerkLock[myLineID]);*/
	Wait(clerkCV, clerkLock);
	return ifBribed;
}
Пример #29
0
MyOctant::~MyOctant() {
    Release();
};
Пример #30
0
void Texture2D::OnDeviceLost()
{
    if (pool_ == D3DPOOL_DEFAULT)
        Release();
}