本文整理汇总了C++中wxFile::Length方法的典型用法代码示例。如果您正苦于以下问题:C++ wxFile::Length方法的具体用法?C++ wxFile::Length怎么用?C++ wxFile::Length使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxFile
的用法示例。
在下文中一共展示了wxFile::Length方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: CheckHeader
// Decryption.
bool CheckHeader(wxFile& pkg_f, PKGHeader* m_header)
{
if (m_header->pkg_magic != 0x7F504B47) {
ConLog.Error("PKG: Not a package file!");
return false;
}
switch (m_header->pkg_type)
{
case PKG_RELEASE_TYPE_DEBUG: break;
case PKG_RELEASE_TYPE_RELEASE: break;
default:
ConLog.Error("PKG: Unknown PKG type!");
return false;
}
switch (m_header->pkg_platform)
{
case PKG_PLATFORM_TYPE_PS3: break;
case PKG_PLATFORM_TYPE_PSP: break;
default:
ConLog.Error("PKG: Unknown PKG type!");
return false;
}
if (m_header->header_size != PKG_HEADER_SIZE) {
ConLog.Error("PKG: Wrong header size!");
return false;
}
if (m_header->pkg_size != pkg_f.Length()) {
ConLog.Error("PKG: File size mismatch.");
return false;
}
if (m_header->data_size + m_header->data_offset + 0x60 != pkg_f.Length()) {
ConLog.Error("PKG: Data size mismatch.");
return false;
}
return true;
}
示例6: 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
}
示例7: 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 ;
}
示例8: 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;
}