当前位置: 首页>>代码示例>>C++>>正文


C++ DiskFile类代码示例

本文整理汇总了C++中DiskFile的典型用法代码示例。如果您正苦于以下问题:C++ DiskFile类的具体用法?C++ DiskFile怎么用?C++ DiskFile使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了DiskFile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: while

// Delete all of the partly reconstructed files
bool Par1Repairer::DeleteIncompleteTargetFiles(void) {
	list<Par1RepairerSourceFile*>::iterator sf = verifylist.begin();

	// Iterate through each file in the verification list
	while (sf != verifylist.end()) {
		Par1RepairerSourceFile *sourcefile = *sf;
		if (sourcefile->GetTargetExists()) {
			DiskFile *targetfile = sourcefile->GetTargetFile();

			// Close and delete the file
			if (targetfile->IsOpen())
				targetfile->Close();
			targetfile->Delete();

			// Forget the file
			diskfilemap.Remove(targetfile);

			delete targetfile;

			// There is no target file
			sourcefile->SetTargetExists(false);
			sourcefile->SetTargetFile(0);
		}

		++sf;
	}

	return true;
}
开发者ID:JeanLouisFLOQUET,项目名称:par2cmdline,代码行数:30,代码来源:par1repairer.cpp

示例2: Copy

bool Copy(File& srcFile, const char* destFilename)
{
	// Operate in 16k buffers.
	const DWORD BUFFER_SIZE = 16 * 1024;

	DWORD fileSize = (DWORD)srcFile.GetLength();

	// See if the destination file exists.
	DiskFile destFile;
	if (!destFile.Open(destFilename, File::MODE_CREATE | File::MODE_WRITEONLY))
		return false;

	// Allocate the buffer space.
	BYTE* buffer = (BYTE*)_alloca(BUFFER_SIZE);

	// Keep copying until there is no more file left to copy.
	while (fileSize > 0)
	{
		// Copy the minimum of BUFFER_SIZE or the fileSize.
		DWORD readSize = min(BUFFER_SIZE, fileSize);
		srcFile.Read(buffer, readSize);
		destFile.Write(buffer, readSize);
		fileSize -= readSize;
	}

	// Close the destination virtual file.
	destFile.Close();

	return true;
}
开发者ID:WeyrSDev,项目名称:gamecode3,代码行数:30,代码来源:vdrive.cpp

示例3: format

Image::Image(const char* filename) : format(RGBA32) {
	printf("Image %s\n", filename);
	DiskFile file; file.open(filename, DiskFile::ReadMode);
	uint size = file.getSize();
	int comp;
	data = stbi_load_from_memory((u8*)file.readAll(), size, &width, &height, &comp, 4);
}
开发者ID:ppiecuch,项目名称:Kore,代码行数:7,代码来源:Image.cpp

示例4: Copy

bool Copy(File& srcFile, const char* destFilename)
{
	// Operate in 16k buffers.
	const uint32_t BUFFER_SIZE = 16 * 1024;

	uint32_t fileSize = (uint32_t)srcFile.GetLength();

	if (!Misc::PathCreate(destFilename))
		return false;

	// See if the destination file exists.
	DiskFile destFile;
	if (!destFile.Open(destFilename, File::MODE_CREATE | File::MODE_WRITEONLY))
		return false;

	// Allocate the buffer space.
	BYTE* buffer = (BYTE*)alloca(BUFFER_SIZE);

	// Keep copying until there is no more file left to copy.
	while (fileSize > 0) {
		// Copy the minimum of BUFFER_SIZE or the fileSize.
		uint32_t readSize = BUFFER_SIZE < fileSize ? BUFFER_SIZE : fileSize;
		if (srcFile.Read(buffer, readSize) != readSize)
			return false;
		destFile.Write(buffer, readSize);
		fileSize -= readSize;
	}

	// Close the destination virtual file.
	destFile.Close();

	return true;
}
开发者ID:sanikoyes,项目名称:tools,代码行数:33,代码来源:lziparchive.cpp

示例5: debug

bool RarVolume::Read()
{
	debug("Checking file %s", *m_filename);

	DiskFile file;
	if (!file.Open(m_filename, DiskFile::omRead))
	{
		return false;
	}

	m_version = DetectRarVersion(file);
	file.Seek(0);

	bool ok = false;

	switch (m_version)
	{
		case 3:
			ok = ReadRar3Volume(file);
			break;

		case 5:
			ok = ReadRar5Volume(file);
			break;
	}

	file.Close();
	DecryptFree();

	LogDebugInfo();

	return ok;
}
开发者ID:sanderjo,项目名称:nzbget,代码行数:33,代码来源:RarReader.cpp

示例6: load

	result WavStream::load(const char *aFilename)
	{
		delete[] mFilename;
		delete mMemFile;
		mMemFile = 0;
		mFilename = 0;
		mSampleCount = 0;
		DiskFile fp;
		int res = fp.open(aFilename);
		if (res != SO_NO_ERROR)
			return res;
		
		int len = (int)strlen(aFilename);
		mFilename = new char[len+1];		
		memcpy(mFilename, aFilename, len);
		mFilename[len] = 0;
		
		res = parse(&fp);

		if (res != SO_NO_ERROR)
		{
			delete[] mFilename;
			mFilename = 0;
			return res;
		}

		return 0;
	}
开发者ID:dbralir,项目名称:soloud,代码行数:28,代码来源:soloud_wavstream.cpp

示例7:

bool Par1Repairer::RemoveParFiles(void) {
	if (noiselevel > CommandLine::nlSilent
			&& parlist.size() > 0) {
			cout << endl << "Purge par files." << endl;
	}

	for (list<string>::const_iterator s=parlist.begin(); s!=parlist.end(); ++s) {
		DiskFile *diskfile = new DiskFile;

		if (diskfile->Open(*s)) {
			if (noiselevel > CommandLine::nlSilent) {
				string name;
				string path;
				DiskFile::SplitFilename((*s), path, name);
				cout << "Remove \"" << name << "\"." << endl;
			}

			if (diskfile->IsOpen())
				diskfile->Close();
			diskfile->Delete();
		}

		delete diskfile;
	}

	return true;
}
开发者ID:JeanLouisFLOQUET,项目名称:par2cmdline,代码行数:27,代码来源:par1repairer.cpp

示例8: eng_new

File* DiskFileDevice::open(const ansichar *path, FileModeFlags flags){
    DiskFile* file = eng_new(DiskFile)(this, path, flags);
	if (!file || !file->valid()) {
		eng_delete(file);
		return nullptr;
	}
    return file;
}
开发者ID:F-Wehling,项目名称:raceflection,代码行数:8,代码来源:DiskFileDevice.cpp

示例9: loadParams

	result Sfxr::loadParams(const char *aFilename)
	{
		DiskFile df;
		int res = df.open(aFilename);
		if (res != SO_NO_ERROR)
			return res;
		return loadParamsFile(&df);
	}
开发者ID:Deslon,项目名称:Supernova,代码行数:8,代码来源:soloud_sfxr.cpp

示例10: isdigit

// Scan any extra files specified on the command line
bool Par1Repairer::VerifyExtraFiles(const list<CommandLine::ExtraFile> &extrafiles) {
	for (ExtraFileIterator i=extrafiles.begin();
			 i!=extrafiles.end() && completefilecount<sourcefiles.size();
			 ++i) {
		string filename = i->FileName();

		bool skip = false;

		// Find the file extension
		string::size_type where = filename.find_last_of('.');
		if (where != string::npos) {
			string tail = filename.substr(where+1);

			// Check the the file extension is the correct form
			if ((tail[0] == 'P' || tail[0] == 'p') &&
					(
						((tail[1] == 'A' || tail[1] == 'a') && (tail[2] == 'R' || tail[2] == 'r'))
						||
						(isdigit(tail[1]) && isdigit(tail[2]))
					)) {
				skip = true;
			}
		}

		if (!skip) {
			filename = DiskFile::GetCanonicalPathname(filename);

			// Has this file already been dealt with
			if (diskfilemap.Find(filename) == 0) {
				DiskFile *diskfile = new DiskFile;

				// Does the file exist
				if (!diskfile->Open(filename)) {
					delete diskfile;
					continue;
				}

				// Remember that we have processed this file
				bool success = diskfilemap.Insert(diskfile);
				assert(success);

				// Do the actual verification
				VerifyDataFile(diskfile, 0);
				// Ignore errors

				// We have finished with the file for now
				diskfile->Close();

				// Find out how much data we have found
				UpdateVerificationResults();
			}
		}
	}

	return true;
}
开发者ID:JeanLouisFLOQUET,项目名称:par2cmdline,代码行数:57,代码来源:par1repairer.cpp

示例11: load

	result Wav::load(const char *aFilename)
	{
		DiskFile dr;
		int res = dr.open(aFilename);
		if (res != SO_NO_ERROR)
        {
			return res;
        }
		return testAndLoadFile(&dr);
	}
开发者ID:Deslon,项目名称:Supernova,代码行数:10,代码来源:soloud_wav.cpp

示例12: loadToMem

	result WavStream::loadToMem(const char *aFilename)
	{
		DiskFile df;
		int res = df.open(aFilename);
		if (res == SO_NO_ERROR)
		{
			res = loadFileToMem(&df);
		}
		return res;
	}
开发者ID:dbralir,项目名称:soloud,代码行数:10,代码来源:soloud_wavstream.cpp

示例13: MemoryFile

	WavStreamInstance::WavStreamInstance(WavStream *aParent)
	{
		mParent = aParent;
		mOffset = 0;
		mOgg = 0;
		mFile = 0;
		if (aParent->mMemFile)
		{
			MemoryFile *mf = new MemoryFile();
			mFile = mf;
			mf->openMem(aParent->mMemFile->getMemPtr(), aParent->mMemFile->length(), false, false);
		}
		else
		if (aParent->mFilename)
		{
			DiskFile *df = new DiskFile;
			mFile = df;
			df->open(aParent->mFilename);
		}
		else
		if (aParent->mStreamFile)
		{
			mFile = aParent->mStreamFile;
			mFile->seek(0); // stb_vorbis assumes file offset to be at start of ogg
		}
		else
		{
			return;
		}
		
		if (mFile)
		{
			if (mParent->mOgg)
			{
				int e;

				mOgg = stb_vorbis_open_file((Soloud_Filehack *)mFile, 0, &e, 0);

				if (!mOgg)
				{
					if (mFile != mParent->mStreamFile)
						delete mFile;
					mFile = 0;
				}
				mOggFrameSize = 0;
				mOggFrameOffset = 0;
				mOggOutputs = 0;
			}
			else
			{		
				mFile->seek(aParent->mDataOffset);
			}
		}
	}
开发者ID:dbralir,项目名称:soloud,代码行数:54,代码来源:soloud_wavstream.cpp

示例14: stop

	result Wav::load(const char *aFilename)
	{
		if (aFilename == 0)
			return INVALID_PARAMETER;
		stop();
		DiskFile dr;
		int res = dr.open(aFilename);
		if (res == SO_NO_ERROR)
			return loadFile(&dr);
		return res;
	}
开发者ID:jarikomppa,项目名称:soloud,代码行数:11,代码来源:soloud_wav.cpp

示例15: SaveBufferIntoFile

bool FileSystem::SaveBufferIntoFile(const char* filename, const char* buffer, int bufLen)
{
	DiskFile file;
	if (!file.Open(filename, DiskFile::omWrite))
	{
		return false;
	}

	int writtenBytes = (int)file.Write(buffer, bufLen);
	file.Close();

	return writtenBytes == bufLen;
}
开发者ID:outtahere,项目名称:nzbget,代码行数:13,代码来源:FileSystem.cpp


注:本文中的DiskFile类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。