File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
3131#include < bitset>
3232#include < cstring>
3333#include < fstream>
34+ #include < sstream>
3435#include < string>
3536
3637using namespace ata_interface ;
@@ -57,7 +58,11 @@ int AtaHardDisk::device_postinit() {
5758 auto bus_obj = dynamic_cast <IdeChannel*>(gMachineObj ->get_comp_by_name (bus_id));
5859 bus_obj->register_device (dev_num, this );
5960
60- this ->insert_image (hdd_image_path);
61+ std::string single_image_path;
62+ std::istringstream hdd_image_stream (hdd_image_path);
63+ while (std::getline (hdd_image_stream, single_image_path, ' :' )) {
64+ this ->insert_image (single_image_path);
65+ }
6166
6267 return 0 ;
6368}
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
2525#define ATA_HARD_DISK_H
2626
2727#include < devices/common/ata/atabasedevice.h>
28- #include < utils/imgfile .h>
28+ #include < utils/metaimgfile .h>
2929
3030#include < string>
3131
@@ -60,7 +60,7 @@ class AtaHardDisk : public AtaBaseDevice
6060 void calc_chs_params ();
6161
6262private:
63- ImgFile hdd_img;
63+ MetaImgFile hdd_img;
6464 uint64_t img_size = 0 ;
6565 uint32_t total_sectors = 0 ;
6666 uint64_t cur_fpos = 0 ;
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
2323#include < memaccess.h>
2424#include < loguru.hpp>
2525
26+ #include < fstream>
2627#include < limits>
2728
2829// ================================================================================================
@@ -562,14 +563,17 @@ void MetaImgFile::append_chunk(std::unique_ptr<FileMetaChunk> file)
562563void MetaImgFile::reserve_partitions (int partitions_to_reserve)
563564{
564565 if (this ->max_partitions == 0 ) {
565- ImgFile partitions;
566- if (!partitions.open (" apm_all_drivers.bin" )) {
566+ std::ifstream partitions;
567+ partitions.open (" apm_all_drivers.bin" , std::ios::in | std::ios::binary);
568+ if (partitions.fail ()) {
567569 ABORT_F (" MetaImgFile: Missing file \" apm_all_drivers.bin\" " );
568570 return ;
569571 }
570- uint64_t partitions_size = partitions.size ();
572+ partitions.seekg (0 , std::ios::end);
573+ size_t partitions_size = partitions.tellg ();
571574 auto data = std::unique_ptr<uint8_t []>(new uint8_t [partitions_size]);
572- partitions.read (&data[0 ], 0 , partitions_size);
575+ partitions.seekg (0 , std::ios::beg);
576+ partitions.read ((char *)data.get (), partitions_size);
573577 partitions.close ();
574578
575579 Partition part = *(Partition*)&data[this ->block_size ];
You can’t perform that action at this time.
0 commit comments