本文整理汇总了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;
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}
示例6: replayVersion
int ReplayList::replayVersion(wxFile& replay) const
{
if (replay.Seek(16) == wxInvalidOffset) {
return 0;
}
int version = 0;
replay.Read(&version, 4);
return version;
}
示例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;
}
示例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;
}
示例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;
}
示例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 ;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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
}