コード例 #1
0
ファイル: File.cpp プロジェクト: Karkasos/Core
	Bool GetFileSizeTest()
	{
		Bool result = true;
		File* file;

		//File does not exists, GetFileSize returns 0
		File::Delete(_fileName);
		CHECK File::GetFileSize(_fileName) == 0;

		//File exists, but is empty, GetFileSize returns 0
		file = File::Create(_fileName);
		CHECK file->GetFileSize() == 0;
		DeletePtr(file)
		CHECK File::GetFileSize(_fileName) == 0;

		//File exists, and is not empty, GetFileSize returns size
		file = File::Open(_fileName);
		file->Write((VoidPtr)_fileName, 5);
		CHECK file->GetFileSize() == 5;
		DeletePtr(file)
		CHECK File::GetFileSize(_fileName) == 5;

		File::Delete(_fileName);

		return result;
	}
コード例 #2
0
ファイル: File.cpp プロジェクト: Karkasos/Core
	Bool OpenReadOnlyTest()
	{
		Bool result = true;
		File* file;
		String text;
		UInt fileSize;

		//File does not exists, open it and it will fail
		File::Delete(_fileName);
		file = File::OpenReadOnly(_fileName);
		CHECK file == 0;

		//File exists, open it and it will work, write to it and it will fail
		CHECK (file = File::Create(_fileName));
		file->Write((VoidPtr)_fileName, String::CStrByteSize(_fileName));
		DeletePtr(file);
		CHECK (file = File::OpenReadOnly(_fileName));
		fileSize = ToUInt(file->GetFileSize());
		text.Reserve(fileSize / sizeof(TChar));
		file->Read(text.DrivePointer(fileSize / sizeof(TChar)), fileSize);
		CHECK text == _fileName;
		DeletePtr(file);

		File::Delete(_fileName);

		return result;
	}
コード例 #3
0
CNcdNodeLink::~CNcdNodeLink()
    {
    DLTRACEIN((""));

    // Do not delete node here because this link does not own it.

    delete iParentIdentifier;
    iParentIdentifier = NULL;
    
    delete iRequestParentIdentifier;
    iRequestParentIdentifier = NULL;
    
    delete iMetaDataIdentifier;
    iMetaDataIdentifier = NULL;

    delete iTimeStamp;
    iTimeStamp = NULL;

    delete iCatalogsSourceName;
    iCatalogsSourceName = NULL;
        
    delete iServerUri;
    iServerUri = NULL;
    
    delete iRemoteUri;
    iRemoteUri = NULL;
    
    DeletePtr( iMetadataTimeStamp );
    iQueries.Close();
    DLTRACEOUT((""));
    }        
コード例 #4
0
ファイル: SPtrArray.cpp プロジェクト: mach0628/comhub
void CSPtrArray::InsertAt(int nIndex, void * newElement, int nCount /*=1*/)
{
	ASSERT(nIndex >= 0);    // will expand to meet need
	ASSERT(nCount > 0);     // zero or negative size not allowed

	if (nIndex >= m_nSize)
	{
		// adding after the end of the array
		SetSize(nIndex + nCount, -1);   // grow so nIndex is valid
	}
	else
	{
		// inserting in the middle of the array
		int nOldSize = m_nSize;
		SetSize(m_nSize + nCount, -1);  // grow it to new size
		// destroy intial data before copying over it
		DeletePtr(&m_pData[nOldSize], nCount);
		// shift old data up to fill gap
		memmove(&m_pData[nIndex+nCount], &m_pData[nIndex],
			(nOldSize-nIndex) * sizeof(void *));

		// re-init slots we copied from
		//memset(&m_pData[nIndex],0, nCount);
	}

	// insert new value in the gap
	ASSERT(nIndex + nCount <= m_nSize);
	while (nCount--)
		m_pData[nIndex++] = newElement;
}
コード例 #5
0
ファイル: CradleGame.cpp プロジェクト: Dieselhead/Cradle
CradleGame::~CradleGame()
{

	if (m_Actor) delete[] m_Actor;
	m_Actor = nullptr;

	
	if (m_cd3d) delete m_cd3d;
	m_cd3d = nullptr;

	if (m_timer) delete m_timer;
	m_timer = nullptr;

	if (m_cInput) delete m_cInput;
	m_cInput = nullptr;

	if (m_texture) delete m_texture;
	m_texture = nullptr;

	// ReleaseCOM(m_vertexBuffer);
	// ReleaseCOM(m_vs);
	// ReleaseCOM(m_ps);
	DeletePtr(m_camera);

	if (m_Resources) delete m_Resources;
	m_Resources = nullptr;

	if (m_instanceData) delete[] m_instanceData;
	m_instanceData = nullptr;

	ReleaseCOM(m_vertexBuffer);

}
コード例 #6
0
// ---------------------------------------------------------------------------
// Starts the operation asynchronously
// ---------------------------------------------------------------------------
//              
void CCatalogsHttpTransaction::AsyncStartL()
    {
    DLTRACEIN((""));
    DeletePtr( iCallBack );
    iCallBack = new ( ELeave ) CAsyncCallBack( 
        iStartCallBack, CActive::EPriorityStandard );
    iCallBack->CallBack();
    }
コード例 #7
0
    Worker::~Worker()
    {
        _alive = false;
        _semaphore.notify();
        _thread->join();

        DeletePtr(_thread);
    }
コード例 #8
0
ファイル: SPtrArray.cpp プロジェクト: mach0628/comhub
//##ModelId=4049F738001C
CSPtrArray::~CSPtrArray()
{
	// TODO: Add your specialized code here.
	if (m_pData != NULL)
	{
		DeletePtr(m_pData, m_nSize);
		delete[] (BYTE*)m_pData;
	}
}
コード例 #9
0
ファイル: File.cpp プロジェクト: Karkasos/Core
	Bool OpenTest()
	{
		Bool result = true;
		File* file;

		//File does not exists, open it and it will fail
		File::Delete(_fileName);
		file = File::Open(_fileName);
		CHECK file == 0;

		//File exists, open it and it will work
		CHECK (file = File::Create(_fileName));
		DeletePtr(file);
		CHECK (file = File::Open(_fileName));
		DeletePtr(file);

		File::Delete(_fileName);

		return result;
	}
コード例 #10
0
ファイル: File.cpp プロジェクト: Karkasos/Core
	Bool SeekToEndTest()
	{
		Bool result = true;
		File* file;

		//Create, write 6 bytes and close
		file = File::Create(_fileName);
		file->Write((VoidPtr)_fileName, 6);
		DeletePtr(file);

		//Create, GetSeekPos returns 0, SeekToEnd, GetSeekPos returns 6
		file = File::Open(_fileName);
		CHECK file->GetSeekPos() == 0;
		file->SeekToEnd();
		CHECK file->GetSeekPos() == 6;

		DeletePtr(file)
		File::Delete(_fileName);

		return result;
	}
コード例 #11
0
ファイル: File.cpp プロジェクト: Karkasos/Core
	Bool CreateTest()
	{
		Bool result = true;
		File* file;

		//File does not exists, create it and size will be 0 and SeekPos will be 0
		File::Delete(_fileName);
		CHECK (file = File::Create(_fileName));
		CHECK file->GetFileSize() == 0;
		CHECK file->GetSeekPos() == 0;
		DeletePtr(file);

		//File exists, create it and it will be truncated and SeekPos will be 0
		CHECK (file = File::Create(_fileName));
		CHECK file->GetFileSize() == 0;
		CHECK file->GetSeekPos() == 0;
		DeletePtr(file);

		File::Delete(_fileName);

		return result;
	}
コード例 #12
0
ファイル: SPtrArray.cpp プロジェクト: mach0628/comhub
//##ModelId=404C95C1002C
void CSPtrArray::RemoveAt(int nIndex,int nCount)
{
	// TODO: Add your specialized code here.
	ASSERT(nIndex >= 0);
	ASSERT(nCount >= 0);
	ASSERT(nIndex + nCount <= m_nSize);

	// just remove a range
	int nMoveCount = m_nSize - (nIndex + nCount);
	DeletePtr(&m_pData[nIndex], nCount);
	if (nMoveCount)
		memmove(&m_pData[nIndex], &m_pData[nIndex + nCount],
			nMoveCount * sizeof(void *));
	m_nSize -= nCount;

}
コード例 #13
0
ファイル: File.cpp プロジェクト: Karkasos/Core
	Bool DeleteTest()
	{
		Bool result = true;
		File* file;

		//File does not exists, Delete returns false
		CHECK File::Delete(_fileName) == false;

		//File exists, Delete returns true, then file no longer exists
		file = File::Create(_fileName);
		DeletePtr(file)
		CHECK File::Delete(_fileName) == true;
		CHECK File::Exists(_fileName) == false;

		return result;
	}
コード例 #14
0
ファイル: File.cpp プロジェクト: Karkasos/Core
	Bool ExistsTest()
	{
		Bool result = true;
		File* file;

		//File does not exists, Exists returns false
		File::Delete(_fileName);
		CHECK File::Exists(_fileName) == false;

		//File exists, Exists returns true
		file = File::Create(_fileName);
		DeletePtr(file)
		CHECK File::Exists(_fileName) == true;

		File::Delete(_fileName);

		return result;
	}
コード例 #15
0
ファイル: Thread.Win32.cpp プロジェクト: Karkasos/Core
		ThreadImpl* ThreadImpl::CreateInstance(ThreadFonc threadEntry, VoidPtr threadParam)
		{
			HANDLE threadHandle;
			ThreadImpl* Thread = new ThreadImpl(threadEntry, threadParam);

			threadHandle = ::CreateThread(NULL, 0, NativeThreadEntry, (LPVOID)Thread, 0, NULL);

			if(threadHandle)
			{
				Thread->_threadHandle = threadHandle;
				return Thread;
			}
			else
			{
				DeletePtr(Thread);
				return NULL;
			}
		}
コード例 #16
0
ファイル: File.cpp プロジェクト: Karkasos/Core
	Bool SeekTest()
	{
		Bool result = true;
		File* file;

		//Seek is at 0, GetSeekPos returns 0
		file = File::Create(_fileName);
		CHECK file->GetSeekPos() == 0;

		//Seek is at 3, GetSeekPos returns 3
		file->Write((VoidPtr)_fileName, 3);
		CHECK file->GetSeekPos() == 3;

		DeletePtr(file)
		File::Delete(_fileName);

		return result;
	}
コード例 #17
0
ファイル: File.cpp プロジェクト: Karkasos/Core
	Bool GetSeekPosTest()
	{
		Bool result = true;
		File* file;

		//SeekPos is at zero, GetSeekPos returns 0
		file = File::Create(_fileName);
		CHECK file->GetSeekPos() == 0;

		//SeekPos is at 5, GetSeekPos returns 5
		file->Write((VoidPtr)_fileName, 5);
		CHECK file->GetSeekPos() == 5;

		DeletePtr(file)
		File::Delete(_fileName);

		return result;
	}
コード例 #18
0
ファイル: File.cpp プロジェクト: Karkasos/Core
	Bool ReadWriteTest()
	{
		Bool result = true;
		File* file;
		UInt32 const bufferSize = 1024;
		TChar buffer[bufferSize];

		file = File::Create(_fileName);
		file->Write((VoidPtr)_fileName, String::CStrByteSize(_fileName) + sizeof(TChar));
		file->Seek(0);
		file->Read(buffer, bufferSize);
		DeletePtr(file);
		File::Delete(_fileName);

		String read = buffer;
		CHECK String::Compare(_fileName, read) == 0;

		return result;
	}
コード例 #19
0
// ---------------------------------------------------------------------------
// Cancel transaction
// ---------------------------------------------------------------------------
//	
TInt CCatalogsHttpTransaction::Cancel()
    {
    DLTRACEIN(( "" )); 
    iState.iOperationState = ECatalogsHttpOpDeleting;
    SetTransferring( EFalse );
    if ( iHttp ) 
        {        
        iHttp->CancelTransaction(); 

        DeletePtr( iHttp );        
        }
        
    if ( iState.iProgressState != ECatalogsHttpNone && 
         iState.iProgressState != ECatalogsHttpDone ) 
        {        
        iOwner.CompleteOperation( this );
        }
    DLTRACE(("Calling release"));
    return Release();
    }
コード例 #20
0
ファイル: Thread.Linux.cpp プロジェクト: Karkasos/Core
		ThreadImpl* ThreadImpl::CreateInstance(ThreadFonc threadEntry, VoidPtr threadParam)
		{
			Int32 errCode;
			pthread_t threadID;
			ThreadImpl* thread = new ThreadImpl(threadEntry, threadParam);

			errCode = pthread_create(&threadID, NULL, NativeThreadEntry, (void*)thread);

			if(!errCode)
			{
				thread->_threadID = threadID;
				return thread;
			}
			else
			{
				SetErrCode((UInt32)errCode);
				DeletePtr(thread);
				return NULL;
			}
		}
コード例 #21
0
ファイル: TextFile.cpp プロジェクト: Karkasos/Core
		String TextFile::ReadAll(CStr fileName)
		{
			Assert(fileName);
			File* file;
			String text;
			UInt fileSize;
			UInt length;
			TChar* buffer;

			file = File::OpenReadOnly(fileName);
			if(file)
			{
				fileSize = ToUInt(file->GetFileSize());
				length = fileSize / sizeof(TChar);
				text.Reserve(length);
				buffer = text.DrivePointer(length);
				file->Read(buffer, fileSize);
				DeletePtr(file);
			}

			return text;
		}
コード例 #22
0
ファイル: TextFile.cpp プロジェクト: Karkasos/Core
		void TextFile::AppendAll(CStr fileName, CStr text, UInt textLength)
		{
			TextFile *textFile = TextFile::Append(fileName);
			textFile->Write(text, textLength); 
			DeletePtr(textFile);
		}
コード例 #23
0
ファイル: TextFile.cpp プロジェクト: Karkasos/Core
		void TextFile::WriteLine(CStr text) const
		{
			Assert(_file);
			Write(text);
			Write(NewLine);
		}

		void TextFile::WriteLine(String const & text) const
		{
			Assert(_file);
			WriteLine(text, text.Length());
		}

		void TextFile::WriteLine() const
		{
			Assert(_file);
			Write(NewLine);
		}

		void TextFile::Close()
		{
			DeletePtr(_file)
		}

		TextFile::~TextFile()
		{
			Close();
		}
	}
}
コード例 #24
0
// ---------------------------------------------------------------------------
// Encodes the URI
// ---------------------------------------------------------------------------
//              
void CCatalogsHttpTransaction::EncodeUriL()
    {
    DeletePtr( iEncodedUri );
    iEncodedUri = CatalogsHttpUtils::EncodeUriL( Uri() );
    }
コード例 #25
0
// ---------------------------------------------------------------------------
// Actually starts the transaction
// ---------------------------------------------------------------------------
//	            
void CCatalogsHttpTransaction::DoStartL()
    {
    DLTRACEIN((""));        
    
    DASSERT( iConnection );

    if ( !iOwner.ConnectionManager().AskConnectionConfirmation( 
        Config().ConnectionMethod() ) )
        {
        DLINFO(("Connection denied!"));
        User::Leave( KCatalogsErrorHttpConnectionDenied );
        }

    // If the operation disconnected prematurely it will be restarted
    // so we need to delete the old iHttp
    DeletePtr( iHttp );    
    iHttp = CCatalogsHttpStack::NewL( 
        this,
        *iConnection,
        iOwner.ConnectionCreatorL() );
    
    iHttp->SetConnectionManager( &iOwner.ConnectionManager() );
                
    UpdateRequestHeadersL();    
    const TDesC8* method = &KCatalogsHttpPost;
    // Choose the correct method string
    switch( Config().HttpMethod() ) 
        {
        case ECatalogsHttpGet:
            {
            method = &KCatalogsHttpGet;
            break;
            }
            
        case ECatalogsHttpHead:
            {
            method = &KCatalogsHttpHead;
            }
            
        default:                   
            {
            }                   
        }
    
    iState.iOperationState = ECatalogsHttpOpInProgress;
    iState.iProgressState = ECatalogsHttpStarted;    
    
    if ( iRequestBody ) 
        {
        // Send the request
        iHttp->IssueHttpRequestL( *method, EncodedUri(), ContentType(), 
            *iRequestBody );                    
        }
    else 
        {
        // Send the request with empty body
        iHttp->IssueHttpRequestL( *method, EncodedUri(), ContentType(), 
            KNullDesC8 );
        }        
    
    // Notify observer about operation start    
    // This method can leave so not using NotifyObserver
    iObserver->HandleHttpEventL( *this, iState );    
    
    DLTRACEOUT(("successful"));
    }
コード例 #26
0
ファイル: SPtrArray.cpp プロジェクト: mach0628/comhub
//##ModelId=4049F7440286
void CSPtrArray::SetSize(int nNewSize, int nGrowBy)
{
	// TODO: Add your specialized code here.
	ASSERT(nNewSize >= 0);
	if (nGrowBy != -1)	m_nGrowBy = nGrowBy;  // set new size

	if (nNewSize == 0)
	{
		// shrink to nothing
		if (m_pData != NULL)
		{
			DeletePtr(m_pData, m_nSize);
			delete[] (BYTE*)m_pData;
			m_pData = NULL;
		}
		m_nSize = m_nMaxSize = 0;
	}
	else if (m_pData == NULL)
	{
		// create one with exact size
#ifdef SIZE_T_MAX
//		ASSERT(nNewSize <= SIZE_T_MAX/sizeof(void));    // no overflow
#endif
		m_pData = (void**) new BYTE[nNewSize * sizeof(void *)];
		memset(m_pData,0,nNewSize * sizeof(void *));
		m_nSize = m_nMaxSize = nNewSize;
	}
	else if (nNewSize <= m_nMaxSize)
	{
		// it fits
		if (nNewSize > m_nSize)
		{
			// initialize the new elements
			memset(&m_pData[m_nSize],0, (nNewSize-m_nSize)*sizeof(void*));
		}
		else if (m_nSize > nNewSize)
		{
			// destroy the old elements
			DeletePtr(&m_pData[nNewSize],m_nSize-nNewSize);
			memset(&m_pData[nNewSize],0, (m_nSize-nNewSize)*sizeof(void*));
		}
		m_nSize = nNewSize;
	}
	else
	{
		// otherwise, grow array
		int nGrowBy = m_nGrowBy;
		if (nGrowBy == 0)
		{
			// heuristically determine growth when nGrowBy == 0
			//  (this avoids heap fragmentation in many situations)
			nGrowBy = m_nSize / 8;
			nGrowBy = (nGrowBy < 4) ? 4 : ((nGrowBy > 1024) ? 1024 : nGrowBy);
		}
		int nNewMax;
		if (nNewSize < m_nMaxSize + nGrowBy)
			nNewMax = m_nMaxSize + nGrowBy;  // granularity
		else
			nNewMax = nNewSize;  // no slush

		ASSERT(nNewMax >= m_nMaxSize);  // no wrap around
#ifdef SIZE_T_MAX
//		ASSERT(nNewMax <= SIZE_T_MAX/sizeof(TYPE)); // no overflow
#endif
		void** pNewData = (void **) new BYTE[nNewMax * sizeof(void*)];

		// copy new data from old
		memcpy(pNewData, m_pData, m_nSize * sizeof(void *));

		// construct remaining elements
		ASSERT(nNewSize > m_nSize);
		memset(&pNewData[m_nSize], 0,(nNewSize-m_nSize)*sizeof(void*));

		// get rid of old stuff (note: no destructors called)
		delete[] m_pData;
		m_pData = pNewData;
		m_nSize = nNewSize;
		m_nMaxSize = nNewMax;
	}

}