mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 19:24:27 +00:00
Add interface for setting media geometry.
This commit is contained in:
@@ -415,24 +415,26 @@ namespace DiscImageChef.DiscImages
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO: Interface to set geometry
|
||||
imageInfo.Cylinders = (uint)(imageInfo.Sectors / 8 / 17);
|
||||
imageInfo.Heads = 8;
|
||||
imageInfo.SectorsPerTrack = 17;
|
||||
|
||||
while(imageInfo.Cylinders == 0)
|
||||
if(imageInfo.Cylinders == 0)
|
||||
{
|
||||
imageInfo.Heads--;
|
||||
imageInfo.Cylinders = (uint)(imageInfo.Sectors / 8 / 17);
|
||||
imageInfo.Heads = 8;
|
||||
imageInfo.SectorsPerTrack = 17;
|
||||
|
||||
if(imageInfo.Heads == 0)
|
||||
while(imageInfo.Cylinders == 0)
|
||||
{
|
||||
imageInfo.SectorsPerTrack--;
|
||||
imageInfo.Heads = 16;
|
||||
imageInfo.Heads--;
|
||||
|
||||
if(imageInfo.Heads == 0)
|
||||
{
|
||||
imageInfo.SectorsPerTrack--;
|
||||
imageInfo.Heads = 16;
|
||||
}
|
||||
|
||||
imageInfo.Cylinders = (uint)(imageInfo.Sectors / imageInfo.Heads / imageInfo.SectorsPerTrack);
|
||||
|
||||
if(imageInfo.Cylinders == 0 && imageInfo.Heads == 0 && imageInfo.SectorsPerTrack == 0) break;
|
||||
}
|
||||
|
||||
imageInfo.Cylinders = (uint)(imageInfo.Sectors / imageInfo.Heads / imageInfo.SectorsPerTrack);
|
||||
|
||||
if(imageInfo.Cylinders == 0 && imageInfo.Heads == 0 && imageInfo.SectorsPerTrack == 0) break;
|
||||
}
|
||||
|
||||
Nhdr0Header header = new Nhdr0Header
|
||||
@@ -477,6 +479,33 @@ namespace DiscImageChef.DiscImages
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool SetGeometry(uint cylinders, uint heads, uint sectorsPerTrack)
|
||||
{
|
||||
if(cylinders > int.MaxValue)
|
||||
{
|
||||
ErrorMessage = "Too many cylinders.";
|
||||
return false;
|
||||
}
|
||||
|
||||
if(heads > short.MaxValue)
|
||||
{
|
||||
ErrorMessage = "Too many heads.";
|
||||
return false;
|
||||
}
|
||||
|
||||
if(sectorsPerTrack > short.MaxValue)
|
||||
{
|
||||
ErrorMessage = "Too many sectors per track.";
|
||||
return false;
|
||||
}
|
||||
|
||||
imageInfo.SectorsPerTrack = sectorsPerTrack;
|
||||
imageInfo.Heads = heads;
|
||||
imageInfo.Cylinders = cylinders;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
struct Nhdr0Header
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user