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


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

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

示例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;
}
开发者ID:jmickle66666666,项目名称:SLADE,代码行数:37,代码来源:MemChunk.cpp

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

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

示例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"));
}
开发者ID:boulerne,项目名称:e,代码行数:14,代码来源:Env.cpp

示例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();
    }
}
开发者ID:BackupTheBerlios,项目名称:wxwebcore-svn,代码行数:19,代码来源:KWQFile.cpp

示例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;
}
开发者ID:renemilk,项目名称:springlobby,代码行数:23,代码来源:replaylist.cpp


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