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


C++ wxFile类代码示例

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


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


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