Code restyling.

This commit is contained in:
2020-02-29 18:03:35 +00:00
parent 4ea327f0c6
commit f7e173710e
855 changed files with 43605 additions and 38045 deletions

View File

@@ -43,32 +43,42 @@ namespace Aaru.DiscImages
public partial class AppleDos
{
public bool Create(string path, MediaType mediaType, Dictionary<string, string> options, ulong sectors,
uint sectorSize)
uint sectorSize)
{
if(sectorSize != 256)
{
ErrorMessage = "Unsupported sector size";
return false;
}
if(mediaType != MediaType.Apple33SS)
{
ErrorMessage = $"Unsupport media format {mediaType}";
return false;
}
if(sectors > uint.MaxValue)
{
ErrorMessage = "Too many sectors";
return false;
}
imageInfo = new ImageInfo {MediaType = mediaType, SectorSize = sectorSize, Sectors = sectors};
imageInfo = new ImageInfo
{
MediaType = mediaType, SectorSize = sectorSize, Sectors = sectors
};
try { writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); }
try
{
writingStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None);
}
catch(IOException e)
{
ErrorMessage = $"Could not create new image file, exception {e.Message}";
return false;
}
@@ -77,12 +87,14 @@ namespace Aaru.DiscImages
IsWriting = true;
ErrorMessage = null;
return true;
}
public bool WriteMediaTag(byte[] data, MediaTagType tag)
{
ErrorMessage = "Unsupported feature";
return false;
}
@@ -93,36 +105,42 @@ namespace Aaru.DiscImages
if(!IsWriting)
{
ErrorMessage = "Tried to write on a non-writable image";
return false;
}
if(data.Length % imageInfo.SectorSize != 0)
{
ErrorMessage = "Incorrect data size";
return false;
}
if(sectorAddress + length > imageInfo.Sectors)
{
ErrorMessage = "Tried to write past image size";
return false;
}
Array.Copy(data, 0, deinterleaved, (int)(sectorAddress * imageInfo.SectorSize), data.Length);
ErrorMessage = "";
return true;
}
public bool WriteSectorLong(byte[] data, ulong sectorAddress)
{
ErrorMessage = "Writing sectors with tags is not supported.";
return false;
}
public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length)
{
ErrorMessage = "Writing sectors with tags is not supported.";
return false;
}
@@ -131,6 +149,7 @@ namespace Aaru.DiscImages
if(!IsWriting)
{
ErrorMessage = "Image is not opened for writing";
return false;
}
@@ -153,7 +172,8 @@ namespace Aaru.DiscImages
for(int t = 0; t < 35; t++)
{
for(int s = 0; s < 16; s++)
Array.Copy(deinterleaved, t * 16 * 256 + offsets[s] * 256, tmp, t * 16 * 256 + s * 256, 256);
Array.Copy(deinterleaved, (t * 16 * 256) + (offsets[s] * 256), tmp, (t * 16 * 256) + (s * 256),
256);
}
writingStream.Seek(0, SeekOrigin.Begin);
@@ -164,6 +184,7 @@ namespace Aaru.DiscImages
IsWriting = false;
ErrorMessage = "";
return true;
}
@@ -174,12 +195,14 @@ namespace Aaru.DiscImages
public bool WriteSectorTag(byte[] data, ulong sectorAddress, SectorTagType tag)
{
ErrorMessage = "Writing sectors with tags is not supported.";
return false;
}
public bool WriteSectorsTag(byte[] data, ulong sectorAddress, uint length, SectorTagType tag)
{
ErrorMessage = "Writing sectors with tags is not supported.";
return false;
}