#include "IFSFile.h" #include "IFSContentProvider.h" namespace LifeCore { IFSFile::IFSFile() { } IFSFile::IFSFile(const String& path, int size) { isOpen = false; EntryName = path; HANDLE file = CreateFileA(path.c_str(), GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if(GetLastError() != ERROR_ALREADY_EXISTS) { if(size > 0) { SetFilePointer(file, size - 1, 0, FILE_BEGIN); char data = 0; DWORD numWrite = 0; WriteFile(file, &data, 1, &numWrite, NULL); } } CloseHandle(file); } bool IFSFile::ReadAsync(char* buffer, size_t count_read) { UNREFERENCED_PARAMETER(buffer); UNREFERENCED_PARAMETER(count_read); //TODO read! return true; } IDataStreamPtr IFSFile::OpenWrite(int mode) { UNREFERENCED_PARAMETER(mode); g_stream = new IFSStream(EntryName, FA_WRITE, this->Size); return IDataStreamPtr(g_stream); } IDataStreamPtr IFSFile::OpenReadWrite(int mode) { UNREFERENCED_PARAMETER(mode); return IDataStreamPtr(0); //throw new NotImplementedException(); } IDataStreamPtr IFSFile::OpenRead() { g_stream = new IFSStream(EntryName, FA_READ, this->Size); return IDataStreamPtr(g_stream); //g_stream = new IZipStream((this->Provider as IZipFileContentProvider).GetSource(), EntryName, FA_READ); //return g_stream; } void IFSFile::Close() { if(g_stream) { g_stream->Close(); delete g_stream; } } }