|
11 | 11 | //! |
12 | 12 | //! # Examples |
13 | 13 | //! |
14 | | -//! ### Replacing the icon of an executable |
| 14 | +//! ### Adding an icon or manifest to an executable |
15 | 15 | //! ``` |
16 | | -//! use editpe::Image; |
17 | | -//! |
| 16 | +//! # use editpe::Image; |
18 | 17 | //! let mut image = Image::parse_file("damocles.exe")?; |
19 | | -//! |
20 | | -//! // get the resource directory |
21 | 18 | //! let mut resources = image.resource_directory().cloned().unwrap_or_default(); |
22 | | -//! // set the icon file |
| 19 | +//! |
23 | 20 | //! resources.set_main_icon_file("sword.png")?; |
24 | | -//! // set the resource directory in the image |
25 | | -//! image.set_resource_directory(resources)?; |
26 | 21 | //! |
27 | | -//! // write an executable image with all changes applied |
| 22 | +//! let manifest = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"; |
| 23 | +//! resources.set_manifest(manifest)?; |
| 24 | +//! |
| 25 | +//! image.set_resource_directory(resources)?; |
28 | 26 | //! image.write_file("damocles.exe"); |
29 | 27 | //! ``` |
30 | 28 | //! |
31 | 29 | //! ### Transferring resources between executables |
32 | 30 | //! ``` |
33 | | -//! use editpe::Image; |
34 | | -//! |
35 | | -//! let image = Image::parse_file("damocles.exe")?; |
36 | | -//! // get the resource directory from the source |
| 31 | +//! # use editpe::Image; |
| 32 | +//! let source = Image::parse_file("damocles.exe")?; |
37 | 33 | //! let resources = image.resource_directory()?; |
38 | 34 | //! |
39 | | -//! let mut image = Image::parse_file("fortuna.exe")?; |
40 | | -//! // copy the resource directory to the target |
41 | | -//! image.set_resource_directory(resources)?; |
42 | | -//! |
43 | | -//! // write an executable image with all changes applied |
44 | | -//! image.write_file("fortuna.exe"); |
| 35 | +//! let mut target = Image::parse_file("fortuna.exe")?; |
| 36 | +//! target.set_resource_directory(resources)?; |
| 37 | +//! target.write_file("fortuna.exe"); |
45 | 38 | //! ``` |
46 | 39 | //! |
47 | 40 | //! # Cargo features |
|
52 | 45 | //! - `images`: Enables support for converting and resizing images in other formats when setting icons. Also enables `std`. |
53 | 46 |
|
54 | 47 | #![cfg_attr(not(feature = "std"), no_std)] |
55 | | -#![cfg_attr(docsrs, feature(doc_auto_cfg, doc_cfg_hide))] |
56 | | -#![cfg_attr(docsrs, doc(cfg_hide(doc)))] |
| 48 | +#![cfg_attr(docsrs, feature(doc_cfg))] |
| 49 | +#![cfg_attr(docsrs, doc(auto_cfg))] |
57 | 50 |
|
58 | 51 | extern crate alloc; |
59 | 52 |
|
|
0 commit comments