void OnRequest(int request_id, const Awesomium::WebString& path) { std::string filePath = Awesomium::ToString(path); std::string extension = CL_PathHelp::get_extension(filePath); CL_DataBuffer buffer = g_Files->Fetch(Awesomium::ToString(path).c_str()); std::string mimeType = "text/html"; if (extension == "js") mimeType = "application/javascript"; else if (extension == "png") mimeType = "image/png"; SendResponse(request_id, buffer.get_size(), (unsigned char *)buffer.get_data(), Awesomium::ToWebString(mimeType)); };
void IcoCreatorView::on_button_save() { CL_SaveFileDialog dlg(this); dlg.add_filter("ICO files", "*.ico", true); dlg.add_filter("All files", "*.*"); dlg.set_initial_directory(CL_System::get_exe_path()); if(dlg.show()) { CL_String filename = dlg.get_filename(); try { CL_IconSet icon_set; int count = 0; for(int i = 0; i < 11; ++i) { if(lineedit_selected_file[i]->get_text().empty() == false) { CL_PixelBuffer pb(lineedit_selected_file[i]->get_text()); icon_set.add_image(pb); count++; } } CL_DataBuffer databuffer = icon_set.create_win32_icon(); CL_File ico_file(filename, CL_File::create_always, CL_File::access_write); ico_file.write(databuffer.get_data(), databuffer.get_size()); ico_file.close(); label_result->set_text(cl_format("Saved %1 images into ico file: %2", count, filename)); } catch(CL_Exception error) { label_result->set_text(cl_format("Save error: %1", error.message)); } } }
void CL_RegistryKey::set_value_binary(const CL_StringRef &name, const CL_DataBuffer &value) { LONG result = RegSetValueEx(impl->key, name.empty() ? 0 : CL_StringHelp::utf8_to_ucs2(name).c_str(), 0, REG_BINARY, (const BYTE *) value.get_data(), value.get_size()); if (result != ERROR_SUCCESS) throw CL_Exception(cl_format("Unable to set registry key value %1", name)); }
void CL_AES128_Encrypt::add(const CL_DataBuffer &data) { add(data.get_data(), data.get_size()); }
CL_Secret CL_RSA::decrypt(const CL_Secret &in_private_exponent, const CL_DataBuffer &in_modulus, const CL_DataBuffer &in_data) { return CL_RSA_Impl::decrypt( in_private_exponent, in_modulus.get_data(), in_modulus.get_size(), in_data.get_data(), in_data.get_size()); }
CL_DataBuffer CL_RSA::encrypt(int block_type, CL_Random &random, const CL_DataBuffer &in_public_exponent, const CL_DataBuffer &in_modulus, const CL_Secret &in_data) { return CL_RSA_Impl::encrypt(block_type, random, in_public_exponent.get_data(), in_public_exponent.get_size(), in_modulus.get_data(), in_modulus.get_size(), in_data.get_data(), in_data.get_size()); }
void CL_SHA1::add(const CL_DataBuffer &data) { add(data.get_data(), data.get_size()); }