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


C++ wxFile::Read方法代码示例

本文整理汇总了C++中wxFile::Read方法的典型用法代码示例。如果您正苦于以下问题:C++ wxFile::Read方法的具体用法?C++ wxFile::Read怎么用?C++ wxFile::Read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在wxFile的用法示例。


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

示例1: importFileStream

/* MemChunk::importFileStream
 * Loads a file (or part of it) from a currently open file stream
 * into the MemChunk
 * Returns false if file couldn't be opened, true otherwise
 *******************************************************************/
bool MemChunk::importFileStream(wxFile& file, uint32_t len)
{
	// Check file
	if (!file.IsOpened())
		return false;

	// Clear current data if it exists
	clear();

	// Get current file position
	uint32_t offset = file.Tell();

	// If length isn't specified or exceeds the file length,
	// only read to the end of the file
	if (offset + len > file.Length() || len == 0)
		len = file.Length() - offset;

	// Setup variables
	size = len;

	// Read the file
	if (size > 0)
	{
		//data = new uint8_t[size];
		if (allocData(size))
			file.Read(data, size);
		else
			return false;
	}

	return true;
}
开发者ID:jmickle66666666,项目名称:SLADE,代码行数:37,代码来源:MemChunk.cpp

示例2: SendWav

bool ControlPanel::SendWav(wxFile& wavfile)
{
	if(m_pSocket->IsDisconnected())
		return false;
	::wxMilliSleep(100);
	
	char* data = new char[wavfile.Length()];
	wavfile.Read(data, wavfile.Length());
	m_pSocket->SaveState();
	m_pSocket->SetFlags(wxSOCKET_WAITALL | wxSOCKET_BLOCK);

	m_pSocket->WaitForWrite();
	m_pSocket->Write(data, wavfile.Length());
/*	
	int writeStep = ( wavfile.Length()>1024 ? 1024 : wavfile.Length());	// send blocks of 128 bytes
	int sent = 0;
	while(sent < wavfile.Length())
	{
		m_pSocket->Write(&data[sent], writeStep);
		if(m_pSocket->Error())
		{
			wxLogMessage("Error sending wav!");
			return false;
		}
		sent += m_pSocket->LastCount();
	//	::wxUsleep(5);
	}
*/	
//	wxLogMessage(_T("Wav file is sent! %d bytes"), m_pSocket->LastCount());
	m_pSocket->RestoreState();
	return true;
}
开发者ID:bestdpf,项目名称:xface-error,代码行数:32,代码来源:ControlPanel.cpp

示例3: ImportFile

size_t WBinaryPage::ImportFile(wxFile& file)
{
    wxFileOffset filesize = file.Length();

    wmain->statusbar->ProgressStart(wxString(_("Importing")).mb_str(), Enctain::PI_GENERIC,
                                    0, filesize);

    bindata.SetBufSize(filesize);

    char buffer[65536];

    for (int i = 0; !file.Eof(); i++)
    {
        size_t rb = file.Read(buffer, sizeof(buffer));
        if (rb == 0) break;

        bindata.AppendData(buffer, rb);

        wmain->statusbar->ProgressUpdate(bindata.GetDataLen());
    }

    listctrl->UpdateData();
    needsave = true;

    wmain->statusbar->ProgressStop();

    return bindata.GetDataLen();
}
开发者ID:bingmann,项目名称:cryptote,代码行数:28,代码来源:wbinpage.cpp

示例4: cbRead

// Reads a wxString from a file. File must be open. File is closed automatically.
bool cbRead(wxFile& file, wxString& st, wxFontEncoding encoding)
{
    st.Empty();
    if (!file.IsOpened())
        return false;

    int len = file.Length();
    if (!len)
    {
        file.Close();
        return true;
    }

    char* buff = new char[len+1];
    if (!buff) // remark by killerbot : this is useless, since when out of mem --> exception (this is not malloc you know)
    {
        file.Close();
        return false;
    }
    file.Read((void*)buff, len);
    file.Close();
    buff[len]='\0';

    DetectEncodingAndConvert(buff, st, encoding);
    delete [] buff;

    return true;
}
开发者ID:stahta01,项目名称:codeblocks_https_metadata,代码行数:29,代码来源:globals.cpp

示例5: OldFiles_Test

Ztring OldFiles_Test ()
{
    //Checking version in Info_Version
    ToShow+=__T("Version checked : ");
    F.Open(__T("../Source/MediaInfo/MediaInfo_Config.cpp"));
    I=F.Read(C, 1000000);
    if (!I)
    {
        ToShow+=__T("Error opening ../Source/MediaInfo/MediaInfo_Config.cpp");
        return ToShow;
    }
    C[I]=0;
    Z.From_Local(C);
    Version=Z.SubString(__T("MediaInfoLib - v"), __T("\")"));
    if (Version.size()!=7)
    {
        ToShow+=__T("Error reading ../Source/MediaInfo/MediaInfo.cpp : \"MediaInfoLib - vX.X.X.X - \" not found");
        return ToShow;
    }
    Version_Short=Version; Version_Short.resize(3);
    ToShow+=Version+__T("\r\n");

    //Checking version in MediaInfo.h
    if (Test_Version("../Source/MediaInfo/MediaInfo.h", "@version ", "\n")) return ToShow;
    if (Test_Version("../Source/MediaInfo/MediaInfoList.h", "@version ", "\n")) return ToShow;
    if (Test_Version("../Project/MSVC/Dll/MediaInfo.rc", " FILEVERSION ", "\n")) return ToShow;
    if (Test_Version("../Project/MSVC/Dll/MediaInfo.rc", " PRODUCTVERSION ", "\n")) return ToShow;
    if (Test_Version("../Project/MSVC/Dll/MediaInfo.rc", "            VALUE \"FileVersion\", \"", "\"")) return ToShow;
    if (Test_Version("../Project/MSVC/Dll/MediaInfo.rc", "            VALUE \"ProductVersion\", \"", "\"")) return ToShow;
    if (Test_Version("../History.txt", "Version ", " ")) return ToShow;
    if (Test_Date(__T("MSVC/Library/MediaInfo.lib"))) return ToShow;
    if (Test_Date(__T("MSVC/Dll/MediaInfo.dll"))) return ToShow;

    return ToShow;
}
开发者ID:0vermind,项目名称:NeoLoader,代码行数:35,代码来源:OldFiles.cpp

示例6: replayVersion

int ReplayList::replayVersion(wxFile& replay) const
{
	if (replay.Seek(16) == wxInvalidOffset) {
		return 0;
	}
	int version = 0;
	replay.Read(&version, 4);
	return version;
}
开发者ID:UdjinM6,项目名称:springlobby,代码行数:9,代码来源:replaylist.cpp

示例7: readStringInFile

Status_e FileText::readStringInFile(wxFile& file, wxString* str)const
{
    uint8_t sizeStr;

    //Lecture de la taille du texte.
    if(file.Read(&sizeStr, sizeof sizeStr) != sizeof sizeStr)
        return STATUS_FILE_READ_ERROR;

    //Lecture du texte.
    wxMemoryBuffer buffer;
    if(file.Read(buffer.GetWriteBuf(sizeStr), sizeStr) != sizeStr)
        return STATUS_FILE_READ_ERROR;
    buffer.UngetWriteBuf(sizeStr);

    str->Clear();
    str->Append(wxString::FromUTF8Unchecked((const char *)buffer.GetData(), buffer.GetDataLen()));

    return STATUS_SUCCESS;
}
开发者ID:antoine163,项目名称:Talv,代码行数:19,代码来源:fileText.cpp

示例8: filePointerAfterHeader

Status_e FileText::filePointerAfterHeader(wxFile& file)const
{
    uint8_t sizelg;

    //Lecture de la taille du premier langage.
    if(file.Read(&sizelg, sizeof sizelg) != sizeof sizelg)
        return STATUS_FILE_READ_ERROR;

    //Pointer sur la taille du deuxième langage.
    if(file.Seek(sizelg, wxFromCurrent) ==  wxInvalidOffset)
        return STATUS_FILE_READ_ERROR;

    //Lecture de la taille du deuxième langage.
    if(file.Read(&sizelg, sizeof sizelg) != sizeof sizelg)
        return STATUS_FILE_READ_ERROR;

    //Pointer sur la taille du premier texte ou la fin du fichier
    file.Seek(sizelg, wxFromCurrent);

    return STATUS_SUCCESS;
}
开发者ID:antoine163,项目名称:Talv,代码行数:21,代码来源:fileText.cpp

示例9: LoadEntries

// Unpacking.
bool LoadEntries(wxFile& dec_pkg_f, PKGHeader* m_header, PKGEntry *m_entries)
{
	dec_pkg_f.Seek(0);
	dec_pkg_f.Read(m_entries, sizeof(PKGEntry) * m_header->file_count);
	
	if (m_entries->name_offset / sizeof(PKGEntry) != m_header->file_count) {
		ConLog.Error("PKG: Entries are damaged!");
		return false;
	}

	return true;
}
开发者ID:MissValeska,项目名称:rpcs3,代码行数:13,代码来源:unpkg.cpp

示例10: GetHeaderInfo

void ReplayList::GetHeaderInfo(wxFile& replay, StoredGame& rep, const int version) const
{
	const int seek = 72 + (version < 5 ? 0 : 240);
	if (replay.Seek(seek) == wxInvalidOffset) {
		return;
	}
	int gametime = 0;
	replay.Read(&gametime, 4);
	rep.duration = gametime;
	rep.size = replay.Length();
	//! \todo don't use long long? (pedantic)
	wxLongLong_t unixtime = 0;
	if (replay.Seek(56) == wxInvalidOffset) {
		return;
	}
	replay.Read(&unixtime, 8);
	wxDateTime dt;
	dt.Set((time_t)unixtime);
	// todo: add 2 strings one for date other for time?
	rep.date_string = STD_STRING(dt.FormatISODate() + _T(" ") + dt.FormatISOTime());
	//  rep.date = (time_t) unixtime ;
}
开发者ID:UdjinM6,项目名称:springlobby,代码行数:22,代码来源:replaylist.cpp

示例11: GetScriptFromReplay

wxString ReplayList::GetScriptFromReplay(wxFile& replay, const int version) const
{

	wxString script;
	if ( !replay.IsOpened() ) return script;
	if(replay.Seek(20)==wxInvalidOffset) {
		return script;
	}
	int headerSize=0 ;
	replay.Read( &headerSize, 4);
	const int seek = 64 + (version < 5 ? 0 : 240);
	if(replay.Seek(seek)==wxInvalidOffset) {
		return script;
	}
	wxFileOffset scriptSize=0;
	replay.Read( &scriptSize, 4);
	scriptSize = LSL::Util::Clamp( wxFileOffset(scriptSize), wxFileOffset(0), replay.Length() );
	if(replay.Seek(headerSize) == wxInvalidOffset)return script;
	std::string script_a(scriptSize,0);
	replay.Read( &script_a[0], scriptSize );
	script = TowxString( script_a ) ;//(script_a,scriptSize);
	return script;
}
开发者ID:renemilk,项目名称:springlobby,代码行数:23,代码来源:replaylist.cpp

示例12: LoadHeader

bool LoadHeader(wxFile& pkg_f, PKGHeader* m_header)
{
	pkg_f.Seek(0);
	
	if (pkg_f.Read(m_header, sizeof(PKGHeader)) != sizeof(PKGHeader)) {
		ConLog.Error("PKG: Package file is too short!");
		return false;
	}

	if (!CheckHeader(pkg_f, m_header))
		return false;

	return true;
}
开发者ID:MissValeska,项目名称:rpcs3,代码行数:14,代码来源:unpkg.cpp

示例13: UnpackEntry

bool UnpackEntry(wxFile& dec_pkg_f, const PKGEntry& entry, std::string dir)
{
	u8 buf[BUF_SIZE];

	dec_pkg_f.Seek(entry.name_offset);
	dec_pkg_f.Read(buf, entry.name_size);
	buf[entry.name_size] = 0;
	
	switch (entry.type & (0xff))
	{
		case PKG_FILE_ENTRY_NPDRM:
		case PKG_FILE_ENTRY_NPDRMEDAT:
		case PKG_FILE_ENTRY_SDAT:
		case PKG_FILE_ENTRY_REGULAR:
		{
			wxFile out;
			out.Create(dir + buf);
			dec_pkg_f.Seek(entry.file_offset);

			for (u64 size = 0; size < entry.file_size; ) {
				size += dec_pkg_f.Read(buf, BUF_SIZE);
				if (size > entry.file_size)
					out.Write(buf, BUF_SIZE - (size - entry.file_size));
				else
					out.Write(buf, BUF_SIZE);
			}
			out.Close();
		}
		break;
			
		case PKG_FILE_ENTRY_FOLDER:
			wxMkdir(dir + buf);
		break;
	}
	return true;
}
开发者ID:MissValeska,项目名称:rpcs3,代码行数:36,代码来源:unpkg.cpp

示例14: Test_Version

int Test_Version(char* FileName_, char* Begin, char* End)
{
    wxString FileName=Ztring().From_Local(FileName_).c_str();
    //Opening File
    F.Open(FileName);
    I=F.Read(C, 1000000);
    if (!I)
    {
        ToShow+=__T("Error opening ")+FileName;
        return -1;
    }

    //Getting information
    C[I]=0;
    Z.From_Local(C);
    Z=Z.SubString(Ztring().From_Local(Begin), Ztring().From_Local(End));

    //deleting extra bytes
    if (Z[Z.size()-1]=='\n')
        Z.resize(Z.size()-1);
    if (Z[Z.size()-1]=='\r')
        Z.resize(Z.size()-1);

    //Testing validity
    if (Z.size()!=3 && Z.size()!=7) //non long, no short
    {
        ToShow+=__T("Error reading ")+FileName;
        return -2;
    }

    //Reformtation information
    Z.FindAndReplace(__T(","), __T("."), 0, Ztring_Recursive);

    if (Z!=Version && Z!=Version_Short)
    {
        ToShow+=FileName;
        ToShow+=__T(" is not good : version is marked ");
        ToShow+=Z;
        ToShow+=__T("\r\n");
    }
    return 0;
}
开发者ID:0vermind,项目名称:NeoLoader,代码行数:42,代码来源:OldFiles.cpp

示例15: LoadCompressed

DWORD CNWCFile::LoadCompressed(wxFile& in, FILE* out, FILELOAD fl)
{
#define HEADER_SIZE	6

	long lSize = in.Length();
	if ( lSize <= HEADER_SIZE )
		return ERROR_INVALID_DATA;

	wxString strTmpName = wxFileName::CreateTempFileName(_T("N2X"));

	DWORD dwResult = ERROR_GEN_FAILURE;
	// save compressed file content without [NWZ]\0
	{
		TByteArray dtCompressed;
		dtCompressed.SetCount(lSize - HEADER_SIZE);
		in.Seek(HEADER_SIZE, wxFromStart);
		in.Read(&dtCompressed[0], lSize-HEADER_SIZE);
		in.Close();

		dwResult = UncompressNSave(strTmpName, &dtCompressed[0], dtCompressed.GetCount());
		if ( ERROR_SUCCESS != dwResult )
		{
			wxRemoveFile(strTmpName);
			return dwResult;
		}
	}

	wxFile file;
	if ( file.Open(strTmpName) )
	{
		dwResult = Load(file, out, fl);

		file.Close();
	}

	wxRemoveFile(strTmpName);

	return dwResult;
#undef	HEADER_SIZE
}
开发者ID:azmeuk,项目名称:nwc2xml,代码行数:40,代码来源:nwcfile.cpp


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