本文整理汇总了C++中wxFile::Close方法的典型用法代码示例。如果您正苦于以下问题:C++ wxFile::Close方法的具体用法?C++ wxFile::Close怎么用?C++ wxFile::Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxFile
的用法示例。
在下文中一共展示了wxFile::Close方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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;
}
示例3: 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
}
示例4: WXSIZEOF
static bool
wxDoCopyFile(wxFile& fileIn,
const wxStructStat& fbuf,
const wxString& filenameDst,
bool overwrite)
{
// reset the umask as we want to create the file with exactly the same
// permissions as the original one
wxCHANGE_UMASK(0);
// create file2 with the same permissions than file1 and open it for
// writing
wxFile fileOut;
if ( !fileOut.Create(filenameDst, overwrite, fbuf.st_mode & 0777) )
return false;
// copy contents of file1 to file2
char buf[4096];
for ( ;; )
{
ssize_t count = fileIn.Read(buf, WXSIZEOF(buf));
if ( count == wxInvalidOffset )
return false;
// end of file?
if ( !count )
break;
if ( fileOut.Write(buf, count) < (size_t)count )
return false;
}
// we can expect fileIn to be closed successfully, but we should ensure
// that fileOut was closed as some write errors (disk full) might not be
// detected before doing this
return fileIn.Close() && fileOut.Close();
}