本文整理汇总了C++中wxFile::IsOpened方法的典型用法代码示例。如果您正苦于以下问题:C++ wxFile::IsOpened方法的具体用法?C++ wxFile::IsOpened怎么用?C++ wxFile::IsOpened使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxFile
的用法示例。
在下文中一共展示了wxFile::IsOpened方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: TestFd
// test a wxFile and wxFileInput/OutputStreams of a known type
//
void FileKindTestCase::TestFd(wxFile& file, bool expected)
{
CPPUNIT_ASSERT(file.IsOpened());
CPPUNIT_ASSERT((wxGetFileKind(file.fd()) == wxFILE_KIND_DISK) == expected);
CPPUNIT_ASSERT((file.GetKind() == wxFILE_KIND_DISK) == expected);
wxFileInputStream inStream(file);
CPPUNIT_ASSERT(inStream.IsSeekable() == expected);
wxFileOutputStream outStream(file);
CPPUNIT_ASSERT(outStream.IsSeekable() == expected);
}
示例4: cbWrite
// Writes a wxString to a file. File must be open. File is closed automatically.
bool cbWrite(wxFile& file, const wxString& buff, wxFontEncoding encoding)
{
bool result = false;
if (file.IsOpened())
{
wxCSConv conv(encoding);
result = file.Write(buff,conv);
if (result)
file.Flush();
file.Close();
}
return result;
}
示例5: WriteEnvToFile
void cxEnv::WriteEnvToFile(wxFile& file) const {
wxASSERT(file.IsOpened());
for (map<wxString, wxString>::const_iterator p = m_env.begin(); p != m_env.end(); ++p) {
wxString line = p->first;
line += wxT('=');
line += p->second;
line += wxT('\n');
file.Write(line);
}
file.Write(wxT("\n"));
}
示例6: GetFileSizeImpl
static uint GetFileSizeImpl(wxFile& file, const wxString& name)
{
if (file.IsOpened())
{
wxFileOffset pos = file.Tell();
file.SeekEnd();
wxFileOffset size = file.Tell();
file.Seek(pos);
return size;
}
else
{
wxFile file2(name, wxFile::read);
if (!file2.IsOpened())
return 0;
file2.SeekEnd();
return file2.Tell();
}
}
示例7: 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;
}