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


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

本文整理汇总了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;
}
开发者ID:stahta01,项目名称:codeblocks_https_metadata,代码行数:29,代码来源:globals.cpp

示例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;
}
开发者ID:stahta01,项目名称:codeblocks_https_metadata,代码行数:14,代码来源:globals.cpp

示例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
}
开发者ID:azmeuk,项目名称:nwc2xml,代码行数:40,代码来源:nwcfile.cpp

示例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();
}
开发者ID:mheinsen,项目名称:wxWidgets,代码行数:38,代码来源:filefn.cpp


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