Пример #1
0
bool MkFileChunk::AttachOriginalFiles
(const MkPathName& chunkFilePath, MkFilePathListContainer& filePathListContainer, MkArray<MkPathName>& memberFilePathList,
 unsigned int chunkSizeGuideline, unsigned int percentageForCompressing, bool createNewChunk)
{
	memberFilePathList.Clear();

	MkArray<MkPathName>& relativeFilePathList = filePathListContainer.GetRelativeFilePathList();
	unsigned int startCount = relativeFilePathList.GetSize();
	MK_CHECK(startCount > 0, L"파일 경로 리스트가 비어 " + m_AbsoluteChunkFilePath + L" 청크 파일 구성 불가")
		return false;

	if (createNewChunk)
	{
		MK_CHECK(!chunkFilePath.IsDirectoryPath(), chunkFilePath + L" 청크 파일 경로 오류")
			return false;

		Clear();

		// 새 청크 파일 이름
		m_AbsoluteChunkFilePath.ConvertToRootBasisAbsolutePath(chunkFilePath);
	}

	// 크기 예약
	m_BlockList.Reserve(m_BlockList.GetSize() + startCount);
	memberFilePathList.Reserve(startCount);

	// 인터페이스 생성. createNewChunk에 따라 청크 파일 생성
	MkInterfaceForFileWriting chunkFileInterface;
	if (!chunkFileInterface.SetUp(m_AbsoluteChunkFilePath, createNewChunk))
		return false;

	// 새 청크 파일의 경우 블록 카운트를 기록하기 위한 태그 공간 확보
	if (createNewChunk)
	{
		m_ChunkSize = sizeof(unsigned int);
		_AddCountTag(chunkFileInterface, m_ChunkSize);
	}

	// 뒤에서부터 앞으로 순회
	MK_INDEXING_RLOOP(relativeFilePathList, i)
	{
		const MkPathName& currPath = filePathListContainer.GetRelativeFilePath(i);

		MkFileBlock& currBlock = m_BlockList.PushBack();
		unsigned int blockSize = currBlock.SetUpFromOriginalFileAndAttachToChunkFile
			(filePathListContainer.GetAbsoluteOriginalFilePath(i), currPath, chunkFileInterface, percentageForCompressing, filePathListContainer.GetOuterWrittenTime(i));

		if (blockSize == 0)
		{
			if (createNewChunk)
			{
				m_AbsoluteChunkFilePath.DeleteCurrentFile();
			}
			return false;
		}

		memberFilePathList.PushBack(currPath);

		++m_AvailableBlockCount;

		m_ChunkSize += blockSize;
		if (m_ChunkSize >= chunkSizeGuideline)
			break;
	}

	chunkFileInterface.Clear();

	// 블록 카운트 수정
	MkInterfaceForFileTag<unsigned int> ftInterface;
	if (!ftInterface.SetUp(m_AbsoluteChunkFilePath))
	{
		if (createNewChunk)
		{
			m_AbsoluteChunkFilePath.DeleteCurrentFile();
		}
		return false;
	}

	ftInterface.Overwrite(m_BlockList.GetSize(), 0);
	ftInterface.Clear();

	// 청크에 구성된 파일들을 리스트에서 삭제
	filePathListContainer.PopBack(memberFilePathList.GetSize());
	return true;
}
Пример #2
0
void MkShaderEffectPool::SetUp(const MkPathName& shaderDirectory)
{
	LPDIRECT3DDEVICE9 device = MK_DEVICE_MGR.GetDevice();
	MK_CHECK(device != NULL, L"NULL device여서 MkShaderEffectPool 초기화 실패")
		return;

	// 경로 점검
	MkPathName dirPath;
	dirPath.ConvertToRootBasisAbsolutePath(shaderDirectory);
	dirPath.CheckAndAddBackslash();
	MK_CHECK(dirPath.IsDirectoryPath() && dirPath.CheckAvailable(), dirPath + L" 경로가 존재하지 않아 MkShaderEffectPool 초기화 실패")
		return;

	// fxo 파일 검색
	MkArray<MkPathName> filePathList;
	MkArray<MkPathName> emptyFilter;
	MkArray<MkStr> prefixFilter;
	MkArray<MkPathName> extensionFilter;
	extensionFilter.PushBack(L"fxo");
	dirPath.GetWhiteFileList(filePathList, emptyFilter, extensionFilter, prefixFilter, emptyFilter, false, false);

	MK_INDEXING_LOOP(filePathList, i)
	{
		MkHashStr effectName = filePathList[i].GetFileName(false);
		MkPathName currFilePath = dirPath + filePathList[i];
		unsigned int fileSize = currFilePath.GetFileSize();
		unsigned int writtenTime = currFilePath.GetWrittenTime();
		
		if (m_Pool.Exist(effectName))
		{
			_EffectData& ed = m_Pool[effectName];
			if ((ed.fileSize != fileSize) || (ed.fileWrittenTime != writtenTime)) // 크기/수정일시 변경 확인
			{
				ed.effect->Clear();
				if (ed.effect->SetUp(effectName, currFilePath))
				{
					ed.fileSize = fileSize;
					ed.fileWrittenTime = writtenTime;

					MK_DEV_PANEL.MsgToLog(effectName.GetString() + L" effect 갱신");
				}
				else
				{
					delete ed.effect;
					m_Pool.Erase(effectName);
				}
			}
		}
		else
		{
			MkShaderEffect* effect = new MkShaderEffect;
			MK_CHECK(effect != NULL, effectName.GetString() + L" effect 객체 생성 실패")
				continue;

			if (effect->SetUp(effectName, currFilePath))
			{
				_EffectData& ed = m_Pool.Create(effectName);
				ed.effect = effect;
				ed.fileSize = fileSize;
				ed.fileWrittenTime = writtenTime;

				MK_DEV_PANEL.MsgToLog(effectName.GetString() + L" effect 생성");
			}
			else
			{
				delete effect;
			}
		}
	}