mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Allow appending on writable images, and correct some incorrect values.
This commit is contained in:
@@ -1476,11 +1476,11 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
descriptorStream = new FileStream(path, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.None);
|
descriptorStream = new FileStream(path, FileMode.Create, FileAccess.ReadWrite, FileShare.None);
|
||||||
imageStream =
|
imageStream =
|
||||||
new
|
new
|
||||||
FileStream(Path.Combine(Path.GetDirectoryName(path), Path.GetFileNameWithoutExtension(path)) + ".mdf",
|
FileStream(Path.Combine(Path.GetDirectoryName(path), Path.GetFileNameWithoutExtension(path)) + ".mdf",
|
||||||
FileMode.CreateNew, FileAccess.ReadWrite, FileShare.None);
|
FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None);
|
||||||
}
|
}
|
||||||
catch(IOException e)
|
catch(IOException e)
|
||||||
{
|
{
|
||||||
@@ -2144,7 +2144,10 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
descriptorStream.Flush();
|
descriptorStream.Flush();
|
||||||
descriptorStream.Close();
|
descriptorStream.Close();
|
||||||
|
imageStream.Flush();
|
||||||
|
imageStream.Close();
|
||||||
|
|
||||||
|
IsWriting = false;
|
||||||
ErrorMessage = "";
|
ErrorMessage = "";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -295,7 +295,9 @@ namespace DiscImageChef.DiscImages
|
|||||||
MediaType.DOS_35_DS_DD_9, MediaType.ACORN_35_DS_HD, MediaType.DOS_525_HD, MediaType.ACORN_525_DS_DD,
|
MediaType.DOS_35_DS_DD_9, MediaType.ACORN_35_DS_HD, MediaType.DOS_525_HD, MediaType.ACORN_525_DS_DD,
|
||||||
MediaType.DOS_35_HD, MediaType.XDF_525, MediaType.DMF, MediaType.XDF_35, MediaType.DOS_35_ED,
|
MediaType.DOS_35_HD, MediaType.XDF_525, MediaType.DMF, MediaType.XDF_35, MediaType.DOS_35_ED,
|
||||||
MediaType.FDFORMAT_35_DD, MediaType.FDFORMAT_525_HD, MediaType.FDFORMAT_35_HD, MediaType.NEC_35_TD,
|
MediaType.FDFORMAT_35_DD, MediaType.FDFORMAT_525_HD, MediaType.FDFORMAT_35_HD, MediaType.NEC_35_TD,
|
||||||
MediaType.Unknown, MediaType.GENERIC_HDD
|
MediaType.Unknown, MediaType.GENERIC_HDD, MediaType.FlashDrive, MediaType.CompactFlash,
|
||||||
|
MediaType.CompactFlashType2, MediaType.PCCardTypeI, MediaType.PCCardTypeII, MediaType.PCCardTypeIII,
|
||||||
|
MediaType.PCCardTypeIV
|
||||||
};
|
};
|
||||||
public IEnumerable<(string name, Type type, string description)> SupportedOptions =>
|
public IEnumerable<(string name, Type type, string description)> SupportedOptions =>
|
||||||
new(string name, Type type, string description)[] { };
|
new(string name, Type type, string description)[] { };
|
||||||
@@ -327,7 +329,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
imageInfo = new ImageInfo {MediaType = mediaType, SectorSize = sectorSize, Sectors = sectors};
|
imageInfo = new ImageInfo {MediaType = mediaType, SectorSize = sectorSize, Sectors = sectors};
|
||||||
|
|
||||||
try { writingStream = new FileStream(path, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.None); }
|
try { writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); }
|
||||||
catch(IOException e)
|
catch(IOException e)
|
||||||
{
|
{
|
||||||
ErrorMessage = $"Could not create new image file, exception {e.Message}";
|
ErrorMessage = $"Could not create new image file, exception {e.Message}";
|
||||||
@@ -427,8 +429,11 @@ namespace DiscImageChef.DiscImages
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((imageInfo.MediaType == MediaType.Unknown || imageInfo.MediaType == MediaType.GENERIC_HDD) &&
|
if((imageInfo.MediaType == MediaType.Unknown || imageInfo.MediaType == MediaType.GENERIC_HDD ||
|
||||||
fdihdr.cylinders == 0)
|
imageInfo.MediaType == MediaType.FlashDrive || imageInfo.MediaType == MediaType.CompactFlash ||
|
||||||
|
imageInfo.MediaType == MediaType.CompactFlashType2 || imageInfo.MediaType == MediaType.PCCardTypeI ||
|
||||||
|
imageInfo.MediaType == MediaType.PCCardTypeII || imageInfo.MediaType == MediaType.PCCardTypeIII ||
|
||||||
|
imageInfo.MediaType == MediaType.PCCardTypeIV) && fdihdr.cylinders == 0)
|
||||||
{
|
{
|
||||||
fdihdr.cylinders = (int)(imageInfo.Sectors / 8 / 33);
|
fdihdr.cylinders = (int)(imageInfo.Sectors / 8 / 33);
|
||||||
fdihdr.heads = 8;
|
fdihdr.heads = 8;
|
||||||
@@ -461,8 +466,9 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
writingStream.Flush();
|
writingStream.Flush();
|
||||||
writingStream.Close();
|
writingStream.Close();
|
||||||
IsWriting = false;
|
|
||||||
|
|
||||||
|
IsWriting = false;
|
||||||
|
ErrorMessage = "";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -526,7 +526,9 @@ namespace DiscImageChef.DiscImages
|
|||||||
new[]
|
new[]
|
||||||
{
|
{
|
||||||
MediaType.Apple32SS, MediaType.Apple33SS, MediaType.AppleSonySS, MediaType.AppleSonyDS,
|
MediaType.Apple32SS, MediaType.Apple33SS, MediaType.AppleSonySS, MediaType.AppleSonyDS,
|
||||||
MediaType.DOS_35_HD, MediaType.Unknown, MediaType.GENERIC_HDD
|
MediaType.DOS_35_HD, MediaType.Unknown, MediaType.GENERIC_HDD, MediaType.FlashDrive,
|
||||||
|
MediaType.CompactFlash, MediaType.CompactFlashType2, MediaType.PCCardTypeI, MediaType.PCCardTypeII,
|
||||||
|
MediaType.PCCardTypeIII, MediaType.PCCardTypeIV
|
||||||
};
|
};
|
||||||
public IEnumerable<(string name, Type type, string description)> SupportedOptions =>
|
public IEnumerable<(string name, Type type, string description)> SupportedOptions =>
|
||||||
new (string name, Type type, string description)[] { };
|
new (string name, Type type, string description)[] { };
|
||||||
@@ -558,7 +560,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
imageInfo = new ImageInfo {MediaType = mediaType, SectorSize = sectorSize, Sectors = sectors};
|
imageInfo = new ImageInfo {MediaType = mediaType, SectorSize = sectorSize, Sectors = sectors};
|
||||||
|
|
||||||
try { writingStream = new FileStream(path, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.None); }
|
try { writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); }
|
||||||
catch(IOException e)
|
catch(IOException e)
|
||||||
{
|
{
|
||||||
ErrorMessage = $"Could not create new image file, exception {e.Message}";
|
ErrorMessage = $"Could not create new image file, exception {e.Message}";
|
||||||
@@ -700,9 +702,8 @@ namespace DiscImageChef.DiscImages
|
|||||||
writingStream.Flush();
|
writingStream.Flush();
|
||||||
writingStream.Close();
|
writingStream.Close();
|
||||||
|
|
||||||
ErrorMessage = "";
|
|
||||||
IsWriting = false;
|
IsWriting = false;
|
||||||
|
ErrorMessage = "";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -296,7 +296,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
imageInfo = new ImageInfo {MediaType = mediaType, SectorSize = sectorSize, Sectors = sectors};
|
imageInfo = new ImageInfo {MediaType = mediaType, SectorSize = sectorSize, Sectors = sectors};
|
||||||
|
|
||||||
try { writingStream = new FileStream(path, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.None); }
|
try { writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); }
|
||||||
catch(IOException e)
|
catch(IOException e)
|
||||||
{
|
{
|
||||||
ErrorMessage = $"Could not create new image file, exception {e.Message}";
|
ErrorMessage = $"Could not create new image file, exception {e.Message}";
|
||||||
@@ -394,12 +394,12 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
writingStream.Seek(0, SeekOrigin.Begin);
|
writingStream.Seek(0, SeekOrigin.Begin);
|
||||||
writingStream.Write(tmp, 0, tmp.Length);
|
writingStream.Write(tmp, 0, tmp.Length);
|
||||||
|
|
||||||
writingStream.Flush();
|
writingStream.Flush();
|
||||||
writingStream.Close();
|
writingStream.Close();
|
||||||
|
|
||||||
ErrorMessage = "";
|
|
||||||
IsWriting = false;
|
IsWriting = false;
|
||||||
|
ErrorMessage = "";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ using DiscImageChef.Filters;
|
|||||||
|
|
||||||
namespace DiscImageChef.DiscImages
|
namespace DiscImageChef.DiscImages
|
||||||
{
|
{
|
||||||
|
// TODO: Check writing
|
||||||
public class Apridisk : IWritableImage
|
public class Apridisk : IWritableImage
|
||||||
{
|
{
|
||||||
readonly byte[] signature =
|
readonly byte[] signature =
|
||||||
@@ -59,6 +60,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
// Cylinder by head, sector data matrix
|
// Cylinder by head, sector data matrix
|
||||||
byte[][][][] sectorsData;
|
byte[][][][] sectorsData;
|
||||||
|
FileStream writingStream;
|
||||||
|
|
||||||
public Apridisk()
|
public Apridisk()
|
||||||
{
|
{
|
||||||
@@ -422,65 +424,6 @@ namespace DiscImageChef.DiscImages
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint Decompress(byte[] compressed, out byte[] decompressed)
|
|
||||||
{
|
|
||||||
int readp = 0;
|
|
||||||
int cLen = compressed.Length;
|
|
||||||
MemoryStream buffer = new MemoryStream();
|
|
||||||
|
|
||||||
uint uLen = 0;
|
|
||||||
|
|
||||||
while(cLen >= 3)
|
|
||||||
{
|
|
||||||
ushort blklen = BitConverter.ToUInt16(compressed, readp);
|
|
||||||
readp += 2;
|
|
||||||
|
|
||||||
for(int i = 0; i < blklen; i++) buffer.WriteByte(compressed[readp]);
|
|
||||||
|
|
||||||
uLen += blklen;
|
|
||||||
readp++;
|
|
||||||
cLen -= 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
decompressed = buffer.ToArray();
|
|
||||||
return uLen;
|
|
||||||
}
|
|
||||||
|
|
||||||
(ushort cylinder, byte head, byte sector) LbaToChs(ulong lba)
|
|
||||||
{
|
|
||||||
ushort cylinder = (ushort)(lba / (imageInfo.Heads * imageInfo.SectorsPerTrack));
|
|
||||||
byte head = (byte)(lba / imageInfo.SectorsPerTrack % imageInfo.Heads);
|
|
||||||
byte sector = (byte)(lba % imageInfo.SectorsPerTrack + 1);
|
|
||||||
|
|
||||||
return (cylinder, head, sector);
|
|
||||||
}
|
|
||||||
|
|
||||||
enum RecordType : uint
|
|
||||||
{
|
|
||||||
Deleted = 0xE31D0000,
|
|
||||||
Sector = 0xE31D0001,
|
|
||||||
Comment = 0xE31D0002,
|
|
||||||
Creator = 0xE31D0003
|
|
||||||
}
|
|
||||||
|
|
||||||
enum CompressType : ushort
|
|
||||||
{
|
|
||||||
Uncompresed = 0x9E90,
|
|
||||||
Compressed = 0x3E5A
|
|
||||||
}
|
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
|
||||||
struct ApridiskRecord
|
|
||||||
{
|
|
||||||
public RecordType type;
|
|
||||||
public CompressType compression;
|
|
||||||
public ushort headerSize;
|
|
||||||
public uint dataSize;
|
|
||||||
public byte head;
|
|
||||||
public byte sector;
|
|
||||||
public ushort cylinder;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<MediaTagType> SupportedMediaTags => new MediaTagType[] { };
|
public IEnumerable<MediaTagType> SupportedMediaTags => new MediaTagType[] { };
|
||||||
public IEnumerable<SectorTagType> SupportedSectorTags => new SectorTagType[] { };
|
public IEnumerable<SectorTagType> SupportedSectorTags => new SectorTagType[] { };
|
||||||
// TODO: Test with real hardware to see real supported media
|
// TODO: Test with real hardware to see real supported media
|
||||||
@@ -496,16 +439,13 @@ namespace DiscImageChef.DiscImages
|
|||||||
MediaType.FDFORMAT_525_HD, MediaType.RX50, MediaType.XDF_35, MediaType.XDF_525
|
MediaType.FDFORMAT_525_HD, MediaType.RX50, MediaType.XDF_35, MediaType.XDF_525
|
||||||
};
|
};
|
||||||
public IEnumerable<(string name, Type type, string description)> SupportedOptions =>
|
public IEnumerable<(string name, Type type, string description)> SupportedOptions =>
|
||||||
new[]
|
new[] {("compress", typeof(bool), "Enable Apridisk compression.")};
|
||||||
{
|
|
||||||
("compress", typeof(bool), "Enable Apridisk compression.")
|
|
||||||
};
|
|
||||||
public IEnumerable<string> KnownExtensions => new[] {".dsk"};
|
public IEnumerable<string> KnownExtensions => new[] {".dsk"};
|
||||||
public bool IsWriting { get; private set; }
|
public bool IsWriting { get; private set; }
|
||||||
public string ErrorMessage { get; private set; }
|
public string ErrorMessage { get; private set; }
|
||||||
FileStream writingStream;
|
|
||||||
|
|
||||||
public bool Create(string path, MediaType mediaType, Dictionary<string, string> options, ulong sectors, uint sectorSize)
|
public bool Create(string path, MediaType mediaType, Dictionary<string, string> options, ulong sectors,
|
||||||
|
uint sectorSize)
|
||||||
{
|
{
|
||||||
if(!SupportedMediaTypes.Contains(mediaType))
|
if(!SupportedMediaTypes.Contains(mediaType))
|
||||||
{
|
{
|
||||||
@@ -515,7 +455,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
imageInfo = new ImageInfo {MediaType = mediaType, SectorSize = sectorSize, Sectors = sectors};
|
imageInfo = new ImageInfo {MediaType = mediaType, SectorSize = sectorSize, Sectors = sectors};
|
||||||
|
|
||||||
try { writingStream = new FileStream(path, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.None); }
|
try { writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); }
|
||||||
catch(IOException e)
|
catch(IOException e)
|
||||||
{
|
{
|
||||||
ErrorMessage = $"Could not create new image file, exception {e.Message}";
|
ErrorMessage = $"Could not create new image file, exception {e.Message}";
|
||||||
@@ -639,7 +579,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
Marshal.StructureToPtr(record, hdrPtr, true);
|
Marshal.StructureToPtr(record, hdrPtr, true);
|
||||||
Marshal.Copy(hdrPtr, hdr, 0, hdr.Length);
|
Marshal.Copy(hdrPtr, hdr, 0, hdr.Length);
|
||||||
|
|
||||||
writingStream.Write(hdr, 0, hdr.Length);
|
writingStream.Write(hdr, 0, hdr.Length);
|
||||||
writingStream.Write(sectorsData[c][h][s], 0, sectorsData[c][h][s].Length);
|
writingStream.Write(sectorsData[c][h][s], 0, sectorsData[c][h][s].Length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -693,13 +633,15 @@ namespace DiscImageChef.DiscImages
|
|||||||
writingStream.Flush();
|
writingStream.Flush();
|
||||||
writingStream.Close();
|
writingStream.Close();
|
||||||
|
|
||||||
|
IsWriting = false;
|
||||||
|
ErrorMessage = "";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool SetMetadata(ImageInfo metadata)
|
public bool SetMetadata(ImageInfo metadata)
|
||||||
{
|
{
|
||||||
imageInfo.Comments = metadata.Comments;
|
imageInfo.Comments = metadata.Comments;
|
||||||
imageInfo.Creator = metadata.Creator;
|
imageInfo.Creator = metadata.Creator;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -726,13 +668,12 @@ namespace DiscImageChef.DiscImages
|
|||||||
sectorsData = new byte[cylinders][][][];
|
sectorsData = new byte[cylinders][][][];
|
||||||
for(ushort c = 0; c < cylinders; c++)
|
for(ushort c = 0; c < cylinders; c++)
|
||||||
{
|
{
|
||||||
sectorsData[c] = new byte[heads][][];
|
sectorsData[c] = new byte[heads][][];
|
||||||
for(byte h = 0; h < heads; h++)
|
for(byte h = 0; h < heads; h++) sectorsData[c][h] = new byte[sectorsPerTrack][];
|
||||||
sectorsData[c][h] = new byte[sectorsPerTrack][];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
imageInfo.Cylinders = cylinders;
|
imageInfo.Cylinders = cylinders;
|
||||||
imageInfo.Heads = heads;
|
imageInfo.Heads = heads;
|
||||||
imageInfo.SectorsPerTrack = sectorsPerTrack;
|
imageInfo.SectorsPerTrack = sectorsPerTrack;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -749,5 +690,64 @@ namespace DiscImageChef.DiscImages
|
|||||||
ErrorMessage = "Unsupported feature";
|
ErrorMessage = "Unsupported feature";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static uint Decompress(byte[] compressed, out byte[] decompressed)
|
||||||
|
{
|
||||||
|
int readp = 0;
|
||||||
|
int cLen = compressed.Length;
|
||||||
|
MemoryStream buffer = new MemoryStream();
|
||||||
|
|
||||||
|
uint uLen = 0;
|
||||||
|
|
||||||
|
while(cLen >= 3)
|
||||||
|
{
|
||||||
|
ushort blklen = BitConverter.ToUInt16(compressed, readp);
|
||||||
|
readp += 2;
|
||||||
|
|
||||||
|
for(int i = 0; i < blklen; i++) buffer.WriteByte(compressed[readp]);
|
||||||
|
|
||||||
|
uLen += blklen;
|
||||||
|
readp++;
|
||||||
|
cLen -= 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
decompressed = buffer.ToArray();
|
||||||
|
return uLen;
|
||||||
|
}
|
||||||
|
|
||||||
|
(ushort cylinder, byte head, byte sector) LbaToChs(ulong lba)
|
||||||
|
{
|
||||||
|
ushort cylinder = (ushort)(lba / (imageInfo.Heads * imageInfo.SectorsPerTrack));
|
||||||
|
byte head = (byte)(lba / imageInfo.SectorsPerTrack % imageInfo.Heads);
|
||||||
|
byte sector = (byte)(lba % imageInfo.SectorsPerTrack + 1);
|
||||||
|
|
||||||
|
return (cylinder, head, sector);
|
||||||
|
}
|
||||||
|
|
||||||
|
enum RecordType : uint
|
||||||
|
{
|
||||||
|
Deleted = 0xE31D0000,
|
||||||
|
Sector = 0xE31D0001,
|
||||||
|
Comment = 0xE31D0002,
|
||||||
|
Creator = 0xE31D0003
|
||||||
|
}
|
||||||
|
|
||||||
|
enum CompressType : ushort
|
||||||
|
{
|
||||||
|
Uncompresed = 0x9E90,
|
||||||
|
Compressed = 0x3E5A
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||||
|
struct ApridiskRecord
|
||||||
|
{
|
||||||
|
public RecordType type;
|
||||||
|
public CompressType compression;
|
||||||
|
public ushort headerSize;
|
||||||
|
public uint dataSize;
|
||||||
|
public byte head;
|
||||||
|
public byte sector;
|
||||||
|
public ushort cylinder;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -400,7 +400,8 @@ namespace DiscImageChef.DiscImages
|
|||||||
new[]
|
new[]
|
||||||
{
|
{
|
||||||
MediaType.AppleProfile, MediaType.AppleWidget, MediaType.PriamDataTower, MediaType.GENERIC_HDD,
|
MediaType.AppleProfile, MediaType.AppleWidget, MediaType.PriamDataTower, MediaType.GENERIC_HDD,
|
||||||
MediaType.Unknown
|
MediaType.Unknown, MediaType.FlashDrive, MediaType.CompactFlash, MediaType.CompactFlashType2,
|
||||||
|
MediaType.PCCardTypeI, MediaType.PCCardTypeII, MediaType.PCCardTypeIII, MediaType.PCCardTypeIV
|
||||||
};
|
};
|
||||||
public IEnumerable<(string name, Type type, string description)> SupportedOptions =>
|
public IEnumerable<(string name, Type type, string description)> SupportedOptions =>
|
||||||
new (string name, Type type, string description)[] { };
|
new (string name, Type type, string description)[] { };
|
||||||
@@ -431,7 +432,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
imageInfo = new ImageInfo {MediaType = mediaType, SectorSize = sectorSize, Sectors = sectors};
|
imageInfo = new ImageInfo {MediaType = mediaType, SectorSize = sectorSize, Sectors = sectors};
|
||||||
|
|
||||||
try { writingStream = new FileStream(path, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.None); }
|
try { writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); }
|
||||||
catch(IOException e)
|
catch(IOException e)
|
||||||
{
|
{
|
||||||
ErrorMessage = $"Could not create new image file, exception {e.Message}";
|
ErrorMessage = $"Could not create new image file, exception {e.Message}";
|
||||||
@@ -723,6 +724,8 @@ namespace DiscImageChef.DiscImages
|
|||||||
writingStream.Flush();
|
writingStream.Flush();
|
||||||
writingStream.Close();
|
writingStream.Close();
|
||||||
|
|
||||||
|
IsWriting = false;
|
||||||
|
ErrorMessage = "";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1814,11 +1814,11 @@ namespace DiscImageChef.DiscImages
|
|||||||
if(separateTracksWriting)
|
if(separateTracksWriting)
|
||||||
foreach(Track track in writingTracks)
|
foreach(Track track in writingTracks)
|
||||||
writingStreams.Add(track.TrackSequence,
|
writingStreams.Add(track.TrackSequence,
|
||||||
new FileStream(track.TrackFile, FileMode.CreateNew, FileAccess.ReadWrite,
|
new FileStream(track.TrackFile, FileMode.OpenOrCreate, FileAccess.ReadWrite,
|
||||||
FileShare.None));
|
FileShare.None));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FileStream jointstream = new FileStream(writingBaseName + ".bin", FileMode.CreateNew,
|
FileStream jointstream = new FileStream(writingBaseName + ".bin", FileMode.OpenOrCreate,
|
||||||
FileAccess.ReadWrite, FileShare.None);
|
FileAccess.ReadWrite, FileShare.None);
|
||||||
foreach(Track track in writingTracks) writingStreams.Add(track.TrackSequence, jointstream);
|
foreach(Track track in writingTracks) writingStreams.Add(track.TrackSequence, jointstream);
|
||||||
}
|
}
|
||||||
@@ -1922,8 +1922,9 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
descriptorStream.Flush();
|
descriptorStream.Flush();
|
||||||
descriptorStream.Close();
|
descriptorStream.Close();
|
||||||
IsWriting = false;
|
|
||||||
|
|
||||||
|
IsWriting = false;
|
||||||
|
ErrorMessage = "";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2151,11 +2151,11 @@ namespace DiscImageChef.DiscImages
|
|||||||
if(separateTracksWriting)
|
if(separateTracksWriting)
|
||||||
foreach(Track track in writingTracks)
|
foreach(Track track in writingTracks)
|
||||||
writingStreams.Add(track.TrackSequence,
|
writingStreams.Add(track.TrackSequence,
|
||||||
new FileStream(track.TrackFile, FileMode.CreateNew, FileAccess.ReadWrite,
|
new FileStream(track.TrackFile, FileMode.OpenOrCreate, FileAccess.ReadWrite,
|
||||||
FileShare.None));
|
FileShare.None));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FileStream jointstream = new FileStream(writingBaseName + ".bin", FileMode.CreateNew,
|
FileStream jointstream = new FileStream(writingBaseName + ".bin", FileMode.OpenOrCreate,
|
||||||
FileAccess.ReadWrite, FileShare.None);
|
FileAccess.ReadWrite, FileShare.None);
|
||||||
foreach(Track track in writingTracks) writingStreams.Add(track.TrackSequence, jointstream);
|
foreach(Track track in writingTracks) writingStreams.Add(track.TrackSequence, jointstream);
|
||||||
}
|
}
|
||||||
@@ -2234,8 +2234,9 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
descriptorStream.Flush();
|
descriptorStream.Flush();
|
||||||
descriptorStream.Close();
|
descriptorStream.Close();
|
||||||
IsWriting = false;
|
|
||||||
|
|
||||||
|
IsWriting = false;
|
||||||
|
ErrorMessage = "";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -456,7 +456,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
public bool Create(string path, MediaType mediaType, Dictionary<string, string> options, ulong sectors,
|
public bool Create(string path, MediaType mediaType, Dictionary<string, string> options, ulong sectors,
|
||||||
uint sectorSize)
|
uint sectorSize)
|
||||||
{
|
{
|
||||||
if(sectorSize == 512)
|
if(sectorSize != 512)
|
||||||
{
|
{
|
||||||
ErrorMessage = "Unsupported sector size";
|
ErrorMessage = "Unsupported sector size";
|
||||||
return false;
|
return false;
|
||||||
@@ -470,7 +470,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
imageInfo = new ImageInfo {MediaType = mediaType, SectorSize = sectorSize, Sectors = sectors};
|
imageInfo = new ImageInfo {MediaType = mediaType, SectorSize = sectorSize, Sectors = sectors};
|
||||||
|
|
||||||
try { writingStream = new FileStream(path, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.None); }
|
try { writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); }
|
||||||
catch(IOException e)
|
catch(IOException e)
|
||||||
{
|
{
|
||||||
ErrorMessage = $"Could not create new image file, exception {e.Message}";
|
ErrorMessage = $"Could not create new image file, exception {e.Message}";
|
||||||
@@ -630,8 +630,9 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
writingStream.Flush();
|
writingStream.Flush();
|
||||||
writingStream.Close();
|
writingStream.Close();
|
||||||
IsWriting = false;
|
|
||||||
|
|
||||||
|
IsWriting = false;
|
||||||
|
ErrorMessage = "";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1414,7 +1414,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
{
|
{
|
||||||
writingBaseName = Path.Combine(Path.GetDirectoryName(path), Path.GetFileNameWithoutExtension(path));
|
writingBaseName = Path.Combine(Path.GetDirectoryName(path), Path.GetFileNameWithoutExtension(path));
|
||||||
descriptorStream = new StreamWriter(path, false, Encoding.ASCII);
|
descriptorStream = new StreamWriter(path, false, Encoding.ASCII);
|
||||||
dataStream = new FileStream(writingBaseName + ".img", FileMode.CreateNew, FileAccess.ReadWrite,
|
dataStream = new FileStream(writingBaseName + ".img", FileMode.OpenOrCreate, FileAccess.ReadWrite,
|
||||||
FileShare.None);
|
FileShare.None);
|
||||||
}
|
}
|
||||||
catch(IOException e)
|
catch(IOException e)
|
||||||
@@ -1790,6 +1790,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
descriptorStream.Flush();
|
descriptorStream.Flush();
|
||||||
descriptorStream.Close();
|
descriptorStream.Close();
|
||||||
|
|
||||||
|
IsWriting = false;
|
||||||
ErrorMessage = "";
|
ErrorMessage = "";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1855,7 +1856,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
if(subStream == null)
|
if(subStream == null)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
subStream = new FileStream(writingBaseName + ".sub", FileMode.CreateNew,
|
subStream = new FileStream(writingBaseName + ".sub", FileMode.OpenOrCreate,
|
||||||
FileAccess.ReadWrite, FileShare.None);
|
FileAccess.ReadWrite, FileShare.None);
|
||||||
}
|
}
|
||||||
catch(IOException e)
|
catch(IOException e)
|
||||||
@@ -1916,7 +1917,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
if(subStream == null)
|
if(subStream == null)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
subStream = new FileStream(writingBaseName + ".sub", FileMode.CreateNew,
|
subStream = new FileStream(writingBaseName + ".sub", FileMode.OpenOrCreate,
|
||||||
FileAccess.ReadWrite, FileShare.None);
|
FileAccess.ReadWrite, FileShare.None);
|
||||||
}
|
}
|
||||||
catch(IOException e)
|
catch(IOException e)
|
||||||
|
|||||||
@@ -920,7 +920,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
imageInfo = new ImageInfo {MediaType = mediaType, SectorSize = sectorSize, Sectors = sectors};
|
imageInfo = new ImageInfo {MediaType = mediaType, SectorSize = sectorSize, Sectors = sectors};
|
||||||
|
|
||||||
try { writingStream = new FileStream(path, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.None); }
|
try { writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); }
|
||||||
catch(IOException e)
|
catch(IOException e)
|
||||||
{
|
{
|
||||||
ErrorMessage = $"Could not create new image file, exception {e.Message}";
|
ErrorMessage = $"Could not create new image file, exception {e.Message}";
|
||||||
@@ -1111,8 +1111,9 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
writingStream.Flush();
|
writingStream.Flush();
|
||||||
writingStream.Close();
|
writingStream.Close();
|
||||||
IsWriting = false;
|
|
||||||
|
|
||||||
|
IsWriting = false;
|
||||||
|
ErrorMessage = "";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -402,13 +402,14 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
imageInfo = new ImageInfo {MediaType = mediaType, SectorSize = sectorSize, Sectors = sectors};
|
imageInfo = new ImageInfo {MediaType = mediaType, SectorSize = sectorSize, Sectors = sectors};
|
||||||
|
|
||||||
try { writingStream = new FileStream(path, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.None); }
|
try { writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); }
|
||||||
catch(IOException e)
|
catch(IOException e)
|
||||||
{
|
{
|
||||||
ErrorMessage = $"Could not create new image file, exception {e.Message}";
|
ErrorMessage = $"Could not create new image file, exception {e.Message}";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Check this
|
||||||
(ushort cylinders, byte heads, ushort sectorsPerTrack, uint bytesPerSector, MediaEncoding encoding, bool
|
(ushort cylinders, byte heads, ushort sectorsPerTrack, uint bytesPerSector, MediaEncoding encoding, bool
|
||||||
variableSectorsPerTrack, MediaType type) geometry = Geometry.GetGeometry(mediaType);
|
variableSectorsPerTrack, MediaType type) geometry = Geometry.GetGeometry(mediaType);
|
||||||
|
|
||||||
@@ -429,7 +430,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
Array.Copy(Encoding.ASCII.GetBytes("DiskImage 2.01 (C) 1990,1991 Digital Research Inc"), 0,
|
Array.Copy(Encoding.ASCII.GetBytes("DiskImage 2.01 (C) 1990,1991 Digital Research Inc"), 0,
|
||||||
footer.signature, 0, 50);
|
footer.signature, 0, 49);
|
||||||
footer.bpbcopy = footer.bpb;
|
footer.bpbcopy = footer.bpb;
|
||||||
|
|
||||||
IsWriting = true;
|
IsWriting = true;
|
||||||
@@ -534,8 +535,9 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
writingStream.Flush();
|
writingStream.Flush();
|
||||||
writingStream.Close();
|
writingStream.Close();
|
||||||
IsWriting = false;
|
|
||||||
|
|
||||||
|
IsWriting = false;
|
||||||
|
ErrorMessage = "";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -374,13 +374,13 @@ namespace DiscImageChef.DiscImages
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(imageInfo.Cylinders > 2)
|
if(imageInfo.Heads > 2)
|
||||||
{
|
{
|
||||||
ErrorMessage = "Too many heads";
|
ErrorMessage = "Too many heads";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
try { writingStream = new FileStream(path, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.None); }
|
try { writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); }
|
||||||
catch(IOException e)
|
catch(IOException e)
|
||||||
{
|
{
|
||||||
ErrorMessage = $"Could not create new image file, exception {e.Message}";
|
ErrorMessage = $"Could not create new image file, exception {e.Message}";
|
||||||
@@ -505,8 +505,9 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
writingStream.Flush();
|
writingStream.Flush();
|
||||||
writingStream.Close();
|
writingStream.Close();
|
||||||
IsWriting = false;
|
|
||||||
|
|
||||||
|
IsWriting = false;
|
||||||
|
ErrorMessage = "";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -348,7 +348,13 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
public IEnumerable<MediaTagType> SupportedMediaTags => new MediaTagType[] { };
|
public IEnumerable<MediaTagType> SupportedMediaTags => new MediaTagType[] { };
|
||||||
public IEnumerable<SectorTagType> SupportedSectorTags => new SectorTagType[] { };
|
public IEnumerable<SectorTagType> SupportedSectorTags => new SectorTagType[] { };
|
||||||
public IEnumerable<MediaType> SupportedMediaTypes => new[] {MediaType.Unknown, MediaType.GENERIC_HDD};
|
public IEnumerable<MediaType> SupportedMediaTypes =>
|
||||||
|
new[]
|
||||||
|
{
|
||||||
|
MediaType.Unknown, MediaType.GENERIC_HDD, MediaType.FlashDrive, MediaType.CompactFlash,
|
||||||
|
MediaType.CompactFlashType2, MediaType.PCCardTypeI, MediaType.PCCardTypeII, MediaType.PCCardTypeIII,
|
||||||
|
MediaType.PCCardTypeIV
|
||||||
|
};
|
||||||
// TODO: Add cluster size option
|
// TODO: Add cluster size option
|
||||||
public IEnumerable<(string name, Type type, string description)> SupportedOptions =>
|
public IEnumerable<(string name, Type type, string description)> SupportedOptions =>
|
||||||
new (string name, Type type, string description)[] { };
|
new (string name, Type type, string description)[] { };
|
||||||
@@ -380,7 +386,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
imageInfo = new ImageInfo {MediaType = mediaType, SectorSize = sectorSize, Sectors = sectors};
|
imageInfo = new ImageInfo {MediaType = mediaType, SectorSize = sectorSize, Sectors = sectors};
|
||||||
|
|
||||||
try { writingStream = new FileStream(path, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.None); }
|
try { writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); }
|
||||||
catch(IOException e)
|
catch(IOException e)
|
||||||
{
|
{
|
||||||
ErrorMessage = $"Could not create new image file, exception {e.Message}";
|
ErrorMessage = $"Could not create new image file, exception {e.Message}";
|
||||||
@@ -525,6 +531,28 @@ namespace DiscImageChef.DiscImages
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(pHdr.cylinders == 0)
|
||||||
|
{
|
||||||
|
pHdr.cylinders = (uint)(imageInfo.Sectors / 16 / 63);
|
||||||
|
pHdr.heads = 16;
|
||||||
|
imageInfo.SectorsPerTrack = 63;
|
||||||
|
|
||||||
|
while(pHdr.cylinders == 0)
|
||||||
|
{
|
||||||
|
pHdr.heads--;
|
||||||
|
|
||||||
|
if(pHdr.heads == 0)
|
||||||
|
{
|
||||||
|
imageInfo.SectorsPerTrack--;
|
||||||
|
pHdr.heads = 16;
|
||||||
|
}
|
||||||
|
|
||||||
|
pHdr.cylinders = (uint)(imageInfo.Sectors / pHdr.heads / imageInfo.SectorsPerTrack);
|
||||||
|
|
||||||
|
if(pHdr.cylinders == 0 && pHdr.heads == 0 && imageInfo.SectorsPerTrack == 0) break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
byte[] hdr = new byte[Marshal.SizeOf(typeof(ParallelsHeader))];
|
byte[] hdr = new byte[Marshal.SizeOf(typeof(ParallelsHeader))];
|
||||||
IntPtr hdrPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(ParallelsHeader)));
|
IntPtr hdrPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(ParallelsHeader)));
|
||||||
Marshal.StructureToPtr(pHdr, hdrPtr, true);
|
Marshal.StructureToPtr(pHdr, hdrPtr, true);
|
||||||
@@ -536,6 +564,11 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
for(long i = 0; i < bat.LongLength; i++) writingStream.Write(BitConverter.GetBytes(bat[i]), 0, 4);
|
for(long i = 0; i < bat.LongLength; i++) writingStream.Write(BitConverter.GetBytes(bat[i]), 0, 4);
|
||||||
|
|
||||||
|
writingStream.Flush();
|
||||||
|
writingStream.Close();
|
||||||
|
|
||||||
|
IsWriting = false;
|
||||||
|
ErrorMessage = "";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -470,7 +470,12 @@ namespace DiscImageChef.DiscImages
|
|||||||
public IEnumerable<MediaTagType> SupportedMediaTags => new MediaTagType[] { };
|
public IEnumerable<MediaTagType> SupportedMediaTags => new MediaTagType[] { };
|
||||||
public IEnumerable<SectorTagType> SupportedSectorTags => new SectorTagType[] { };
|
public IEnumerable<SectorTagType> SupportedSectorTags => new SectorTagType[] { };
|
||||||
public IEnumerable<MediaType> SupportedMediaTypes =>
|
public IEnumerable<MediaType> SupportedMediaTypes =>
|
||||||
new[] {MediaType.Unknown, MediaType.GENERIC_HDD};
|
new[]
|
||||||
|
{
|
||||||
|
MediaType.Unknown, MediaType.GENERIC_HDD, MediaType.FlashDrive, MediaType.CompactFlash,
|
||||||
|
MediaType.CompactFlashType2, MediaType.PCCardTypeI, MediaType.PCCardTypeII, MediaType.PCCardTypeIII,
|
||||||
|
MediaType.PCCardTypeIV
|
||||||
|
};
|
||||||
public IEnumerable<(string name, Type type, string description)> SupportedOptions =>
|
public IEnumerable<(string name, Type type, string description)> SupportedOptions =>
|
||||||
new (string name, Type type, string description)[] { };
|
new (string name, Type type, string description)[] { };
|
||||||
public IEnumerable<string> KnownExtensions => new[] {".qcow", ".qc"};
|
public IEnumerable<string> KnownExtensions => new[] {".qcow", ".qc"};
|
||||||
@@ -501,7 +506,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
imageInfo = new ImageInfo {MediaType = mediaType, SectorSize = sectorSize, Sectors = sectors};
|
imageInfo = new ImageInfo {MediaType = mediaType, SectorSize = sectorSize, Sectors = sectors};
|
||||||
|
|
||||||
try { writingStream = new FileStream(path, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.None); }
|
try { writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); }
|
||||||
catch(IOException e)
|
catch(IOException e)
|
||||||
{
|
{
|
||||||
ErrorMessage = $"Could not create new image file, exception {e.Message}";
|
ErrorMessage = $"Could not create new image file, exception {e.Message}";
|
||||||
@@ -713,6 +718,11 @@ namespace DiscImageChef.DiscImages
|
|||||||
for(long i = 0; i < l1Table.LongLength; i++)
|
for(long i = 0; i < l1Table.LongLength; i++)
|
||||||
writingStream.Write(BigEndianBitConverter.GetBytes(l1Table[i]), 0, 8);
|
writingStream.Write(BigEndianBitConverter.GetBytes(l1Table[i]), 0, 8);
|
||||||
|
|
||||||
|
writingStream.Flush();
|
||||||
|
writingStream.Close();
|
||||||
|
|
||||||
|
IsWriting = false;
|
||||||
|
ErrorMessage = "";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -497,7 +497,12 @@ namespace DiscImageChef.DiscImages
|
|||||||
public IEnumerable<MediaTagType> SupportedMediaTags => new MediaTagType[] { };
|
public IEnumerable<MediaTagType> SupportedMediaTags => new MediaTagType[] { };
|
||||||
public IEnumerable<SectorTagType> SupportedSectorTags => new SectorTagType[] { };
|
public IEnumerable<SectorTagType> SupportedSectorTags => new SectorTagType[] { };
|
||||||
public IEnumerable<MediaType> SupportedMediaTypes =>
|
public IEnumerable<MediaType> SupportedMediaTypes =>
|
||||||
new[] {MediaType.Unknown, MediaType.GENERIC_HDD};
|
new[]
|
||||||
|
{
|
||||||
|
MediaType.Unknown, MediaType.GENERIC_HDD, MediaType.FlashDrive, MediaType.CompactFlash,
|
||||||
|
MediaType.CompactFlashType2, MediaType.PCCardTypeI, MediaType.PCCardTypeII, MediaType.PCCardTypeIII,
|
||||||
|
MediaType.PCCardTypeIV
|
||||||
|
};
|
||||||
public IEnumerable<(string name, Type type, string description)> SupportedOptions =>
|
public IEnumerable<(string name, Type type, string description)> SupportedOptions =>
|
||||||
new (string name, Type type, string description)[] { };
|
new (string name, Type type, string description)[] { };
|
||||||
public IEnumerable<string> KnownExtensions => new[] {".qcow2", ".qc2", ".qcow3", ".qc3"};
|
public IEnumerable<string> KnownExtensions => new[] {".qcow2", ".qc2", ".qcow3", ".qc3"};
|
||||||
@@ -528,7 +533,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
imageInfo = new ImageInfo {MediaType = mediaType, SectorSize = sectorSize, Sectors = sectors};
|
imageInfo = new ImageInfo {MediaType = mediaType, SectorSize = sectorSize, Sectors = sectors};
|
||||||
|
|
||||||
try { writingStream = new FileStream(path, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.None); }
|
try { writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); }
|
||||||
catch(IOException e)
|
catch(IOException e)
|
||||||
{
|
{
|
||||||
ErrorMessage = $"Could not create new image file, exception {e.Message}";
|
ErrorMessage = $"Could not create new image file, exception {e.Message}";
|
||||||
@@ -788,7 +793,10 @@ namespace DiscImageChef.DiscImages
|
|||||||
for(long i = 0; i < l1Table.LongLength; i++)
|
for(long i = 0; i < l1Table.LongLength; i++)
|
||||||
writingStream.Write(BigEndianBitConverter.GetBytes(l1Table[i]), 0, 8);
|
writingStream.Write(BigEndianBitConverter.GetBytes(l1Table[i]), 0, 8);
|
||||||
|
|
||||||
IsWriting = false;
|
writingStream.Flush();
|
||||||
|
writingStream.Close();
|
||||||
|
|
||||||
|
IsWriting = false;
|
||||||
ErrorMessage = "";
|
ErrorMessage = "";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -449,7 +449,13 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
public IEnumerable<MediaTagType> SupportedMediaTags => new MediaTagType[] { };
|
public IEnumerable<MediaTagType> SupportedMediaTags => new MediaTagType[] { };
|
||||||
public IEnumerable<SectorTagType> SupportedSectorTags => new SectorTagType[] { };
|
public IEnumerable<SectorTagType> SupportedSectorTags => new SectorTagType[] { };
|
||||||
public IEnumerable<MediaType> SupportedMediaTypes => new[] {MediaType.Unknown, MediaType.GENERIC_HDD};
|
public IEnumerable<MediaType> SupportedMediaTypes =>
|
||||||
|
new[]
|
||||||
|
{
|
||||||
|
MediaType.Unknown, MediaType.GENERIC_HDD, MediaType.FlashDrive, MediaType.CompactFlash,
|
||||||
|
MediaType.CompactFlashType2, MediaType.PCCardTypeI, MediaType.PCCardTypeII, MediaType.PCCardTypeIII,
|
||||||
|
MediaType.PCCardTypeIV
|
||||||
|
};
|
||||||
// TODO: Add cluster size option
|
// TODO: Add cluster size option
|
||||||
public IEnumerable<(string name, Type type, string description)> SupportedOptions =>
|
public IEnumerable<(string name, Type type, string description)> SupportedOptions =>
|
||||||
new (string name, Type type, string description)[] { };
|
new (string name, Type type, string description)[] { };
|
||||||
@@ -481,7 +487,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
imageInfo = new ImageInfo {MediaType = mediaType, SectorSize = sectorSize, Sectors = sectors};
|
imageInfo = new ImageInfo {MediaType = mediaType, SectorSize = sectorSize, Sectors = sectors};
|
||||||
|
|
||||||
try { writingStream = new FileStream(path, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.None); }
|
try { writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); }
|
||||||
catch(IOException e)
|
catch(IOException e)
|
||||||
{
|
{
|
||||||
ErrorMessage = $"Could not create new image file, exception {e.Message}";
|
ErrorMessage = $"Could not create new image file, exception {e.Message}";
|
||||||
@@ -676,6 +682,11 @@ namespace DiscImageChef.DiscImages
|
|||||||
writingStream.Seek((long)qHdr.l1_table_offset, SeekOrigin.Begin);
|
writingStream.Seek((long)qHdr.l1_table_offset, SeekOrigin.Begin);
|
||||||
for(long i = 0; i < l1Table.LongLength; i++) writingStream.Write(BitConverter.GetBytes(l1Table[i]), 0, 8);
|
for(long i = 0; i < l1Table.LongLength; i++) writingStream.Write(BitConverter.GetBytes(l1Table[i]), 0, 8);
|
||||||
|
|
||||||
|
writingStream.Flush();
|
||||||
|
writingStream.Close();
|
||||||
|
|
||||||
|
IsWriting = false;
|
||||||
|
ErrorMessage = "";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -336,7 +336,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
public bool Create(string path, MediaType mediaType, Dictionary<string, string> options, ulong sectors,
|
public bool Create(string path, MediaType mediaType, Dictionary<string, string> options, ulong sectors,
|
||||||
uint sectorSize)
|
uint sectorSize)
|
||||||
{
|
{
|
||||||
if(sectorSize == 512)
|
if(sectorSize != 512)
|
||||||
{
|
{
|
||||||
ErrorMessage = "Unsupported sector size";
|
ErrorMessage = "Unsupported sector size";
|
||||||
return false;
|
return false;
|
||||||
@@ -366,7 +366,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
SectorsPerTrack = geometry.sectorsPerTrack
|
SectorsPerTrack = geometry.sectorsPerTrack
|
||||||
};
|
};
|
||||||
|
|
||||||
try { writingStream = new FileStream(path, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.None); }
|
try { writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); }
|
||||||
catch(IOException e)
|
catch(IOException e)
|
||||||
{
|
{
|
||||||
ErrorMessage = $"Could not create new image file, exception {e.Message}";
|
ErrorMessage = $"Could not create new image file, exception {e.Message}";
|
||||||
@@ -485,7 +485,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
}
|
}
|
||||||
|
|
||||||
string headerSignature =
|
string headerSignature =
|
||||||
$"Disk IMage VER 1.0 Copyright (C) ({DateTime.Now.Year:D4}) Ray Arachelian, All Rights Reserved. DIC ";
|
$"Disk IMage VER 1.0 Copyright (C) {DateTime.Now.Year:D4} Ray Arachelian, All Rights Reserved. DIC ";
|
||||||
RayHdr header = new RayHdr
|
RayHdr header = new RayHdr
|
||||||
{
|
{
|
||||||
signature = Encoding.ASCII.GetBytes(headerSignature),
|
signature = Encoding.ASCII.GetBytes(headerSignature),
|
||||||
@@ -507,8 +507,9 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
writingStream.Flush();
|
writingStream.Flush();
|
||||||
writingStream.Close();
|
writingStream.Close();
|
||||||
IsWriting = false;
|
|
||||||
|
|
||||||
|
IsWriting = false;
|
||||||
|
ErrorMessage = "";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -289,11 +289,15 @@ namespace DiscImageChef.DiscImages
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<MediaTagType> SupportedMediaTags =>
|
public IEnumerable<MediaTagType> SupportedMediaTags => new[] {MediaTagType.ATA_IDENTIFY};
|
||||||
new[] {MediaTagType.ATA_IDENTIFY};
|
|
||||||
public IEnumerable<SectorTagType> SupportedSectorTags => new SectorTagType[] { };
|
public IEnumerable<SectorTagType> SupportedSectorTags => new SectorTagType[] { };
|
||||||
public IEnumerable<MediaType> SupportedMediaTypes =>
|
public IEnumerable<MediaType> SupportedMediaTypes =>
|
||||||
new[] {MediaType.GENERIC_HDD, MediaType.Unknown};
|
new[]
|
||||||
|
{
|
||||||
|
MediaType.GENERIC_HDD, MediaType.Unknown, MediaType.FlashDrive, MediaType.CompactFlash,
|
||||||
|
MediaType.CompactFlashType2, MediaType.PCCardTypeI, MediaType.PCCardTypeII, MediaType.PCCardTypeIII,
|
||||||
|
MediaType.PCCardTypeIV
|
||||||
|
};
|
||||||
public IEnumerable<(string name, Type type, string description)> SupportedOptions =>
|
public IEnumerable<(string name, Type type, string description)> SupportedOptions =>
|
||||||
new (string name, Type type, string description)[] { };
|
new (string name, Type type, string description)[] { };
|
||||||
public IEnumerable<string> KnownExtensions => new[] {".ide"};
|
public IEnumerable<string> KnownExtensions => new[] {".ide"};
|
||||||
@@ -309,7 +313,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(sectors > ushort.MaxValue)
|
if(sectors > 63 * 16 * 1024)
|
||||||
{
|
{
|
||||||
ErrorMessage = $"Too many sectors";
|
ErrorMessage = $"Too many sectors";
|
||||||
return false;
|
return false;
|
||||||
@@ -323,7 +327,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
imageInfo = new ImageInfo {MediaType = mediaType, SectorSize = sectorSize, Sectors = sectors};
|
imageInfo = new ImageInfo {MediaType = mediaType, SectorSize = sectorSize, Sectors = sectors};
|
||||||
|
|
||||||
try { writingStream = new FileStream(path, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.None); }
|
try { writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); }
|
||||||
catch(IOException e)
|
catch(IOException e)
|
||||||
{
|
{
|
||||||
ErrorMessage = $"Could not create new image file, exception {e.Message}";
|
ErrorMessage = $"Could not create new image file, exception {e.Message}";
|
||||||
@@ -502,7 +506,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
if(string.IsNullOrEmpty(imageInfo.DriveFirmwareRevision)) Interop.Version.GetVersion();
|
if(string.IsNullOrEmpty(imageInfo.DriveFirmwareRevision)) Interop.Version.GetVersion();
|
||||||
|
|
||||||
if(string.IsNullOrEmpty(imageInfo.DriveSerialNumber))
|
if(string.IsNullOrEmpty(imageInfo.DriveSerialNumber))
|
||||||
imageInfo.DriveSerialNumber = $"{new Random().NextDouble():X16}";
|
imageInfo.DriveSerialNumber = $"{new Random().NextDouble():16X}";
|
||||||
|
|
||||||
byte[] ataIdBytes = new byte[Marshal.SizeOf(ataId)];
|
byte[] ataIdBytes = new byte[Marshal.SizeOf(ataId)];
|
||||||
IntPtr ptr = Marshal.AllocHGlobal(512);
|
IntPtr ptr = Marshal.AllocHGlobal(512);
|
||||||
@@ -529,8 +533,9 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
writingStream.Flush();
|
writingStream.Flush();
|
||||||
writingStream.Close();
|
writingStream.Close();
|
||||||
IsWriting = false;
|
|
||||||
|
|
||||||
|
IsWriting = false;
|
||||||
|
ErrorMessage = "";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -478,8 +478,9 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
writingStream.Flush();
|
writingStream.Flush();
|
||||||
writingStream.Close();
|
writingStream.Close();
|
||||||
IsWriting = false;
|
|
||||||
|
|
||||||
|
IsWriting = false;
|
||||||
|
ErrorMessage = "";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -512,7 +513,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
imageInfo = new ImageInfo {MediaType = mediaType, SectorSize = sectorSize, Sectors = sectors};
|
imageInfo = new ImageInfo {MediaType = mediaType, SectorSize = sectorSize, Sectors = sectors};
|
||||||
|
|
||||||
try { writingStream = new FileStream(path, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.None); }
|
try { writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); }
|
||||||
catch(IOException e)
|
catch(IOException e)
|
||||||
{
|
{
|
||||||
ErrorMessage = $"Could not create new image file, exception {e.Message}";
|
ErrorMessage = $"Could not create new image file, exception {e.Message}";
|
||||||
|
|||||||
@@ -268,7 +268,12 @@ namespace DiscImageChef.DiscImages
|
|||||||
public IEnumerable<MediaTagType> SupportedMediaTags => new MediaTagType[] { };
|
public IEnumerable<MediaTagType> SupportedMediaTags => new MediaTagType[] { };
|
||||||
public IEnumerable<SectorTagType> SupportedSectorTags => new SectorTagType[] { };
|
public IEnumerable<SectorTagType> SupportedSectorTags => new SectorTagType[] { };
|
||||||
public IEnumerable<MediaType> SupportedMediaTypes =>
|
public IEnumerable<MediaType> SupportedMediaTypes =>
|
||||||
new[] {MediaType.GENERIC_HDD, MediaType.Unknown};
|
new[]
|
||||||
|
{
|
||||||
|
MediaType.GENERIC_HDD, MediaType.Unknown, MediaType.FlashDrive, MediaType.CompactFlash,
|
||||||
|
MediaType.CompactFlashType2, MediaType.PCCardTypeI, MediaType.PCCardTypeII, MediaType.PCCardTypeIII,
|
||||||
|
MediaType.PCCardTypeIV
|
||||||
|
};
|
||||||
public IEnumerable<(string name, Type type, string description)> SupportedOptions =>
|
public IEnumerable<(string name, Type type, string description)> SupportedOptions =>
|
||||||
new (string name, Type type, string description)[] { };
|
new (string name, Type type, string description)[] { };
|
||||||
public IEnumerable<string> KnownExtensions => new[] {".t98"};
|
public IEnumerable<string> KnownExtensions => new[] {".t98"};
|
||||||
@@ -292,7 +297,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
imageInfo = new ImageInfo {MediaType = mediaType, SectorSize = sectorSize, Sectors = sectors};
|
imageInfo = new ImageInfo {MediaType = mediaType, SectorSize = sectorSize, Sectors = sectors};
|
||||||
|
|
||||||
try { writingStream = new FileStream(path, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.None); }
|
try { writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); }
|
||||||
catch(IOException e)
|
catch(IOException e)
|
||||||
{
|
{
|
||||||
ErrorMessage = $"Could not create new image file, exception {e.Message}";
|
ErrorMessage = $"Could not create new image file, exception {e.Message}";
|
||||||
@@ -396,8 +401,9 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
writingStream.Flush();
|
writingStream.Flush();
|
||||||
writingStream.Close();
|
writingStream.Close();
|
||||||
IsWriting = false;
|
|
||||||
|
|
||||||
|
IsWriting = false;
|
||||||
|
ErrorMessage = "";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -706,7 +706,12 @@ namespace DiscImageChef.DiscImages
|
|||||||
public IEnumerable<MediaTagType> SupportedMediaTags => new MediaTagType[] { };
|
public IEnumerable<MediaTagType> SupportedMediaTags => new MediaTagType[] { };
|
||||||
public IEnumerable<SectorTagType> SupportedSectorTags => new SectorTagType[] { };
|
public IEnumerable<SectorTagType> SupportedSectorTags => new SectorTagType[] { };
|
||||||
public IEnumerable<MediaType> SupportedMediaTypes =>
|
public IEnumerable<MediaType> SupportedMediaTypes =>
|
||||||
new[] {MediaType.Unknown, MediaType.GENERIC_HDD};
|
new[]
|
||||||
|
{
|
||||||
|
MediaType.Unknown, MediaType.GENERIC_HDD, MediaType.FlashDrive, MediaType.CompactFlash,
|
||||||
|
MediaType.CompactFlashType2, MediaType.PCCardTypeI, MediaType.PCCardTypeII, MediaType.PCCardTypeIII,
|
||||||
|
MediaType.PCCardTypeIV
|
||||||
|
};
|
||||||
public IEnumerable<(string name, Type type, string description)> SupportedOptions =>
|
public IEnumerable<(string name, Type type, string description)> SupportedOptions =>
|
||||||
new (string name, Type type, string description)[] { };
|
new (string name, Type type, string description)[] { };
|
||||||
public IEnumerable<string> KnownExtensions => new[] {".dmg"};
|
public IEnumerable<string> KnownExtensions => new[] {".dmg"};
|
||||||
@@ -730,7 +735,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
imageInfo = new ImageInfo {MediaType = mediaType, SectorSize = sectorSize, Sectors = sectors};
|
imageInfo = new ImageInfo {MediaType = mediaType, SectorSize = sectorSize, Sectors = sectors};
|
||||||
|
|
||||||
try { writingStream = new FileStream(path, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.None); }
|
try { writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); }
|
||||||
catch(IOException e)
|
catch(IOException e)
|
||||||
{
|
{
|
||||||
ErrorMessage = $"Could not create new image file, exception {e.Message}";
|
ErrorMessage = $"Could not create new image file, exception {e.Message}";
|
||||||
@@ -1014,9 +1019,9 @@ namespace DiscImageChef.DiscImages
|
|||||||
writingStream.Write(BigEndianBitConverter.GetBytes(footer.imageVariant), 0, 4);
|
writingStream.Write(BigEndianBitConverter.GetBytes(footer.imageVariant), 0, 4);
|
||||||
writingStream.Write(BigEndianBitConverter.GetBytes(footer.sectorCount), 0, 8);
|
writingStream.Write(BigEndianBitConverter.GetBytes(footer.sectorCount), 0, 8);
|
||||||
writingStream.Write(new byte[12], 0, 12);
|
writingStream.Write(new byte[12], 0, 12);
|
||||||
writingStream.Close();
|
|
||||||
|
|
||||||
Crc32Context.File(writingStream.Name);
|
writingStream.Flush();
|
||||||
|
writingStream.Close();
|
||||||
|
|
||||||
IsWriting = false;
|
IsWriting = false;
|
||||||
ErrorMessage = "";
|
ErrorMessage = "";
|
||||||
|
|||||||
@@ -237,7 +237,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
ulong index = sectorAddress * vHdr.sectorSize / vHdr.blockSize;
|
ulong index = sectorAddress * vHdr.sectorSize / vHdr.blockSize;
|
||||||
ulong secOff = sectorAddress * vHdr.sectorSize % vHdr.blockSize;
|
ulong secOff = sectorAddress * vHdr.sectorSize % vHdr.blockSize;
|
||||||
|
|
||||||
uint ibmOff = ibm[index];
|
uint ibmOff = ibm[index];
|
||||||
|
|
||||||
if(ibmOff == VDI_EMPTY) return new byte[vHdr.sectorSize];
|
if(ibmOff == VDI_EMPTY) return new byte[vHdr.sectorSize];
|
||||||
|
|
||||||
@@ -375,7 +375,13 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
public IEnumerable<MediaTagType> SupportedMediaTags => new MediaTagType[] { };
|
public IEnumerable<MediaTagType> SupportedMediaTags => new MediaTagType[] { };
|
||||||
public IEnumerable<SectorTagType> SupportedSectorTags => new SectorTagType[] { };
|
public IEnumerable<SectorTagType> SupportedSectorTags => new SectorTagType[] { };
|
||||||
public IEnumerable<MediaType> SupportedMediaTypes => new[] {MediaType.Unknown, MediaType.GENERIC_HDD};
|
public IEnumerable<MediaType> SupportedMediaTypes =>
|
||||||
|
new[]
|
||||||
|
{
|
||||||
|
MediaType.Unknown, MediaType.GENERIC_HDD, MediaType.FlashDrive, MediaType.CompactFlash,
|
||||||
|
MediaType.CompactFlashType2, MediaType.PCCardTypeI, MediaType.PCCardTypeII, MediaType.PCCardTypeIII,
|
||||||
|
MediaType.PCCardTypeIV
|
||||||
|
};
|
||||||
// TODO: Add cluster size option
|
// TODO: Add cluster size option
|
||||||
public IEnumerable<(string name, Type type, string description)> SupportedOptions =>
|
public IEnumerable<(string name, Type type, string description)> SupportedOptions =>
|
||||||
new (string name, Type type, string description)[] { };
|
new (string name, Type type, string description)[] { };
|
||||||
@@ -406,7 +412,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
imageInfo = new ImageInfo {MediaType = mediaType, SectorSize = sectorSize, Sectors = sectors};
|
imageInfo = new ImageInfo {MediaType = mediaType, SectorSize = sectorSize, Sectors = sectors};
|
||||||
|
|
||||||
try { writingStream = new FileStream(path, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.None); }
|
try { writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); }
|
||||||
catch(IOException e)
|
catch(IOException e)
|
||||||
{
|
{
|
||||||
ErrorMessage = $"Could not create new image file, exception {e.Message}";
|
ErrorMessage = $"Could not create new image file, exception {e.Message}";
|
||||||
@@ -564,6 +570,28 @@ namespace DiscImageChef.DiscImages
|
|||||||
? imageInfo.Comments.Substring(0, 255)
|
? imageInfo.Comments.Substring(0, 255)
|
||||||
: imageInfo.Comments;
|
: imageInfo.Comments;
|
||||||
|
|
||||||
|
if(vHdr.cylinders == 0)
|
||||||
|
{
|
||||||
|
vHdr.cylinders = (uint)(imageInfo.Sectors / 16 / 63);
|
||||||
|
vHdr.heads = 16;
|
||||||
|
vHdr.spt = 63;
|
||||||
|
|
||||||
|
while(vHdr.cylinders == 0)
|
||||||
|
{
|
||||||
|
vHdr.heads--;
|
||||||
|
|
||||||
|
if(vHdr.heads == 0)
|
||||||
|
{
|
||||||
|
vHdr.spt--;
|
||||||
|
vHdr.heads = 16;
|
||||||
|
}
|
||||||
|
|
||||||
|
vHdr.cylinders = (uint)(imageInfo.Sectors / vHdr.heads / vHdr.spt);
|
||||||
|
|
||||||
|
if(vHdr.cylinders == 0 && vHdr.heads == 0 && vHdr.spt == 0) break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
byte[] hdr = new byte[Marshal.SizeOf(typeof(VdiHeader))];
|
byte[] hdr = new byte[Marshal.SizeOf(typeof(VdiHeader))];
|
||||||
IntPtr hdrPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(VdiHeader)));
|
IntPtr hdrPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(VdiHeader)));
|
||||||
Marshal.StructureToPtr(vHdr, hdrPtr, true);
|
Marshal.StructureToPtr(vHdr, hdrPtr, true);
|
||||||
@@ -576,6 +604,11 @@ namespace DiscImageChef.DiscImages
|
|||||||
writingStream.Seek(vHdr.offsetBlocks, SeekOrigin.Begin);
|
writingStream.Seek(vHdr.offsetBlocks, SeekOrigin.Begin);
|
||||||
for(long i = 0; i < ibm.LongLength; i++) writingStream.Write(BitConverter.GetBytes(ibm[i]), 0, 4);
|
for(long i = 0; i < ibm.LongLength; i++) writingStream.Write(BitConverter.GetBytes(ibm[i]), 0, 4);
|
||||||
|
|
||||||
|
writingStream.Flush();
|
||||||
|
writingStream.Close();
|
||||||
|
|
||||||
|
IsWriting = false;
|
||||||
|
ErrorMessage = "";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1094,7 +1094,13 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
public IEnumerable<MediaTagType> SupportedMediaTags => new MediaTagType[] { };
|
public IEnumerable<MediaTagType> SupportedMediaTags => new MediaTagType[] { };
|
||||||
public IEnumerable<SectorTagType> SupportedSectorTags => new SectorTagType[] { };
|
public IEnumerable<SectorTagType> SupportedSectorTags => new SectorTagType[] { };
|
||||||
public IEnumerable<MediaType> SupportedMediaTypes => new[] {MediaType.GENERIC_HDD, MediaType.Unknown};
|
public IEnumerable<MediaType> SupportedMediaTypes =>
|
||||||
|
new[]
|
||||||
|
{
|
||||||
|
MediaType.GENERIC_HDD, MediaType.Unknown, MediaType.FlashDrive, MediaType.CompactFlash,
|
||||||
|
MediaType.CompactFlashType2, MediaType.PCCardTypeI, MediaType.PCCardTypeII, MediaType.PCCardTypeIII,
|
||||||
|
MediaType.PCCardTypeIV
|
||||||
|
};
|
||||||
// TODO: Support dynamic images
|
// TODO: Support dynamic images
|
||||||
public IEnumerable<(string name, Type type, string description)> SupportedOptions =>
|
public IEnumerable<(string name, Type type, string description)> SupportedOptions =>
|
||||||
new (string name, Type type, string description)[] { };
|
new (string name, Type type, string description)[] { };
|
||||||
@@ -1119,7 +1125,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
imageInfo = new ImageInfo {MediaType = mediaType, SectorSize = sectorSize, Sectors = sectors};
|
imageInfo = new ImageInfo {MediaType = mediaType, SectorSize = sectorSize, Sectors = sectors};
|
||||||
|
|
||||||
try { writingStream = new FileStream(path, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.None); }
|
try { writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); }
|
||||||
catch(IOException e)
|
catch(IOException e)
|
||||||
{
|
{
|
||||||
ErrorMessage = $"Could not create new image file, exception {e.Message}";
|
ErrorMessage = $"Could not create new image file, exception {e.Message}";
|
||||||
@@ -1288,8 +1294,9 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
writingStream.Flush();
|
writingStream.Flush();
|
||||||
writingStream.Close();
|
writingStream.Close();
|
||||||
IsWriting = false;
|
|
||||||
|
|
||||||
|
IsWriting = false;
|
||||||
|
ErrorMessage = "";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -861,7 +861,12 @@ namespace DiscImageChef.DiscImages
|
|||||||
public IEnumerable<MediaTagType> SupportedMediaTags => new MediaTagType[] { };
|
public IEnumerable<MediaTagType> SupportedMediaTags => new MediaTagType[] { };
|
||||||
public IEnumerable<SectorTagType> SupportedSectorTags => new SectorTagType[] { };
|
public IEnumerable<SectorTagType> SupportedSectorTags => new SectorTagType[] { };
|
||||||
public IEnumerable<MediaType> SupportedMediaTypes =>
|
public IEnumerable<MediaType> SupportedMediaTypes =>
|
||||||
new[] {MediaType.GENERIC_HDD, MediaType.Unknown};
|
new[]
|
||||||
|
{
|
||||||
|
MediaType.GENERIC_HDD, MediaType.Unknown, MediaType.FlashDrive, MediaType.CompactFlash,
|
||||||
|
MediaType.CompactFlashType2, MediaType.PCCardTypeI, MediaType.PCCardTypeII, MediaType.PCCardTypeIII,
|
||||||
|
MediaType.PCCardTypeIV
|
||||||
|
};
|
||||||
public IEnumerable<(string name, Type type, string description)> SupportedOptions =>
|
public IEnumerable<(string name, Type type, string description)> SupportedOptions =>
|
||||||
new[]
|
new[]
|
||||||
{
|
{
|
||||||
@@ -961,8 +966,8 @@ namespace DiscImageChef.DiscImages
|
|||||||
writingBaseName = Path.Combine(Path.GetDirectoryName(path), Path.GetFileNameWithoutExtension(path));
|
writingBaseName = Path.Combine(Path.GetDirectoryName(path), Path.GetFileNameWithoutExtension(path));
|
||||||
descriptorStream = new StreamWriter(path, false, Encoding.ASCII);
|
descriptorStream = new StreamWriter(path, false, Encoding.ASCII);
|
||||||
// TODO: Support split
|
// TODO: Support split
|
||||||
writingStream = new FileStream(writingBaseName + "-flat.vmdk", FileMode.CreateNew, FileAccess.ReadWrite,
|
writingStream = new FileStream(writingBaseName + "-flat.vmdk", FileMode.OpenOrCreate,
|
||||||
FileShare.None);
|
FileAccess.ReadWrite, FileShare.None);
|
||||||
}
|
}
|
||||||
catch(IOException e)
|
catch(IOException e)
|
||||||
{
|
{
|
||||||
@@ -1108,8 +1113,9 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
descriptorStream.Flush();
|
descriptorStream.Flush();
|
||||||
descriptorStream.Close();
|
descriptorStream.Close();
|
||||||
IsWriting = false;
|
|
||||||
|
|
||||||
|
IsWriting = false;
|
||||||
|
ErrorMessage = "";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -299,7 +299,12 @@ namespace DiscImageChef.DiscImages
|
|||||||
public IEnumerable<MediaTagType> SupportedMediaTags => new MediaTagType[] { };
|
public IEnumerable<MediaTagType> SupportedMediaTags => new MediaTagType[] { };
|
||||||
public IEnumerable<SectorTagType> SupportedSectorTags => new SectorTagType[] { };
|
public IEnumerable<SectorTagType> SupportedSectorTags => new SectorTagType[] { };
|
||||||
public IEnumerable<MediaType> SupportedMediaTypes =>
|
public IEnumerable<MediaType> SupportedMediaTypes =>
|
||||||
new[] {MediaType.GENERIC_HDD, MediaType.Unknown};
|
new[]
|
||||||
|
{
|
||||||
|
MediaType.GENERIC_HDD, MediaType.Unknown, MediaType.FlashDrive, MediaType.CompactFlash,
|
||||||
|
MediaType.CompactFlashType2, MediaType.PCCardTypeI, MediaType.PCCardTypeII, MediaType.PCCardTypeIII,
|
||||||
|
MediaType.PCCardTypeIV
|
||||||
|
};
|
||||||
public IEnumerable<(string name, Type type, string description)> SupportedOptions =>
|
public IEnumerable<(string name, Type type, string description)> SupportedOptions =>
|
||||||
new (string name, Type type, string description)[] { };
|
new (string name, Type type, string description)[] { };
|
||||||
public IEnumerable<string> KnownExtensions => new[] {".v98"};
|
public IEnumerable<string> KnownExtensions => new[] {".v98"};
|
||||||
@@ -309,7 +314,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
public bool Create(string path, MediaType mediaType, Dictionary<string, string> options, ulong sectors,
|
public bool Create(string path, MediaType mediaType, Dictionary<string, string> options, ulong sectors,
|
||||||
uint sectorSize)
|
uint sectorSize)
|
||||||
{
|
{
|
||||||
if(sectorSize == 0)
|
if(sectorSize != 512)
|
||||||
{
|
{
|
||||||
ErrorMessage = "Unsupported sector size";
|
ErrorMessage = "Unsupported sector size";
|
||||||
return false;
|
return false;
|
||||||
@@ -329,7 +334,7 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
imageInfo = new ImageInfo {MediaType = mediaType, SectorSize = sectorSize, Sectors = sectors};
|
imageInfo = new ImageInfo {MediaType = mediaType, SectorSize = sectorSize, Sectors = sectors};
|
||||||
|
|
||||||
try { writingStream = new FileStream(path, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.None); }
|
try { writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); }
|
||||||
catch(IOException e)
|
catch(IOException e)
|
||||||
{
|
{
|
||||||
ErrorMessage = $"Could not create new image file, exception {e.Message}";
|
ErrorMessage = $"Could not create new image file, exception {e.Message}";
|
||||||
@@ -480,8 +485,9 @@ namespace DiscImageChef.DiscImages
|
|||||||
|
|
||||||
writingStream.Flush();
|
writingStream.Flush();
|
||||||
writingStream.Close();
|
writingStream.Close();
|
||||||
IsWriting = false;
|
|
||||||
|
|
||||||
|
IsWriting = false;
|
||||||
|
ErrorMessage = "";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -89,6 +89,12 @@ namespace DiscImageChef.Commands
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(File.Exists(options.OutputFile))
|
||||||
|
{
|
||||||
|
DicConsole.ErrorWriteLine("Output file already exists, not continuing.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
PluginBase plugins = new PluginBase();
|
PluginBase plugins = new PluginBase();
|
||||||
IMediaImage inputFormat = ImageFormat.Detect(inputFilter);
|
IMediaImage inputFormat = ImageFormat.Detect(inputFilter);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user