void toolbar_extension::button::custom_image::write_to_file(stream_writer &p_file, bool b_paths, abort_callback & p_abort) throw (const exception_io &) { p_file.write_lendian_t(I_BUTTON_MASK_TYPE, p_abort); p_file.write_lendian_t(sizeof(m_mask_type), p_abort); p_file.write_lendian_t(m_mask_type, p_abort); if (b_paths) { p_file.write_lendian_t(I_CUSTOM_BUTTON_PATH, p_abort); p_file.write_lendian_t(m_path.length(), p_abort); p_file.write(m_path.get_ptr(), m_path.length(), p_abort); } else { pfc::string8 realPath, canPath; try{ p_file.write_lendian_t(I_BUTTON_CUSTOM_IMAGE_DATA, p_abort); { service_ptr_t<file> p_image; get_path(realPath); filesystem::g_get_canonical_path(realPath, canPath); filesystem::g_open(p_image, canPath, filesystem::open_mode_read, p_abort); pfc::string_filename_ext name(m_path); t_filesize imagesize = p_image->get_size(p_abort); if (imagesize >= MAXLONG) throw exception_io_device_full(); unsigned size = (unsigned)imagesize + name.length() + 4 * sizeof(t_uint32); p_file.write_lendian_t(size, p_abort); p_file.write_lendian_t(IMAGE_NAME, p_abort); p_file.write_lendian_t(name.length(), p_abort); p_file.write(name.get_ptr(), name.length(), p_abort); p_file.write_lendian_t(IMAGE_DATA, p_abort); p_file.write_lendian_t((unsigned)imagesize, p_abort); pfc::array_t<t_uint8> temp; temp.set_size((unsigned)imagesize); p_image->read(temp.get_ptr(), temp.get_size(), p_abort); p_file.write(temp.get_ptr(), temp.get_size(), p_abort); } } catch (const pfc::exception & err) { throw pfc::exception(pfc::string_formatter() << "Error reading file \"" << realPath << "\" : " << err.what()); } } if (m_mask_type == uie::MASK_BITMAP) { if (b_paths) { p_file.write_lendian_t(I_CUSTOM_BUTTON_MASK_PATH, p_abort); p_file.write_lendian_t(m_mask_path.length(), p_abort); p_file.write(m_mask_path.get_ptr(), m_mask_path.length(), p_abort); } else { try { p_file.write_lendian_t(I_BUTTON_CUSTOM_IMAGE_MASK_DATA, p_abort); service_ptr_t<file> p_image; filesystem::g_open(p_image, m_mask_path, filesystem::open_mode_read, p_abort); pfc::string_filename_ext name(m_mask_path); t_filesize imagesize = p_image->get_size(p_abort); if (imagesize >= MAXLONG) throw exception_io_device_full(); unsigned size = (unsigned)imagesize + name.length() + sizeof(IMAGE_NAME) + sizeof(IMAGE_DATA); p_file.write_lendian_t(size, p_abort); p_file.write_lendian_t(IMAGE_NAME, p_abort); p_file.write_lendian_t(name.length(), p_abort); p_file.write(name.get_ptr(), name.length(), p_abort); p_file.write_lendian_t(IMAGE_DATA, p_abort); p_file.write_lendian_t((unsigned)imagesize, p_abort); pfc::array_t<t_uint8> temp; temp.set_size((unsigned)imagesize); p_image->read(temp.get_ptr(), temp.get_size(), p_abort); p_file.write(temp.get_ptr(), temp.get_size(), p_abort); } catch (const pfc::exception & err) { throw pfc::exception(pfc::string_formatter() << "Error reading file \"" << m_mask_path << "\" : " << err.what()); } } } if (m_mask_type == uie::MASK_COLOUR) { p_file.write_lendian_t(I_BUTTON_MASK_COLOUR, p_abort); p_file.write_lendian_t(sizeof(m_mask_colour), p_abort); p_file.write_lendian_t(m_mask_colour, p_abort); } }
void toolbar_extension::button::write_to_file(stream_writer &p_file, bool b_paths, abort_callback & p_abort) { p_file.write_lendian_t(I_BUTTON_TYPE, p_abort); p_file.write_lendian_t(sizeof(m_type), p_abort); p_file.write_lendian_t(m_type, p_abort); p_file.write_lendian_t(I_BUTTON_FILTER, p_abort); p_file.write_lendian_t(sizeof(m_filter), p_abort); p_file.write_lendian_t(m_filter, p_abort); p_file.write_lendian_t(I_BUTTON_SHOW, p_abort); p_file.write_lendian_t(sizeof(m_show), p_abort); p_file.write_lendian_t(m_show, p_abort); p_file.write_lendian_t(I_BUTTON_GUID, p_abort); p_file.write_lendian_t(sizeof(m_guid), p_abort); p_file.write_lendian_t((GUID&)m_guid, p_abort); p_file.write_lendian_t(I_BUTTON_SUBCOMMAND, p_abort); p_file.write_lendian_t(sizeof(m_subcommand), p_abort); p_file.write_lendian_t((GUID&)m_subcommand, p_abort); p_file.write_lendian_t(I_BUTTON_CUSTOM, p_abort); p_file.write_lendian_t(sizeof(m_use_custom), p_abort); p_file.write_lendian_t(m_use_custom, p_abort); if (m_use_custom) { p_file.write_lendian_t(I_BUTTON_CUSTOM_DATA, p_abort); stream_writer_memblock p_write; m_custom_image.write_to_file(p_write, b_paths, p_abort); p_file.write_lendian_t(p_write.m_data.get_size(), p_abort); p_file.write(p_write.m_data.get_ptr(), p_write.m_data.get_size(), p_abort); } p_file.write_lendian_t(I_BUTTON_CUSTOM_HOT, p_abort); p_file.write_lendian_t(sizeof(m_use_custom_hot), p_abort); p_file.write_lendian_t(m_use_custom_hot, p_abort); if (m_use_custom_hot) { p_file.write_lendian_t(I_BUTTON_CUSTOM_HOT_DATA, p_abort); stream_writer_memblock p_write; m_custom_hot_image.write_to_file(p_write, b_paths, p_abort); p_file.write_lendian_t(p_write.m_data.get_size(), p_abort); p_file.write(p_write.m_data.get_ptr(), p_write.m_data.get_size(), p_abort); } p_file.write_lendian_t(I_BUTTON_USE_CUSTOM_TEXT, p_abort); p_file.write_lendian_t(sizeof(m_use_custom_text), p_abort); p_file.write_lendian_t(m_use_custom_text, p_abort); if (m_use_custom_text) { p_file.write_lendian_t(I_BUTTON_TEXT, p_abort); p_file.write_lendian_t(m_text.length(), p_abort); p_file.write(m_text, m_text.length(), p_abort); } }