• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ wxFile类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中wxFile的典型用法代码示例。如果您正苦于以下问题:C++ wxFile类的具体用法?C++ wxFile怎么用?C++ wxFile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了wxFile类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: MakeSaveState

void MakeSaveState(wxFile& f)
{
	const ArrayF<MemoryBlock>& mb = Memory.MemoryBlocks;
	
	state_hdr state;
	memset(&state, 0, sizeof(state_hdr));
	
	state.magic = state_magic;
	state.version = state_version;
	state.mem_count = mb.GetCount();
	//state.hle_count = mb.GetCount();
	
	state.mem_offset = sizeof(state_hdr) + 4;
	
	f.Seek(state.mem_offset);
	for(u32 i=0; i<state.mem_count; ++i)
	{
		state.mem_size += mb[i].GetSize();
		f.Write(mb[i].GetMem(), mb[i].GetSize());
	}

	state.hle_offset = state.mem_offset + state.mem_size + 4;

	f.Seek(0);
	f.Write(&state, sizeof(state_hdr));
}
开发者ID:252525fb,项目名称:rpcs3,代码行数:26,代码来源:MainFrame.cpp


示例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;
}
开发者ID:bestdpf,项目名称:xface-error,代码行数:32,代码来源:ControlPanel.cpp


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


示例4: 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


示例5: replayVersion

int ReplayList::replayVersion(wxFile& replay) const
{
	if (replay.Seek(16) == wxInvalidOffset) {
		return 0;
	}
	int version = 0;
	replay.Read(&version, 4);
	return version;
}
开发者ID:UdjinM6,项目名称:springlobby,代码行数:9,代码来源:replaylist.cpp


示例6: saveBuilderPaths

/* NodeBuilders::saveBuilderPaths
 * Writes builder paths to [file]
 *******************************************************************/
void NodeBuilders::saveBuilderPaths(wxFile& file)
{
	file.Write("nodebuilder_paths\n{\n");
	for (unsigned a = 0; a < builders.size(); a++)
	{
		string path = builders[a].path;
		path.Replace("\\", "/");
		file.Write(S_FMT("\t%s \"%s\"\n", builders[a].id, path));
	}
	file.Write("}\n");
}
开发者ID:Blue-Shadow,项目名称:SLADE,代码行数:14,代码来源:NodeBuilders.cpp


示例7: LoadEntries

// Unpacking.
bool LoadEntries(wxFile& dec_pkg_f, PKGHeader* m_header, PKGEntry *m_entries)
{
	dec_pkg_f.Seek(0);
	dec_pkg_f.Read(m_entries, sizeof(PKGEntry) * m_header->file_count);
	
	if (m_entries->name_offset / sizeof(PKGEntry) != m_header->file_count) {
		ConLog.Error("PKG: Entries are damaged!");
		return false;
	}

	return true;
}
开发者ID:MissValeska,项目名称:rpcs3,代码行数:13,代码来源:unpkg.cpp


示例8: CPPUNIT_ASSERT

// 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


示例9: 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


示例10: LoadHeader

bool LoadHeader(wxFile& pkg_f, PKGHeader* m_header)
{
	pkg_f.Seek(0);
	
	if (pkg_f.Read(m_header, sizeof(PKGHeader)) != sizeof(PKGHeader)) {
		ConLog.Error("PKG: Package file is too short!");
		return false;
	}

	if (!CheckHeader(pkg_f, m_header))
		return false;

	return true;
}
开发者ID:MissValeska,项目名称:rpcs3,代码行数:14,代码来源:unpkg.cpp


示例11: writeStringInFile

Status_e FileText::writeStringInFile(wxFile& file, wxString const& str)
{
    uint8_t sizeStr = strlen(str.fn_str());

    //Écriture de la taille du texte.
    if(file.Write(&sizeStr, sizeof sizeStr) != sizeof sizeStr)
        return STATUS_FILE_WRITE_ERROR;

    //Écriture du texte.
    if(!file.Write(str))
        return STATUS_FILE_WRITE_ERROR;

    return STATUS_SUCCESS;
}
开发者ID:antoine163,项目名称:Talv,代码行数:14,代码来源:fileText.cpp


示例12: 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


示例13: SJ_WINDOW_DISABLER

// pass an uninitialized file object, the function will ask the user for the
// filename and try to open it, returns true on success (file was opened),
// false if file couldn't be opened/created and -1 if the file selection
// dialog was cancelled
int SjLogDialog::OpenLogFile(wxFile& file, wxString& retFilename)
{
	SJ_WINDOW_DISABLER(this);

	// get the file name
	// -----------------
	SjExtList extList; extList.AddExt(wxT("txt"));
	wxFileDialog dlg(this, _("Save"), wxT(""), wxT("log.txt"), extList.GetFileDlgStr(wxFD_SAVE), wxFD_SAVE|wxFD_CHANGE_DIR);
	if( dlg.ShowModal() != wxID_OK ) { return -1; }
	wxString filename = dlg.GetPath();

	// open file
	// ---------
	bool bOk wxDUMMY_INITIALIZE(false);
	if ( wxFile::Exists(filename) )
	{
		wxASSERT( wxYES != wxCANCEL );
		wxASSERT( wxNO != wxCANCEL );
		bool bAppend = false;
		switch( SjMessageBox(wxString::Format(_("Overwrite \"%s\"?"), filename.c_str()), SJ_PROGRAM_NAME,
		                     wxICON_QUESTION | wxYES_NO | wxCANCEL, this, NULL, NULL, _("Yes"), _("Append")) )
		{
			case wxYES:
				bAppend = false;
				break;

			case wxNO:
				bAppend = true;
				break;

			default:
				return -1;
		}

		if ( bAppend ) {
			bOk = file.Open(filename, wxFile::write_append);
		}
		else {
			bOk = file.Create(filename, true /* overwrite */);
		}
	}
	else {
		bOk = file.Create(filename);
	}

	retFilename = filename;

	return bOk;
}
开发者ID:conradstorz,项目名称:silverjuke,代码行数:53,代码来源:console.cpp


示例14: readStringInFile

Status_e FileText::readStringInFile(wxFile& file, wxString* str)const
{
    uint8_t sizeStr;

    //Lecture de la taille du texte.
    if(file.Read(&sizeStr, sizeof sizeStr) != sizeof sizeStr)
        return STATUS_FILE_READ_ERROR;

    //Lecture du texte.
    wxMemoryBuffer buffer;
    if(file.Read(buffer.GetWriteBuf(sizeStr), sizeStr) != sizeStr)
        return STATUS_FILE_READ_ERROR;
    buffer.UngetWriteBuf(sizeStr);

    str->Clear();
    str->Append(wxString::FromUTF8Unchecked((const char *)buffer.GetData(), buffer.GetDataLen()));

    return STATUS_SUCCESS;
}
开发者ID:antoine163,项目名称:Talv,代码行数:19,代码来源:fileText.cpp


示例15: 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


示例16: 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;
}
开发者ID:MissValeska,项目名称:rpcs3,代码行数:43,代码来源:unpkg.cpp


示例17: filePointerAfterHeader

Status_e FileText::filePointerAfterHeader(wxFile& file)const
{
    uint8_t sizelg;

    //Lecture de la taille du premier langage.
    if(file.Read(&sizelg, sizeof sizelg) != sizeof sizelg)
        return STATUS_FILE_READ_ERROR;

    //Pointer sur la taille du deuxième langage.
    if(file.Seek(sizelg, wxFromCurrent) ==  wxInvalidOffset)
        return STATUS_FILE_READ_ERROR;

    //Lecture de la taille du deuxième langage.
    if(file.Read(&sizelg, sizeof sizelg) != sizeof sizelg)
        return STATUS_FILE_READ_ERROR;

    //Pointer sur la taille du premier texte ou la fin du fichier
    file.Seek(sizelg, wxFromCurrent);

    return STATUS_SUCCESS;
}
开发者ID:antoine163,项目名称:Talv,代码行数:21,代码来源:fileText.cpp


示例18: UncompressNSave

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


示例19: 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


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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ wxFileConfig类代码示例发布时间:2022-05-31
下一篇:
C++ wxFSFile类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap