예제 #1
0
/*static*/
void wxMemoryFSHandlerBase::AddFileWithMimeType(const wxString& filename,
                                                const wxString& textdata,
                                                const wxString& mimetype)
{
    AddFileWithMimeType
    (
        filename,
        static_cast<const char *>(textdata.To8BitData()),
        wxStrlen(static_cast<const char *>(textdata.To8BitData())),
        mimetype
    );
}
예제 #2
0
파일: utils.cpp 프로젝트: genua/anoubis
bool
JobCtrl_calculate_checksum(const wxString &file, u_int8_t *cs, int cslen)
{
	SHA256_CTX	shaCtx;
	int		fd, nread;
	unsigned char	buf[1024];

	if ((cs == NULL) || (cslen < ANOUBIS_CS_LEN)) {
		return (false);
	}

	fd = open(file.To8BitData(), O_RDONLY);
	if (fd == -1)
		return (false);

	SHA256_Init(&shaCtx);

	/* Read file chunk by chunk and put it into SHA256_CTX */
	while ((nread = read(fd, buf, sizeof(buf))) > 0) {
		SHA256_Update(&shaCtx, buf, nread);
	}

	SHA256_Final(cs, &shaCtx);

	close(fd);

	if (nread == -1) {
		/* read operation failed */
		return (false);
	}

	return (true);
}
예제 #3
0
/*static*/
void wxMemoryFSHandlerBase::AddFileWithMimeType(const wxString& filename,
                                                const wxString& textdata,
                                                const wxString& mimetype)
{
    const wxCharBuffer buf(textdata.To8BitData());

    AddFileWithMimeType(filename, buf.data(), buf.length(), mimetype);
}
예제 #4
0
void strStream::CheckString(const wxString& text)
{
    wxStringOutputStream sos;

    const wxCharBuffer buf(text.To8BitData());
    sos.Write(buf, buf.length());

    CPPUNIT_ASSERT_EQUAL( text, sos.GetString() );
}
예제 #5
0
wxCharBuffer CControlSocket::ConvToServer(const wxString& str, bool force_utf8 /*=false*/)
{
	if (m_useUTF8 || force_utf8) {
		wxCharBuffer const buffer = str.utf8_str();
		if (buffer || force_utf8)
			return buffer;
	}

	if (m_pCSConv) {
		wxCharBuffer const buffer = str.mb_str(*m_pCSConv);
		if (buffer)
			return buffer;
	}

	wxCharBuffer buffer = str.mb_str(*wxConvCurrent);
	if (!buffer)
		buffer = str.To8BitData();

	return buffer;
}
예제 #6
0
 /**
  * \brief Create a std::string from a wxString.
  * \param str The reference string.
  */
 inline std::string wx_to_std_string( const wxString& str )
 {
   return std::string( str.To8BitData() );
 } // wx_to_std_string()