@@ -81,13 +81,6 @@ impl DiskImageBuilder {
81
81
self . set_file_source ( CONFIG_FILE_NAME , FileDataSource :: Data ( bytes. to_vec ( ) ) )
82
82
}
83
83
84
- /// Add a file source to the disk image
85
- fn set_file_source ( & mut self , destination : & str , source : FileDataSource ) -> & mut Self {
86
- let destination = destination. to_string ( ) ;
87
- self . files . insert ( destination, source) ;
88
- self
89
- }
90
-
91
84
/// Add a file with the specified bytes to the disk image
92
85
pub fn set_file_contents ( & mut self , destination : & str , data : Vec < u8 > ) -> & mut Self {
93
86
self . set_file_source ( destination, FileDataSource :: Data ( data) )
@@ -98,31 +91,6 @@ impl DiskImageBuilder {
98
91
self . set_file_source ( destination, FileDataSource :: File ( file_path) )
99
92
}
100
93
101
- fn create_fat_filesystem_image (
102
- & self ,
103
- internal_files : BTreeMap < & str , FileDataSource > ,
104
- ) -> anyhow:: Result < NamedTempFile > {
105
- let mut local_map = BTreeMap :: new ( ) ;
106
-
107
- for f in & self . files {
108
- local_map. insert ( f. 0 . as_str ( ) , f. 1 . clone ( ) ) ;
109
- }
110
-
111
- for k in internal_files {
112
- if let Some ( _) = local_map. insert ( k. 0 , k. 1 ) {
113
- return Err ( anyhow:: Error :: msg ( format ! (
114
- "Attempted to overwrite internal file: {}" ,
115
- k. 0
116
- ) ) ) ;
117
- }
118
- }
119
-
120
- let out_file = NamedTempFile :: new ( ) . context ( "failed to create temp file" ) ?;
121
- fat:: create_fat_filesystem ( local_map, out_file. path ( ) )
122
- . context ( "failed to create BIOS FAT filesystem" ) ?;
123
-
124
- Ok ( out_file)
125
- }
126
94
#[ cfg( feature = "bios" ) ]
127
95
/// Create an MBR disk image for booting on BIOS systems.
128
96
pub fn create_bios_image ( & self , image_path : & Path ) -> anyhow:: Result < ( ) > {
@@ -213,4 +181,37 @@ impl DiskImageBuilder {
213
181
214
182
Ok ( ( ) )
215
183
}
184
+
185
+ /// Add a file source to the disk image
186
+ fn set_file_source ( & mut self , destination : & str , source : FileDataSource ) -> & mut Self {
187
+ let destination = destination. to_string ( ) ;
188
+ self . files . insert ( destination, source) ;
189
+ self
190
+ }
191
+
192
+ fn create_fat_filesystem_image (
193
+ & self ,
194
+ internal_files : BTreeMap < & str , FileDataSource > ,
195
+ ) -> anyhow:: Result < NamedTempFile > {
196
+ let mut local_map = BTreeMap :: new ( ) ;
197
+
198
+ for f in & self . files {
199
+ local_map. insert ( f. 0 . as_str ( ) , f. 1 . clone ( ) ) ;
200
+ }
201
+
202
+ for k in internal_files {
203
+ if let Some ( _) = local_map. insert ( k. 0 , k. 1 ) {
204
+ return Err ( anyhow:: Error :: msg ( format ! (
205
+ "Attempted to overwrite internal file: {}" ,
206
+ k. 0
207
+ ) ) ) ;
208
+ }
209
+ }
210
+
211
+ let out_file = NamedTempFile :: new ( ) . context ( "failed to create temp file" ) ?;
212
+ fat:: create_fat_filesystem ( local_map, out_file. path ( ) )
213
+ . context ( "failed to create BIOS FAT filesystem" ) ?;
214
+
215
+ Ok ( out_file)
216
+ }
216
217
}
0 commit comments