mirror of
https://github.com/davidgiven/fluxengine.git
synced 2025-10-31 11:17:01 -07:00
Amiga FFS writes work.
This commit is contained in:
@@ -147,6 +147,30 @@ public:
|
|||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void putFile(const Path& path, const Bytes& data)
|
||||||
|
{
|
||||||
|
AdfMount m(this);
|
||||||
|
if (path.size() == 0)
|
||||||
|
throw BadPathException();
|
||||||
|
|
||||||
|
auto* vol = m.getVolume();
|
||||||
|
changeDirButOne(vol, path);
|
||||||
|
|
||||||
|
auto* file = adfOpenFile(vol, (char*)path.back().c_str(), (char*)"w");
|
||||||
|
if (!file)
|
||||||
|
throw CannotWriteException();
|
||||||
|
|
||||||
|
unsigned pos = 0;
|
||||||
|
while (pos != data.size())
|
||||||
|
{
|
||||||
|
long done = adfWriteFile(
|
||||||
|
file, data.size() - pos, (uint8_t*)data.cbegin() + pos);
|
||||||
|
pos += done;
|
||||||
|
}
|
||||||
|
|
||||||
|
adfCloseFile(file);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class AdfEntry
|
class AdfEntry
|
||||||
{
|
{
|
||||||
@@ -270,6 +294,8 @@ public:
|
|||||||
RETCODE adfNativeWriteSector(
|
RETCODE adfNativeWriteSector(
|
||||||
struct Device* dev, int32_t sector, int size, uint8_t* buffer)
|
struct Device* dev, int32_t sector, int size, uint8_t* buffer)
|
||||||
{
|
{
|
||||||
|
Bytes bytes(buffer, size);
|
||||||
|
putLogicalSector(sector, bytes);
|
||||||
return RC_OK;
|
return RC_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -76,28 +76,28 @@ public:
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Only a few sectors have changed. Do we need to populate the track? */
|
/* Only a few sectors have changed. Do we need to populate the
|
||||||
|
* track? */
|
||||||
|
|
||||||
if (_loadedtracks.find(trackid) == _loadedtracks.end())
|
if (_loadedtracks.find(trackid) == _loadedtracks.end())
|
||||||
populateSectors(track, side);
|
populateSectors(track, side);
|
||||||
|
|
||||||
/* Now merge the loaded track with the changed one, and write the result back. */
|
/* Now merge the loaded track with the changed one, and write
|
||||||
|
* the result back. */
|
||||||
|
|
||||||
Image image;
|
Image image;
|
||||||
for (const unsigned sector : sectors)
|
for (const unsigned sector : sectors)
|
||||||
{
|
{
|
||||||
auto s = image.put(track, side, sector);
|
auto s = image.put(track, side, sector);
|
||||||
if (_changedSectors.contains(track, side, sector))
|
if (_changedSectors.contains(track, side, sector))
|
||||||
s->data = _changedSectors.get(track, side, sector)->data;
|
s->data =
|
||||||
|
_changedSectors.get(track, side, sector)->data;
|
||||||
else
|
else
|
||||||
s->data = _readSectors.get(track, side, sector)->data;
|
s->data = _readSectors.get(track, side, sector)->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
writeDiskCommand(image,
|
writeDiskCommand(
|
||||||
*_encoder,
|
image, *_encoder, *_fluxSink, &*_decoder, &*_fluxSource);
|
||||||
*_fluxSink,
|
|
||||||
&*_decoder,
|
|
||||||
&*_fluxSource);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user