mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Corrected datetime field handling in ProDOS filesystem.
This commit is contained in:
@@ -1,3 +1,8 @@
|
|||||||
|
2015-04-19 Natalia Portillo <claunia@claunia.com>
|
||||||
|
|
||||||
|
* Plugins/ProDOS.cs:
|
||||||
|
Corrected datetime field handling in ProDOS filesystem.
|
||||||
|
|
||||||
2015-04-19 Natalia Portillo <claunia@claunia.com>
|
2015-04-19 Natalia Portillo <claunia@claunia.com>
|
||||||
|
|
||||||
* ImagePlugins/2MG.cs:
|
* ImagePlugins/2MG.cs:
|
||||||
|
|||||||
@@ -65,8 +65,8 @@ namespace DiscImageChef.Plugins
|
|||||||
|
|
||||||
const byte ProDOSVersion1 = 0x00;
|
const byte ProDOSVersion1 = 0x00;
|
||||||
|
|
||||||
const UInt32 ProDOSYearMask = 0xFF000000;
|
const UInt32 ProDOSYearMask = 0xFE000000;
|
||||||
const UInt32 ProDOSMonthMask = 0xE00000;
|
const UInt32 ProDOSMonthMask = 0x1E00000;
|
||||||
const UInt32 ProDOSDayMask = 0x1F0000;
|
const UInt32 ProDOSDayMask = 0x1F0000;
|
||||||
const UInt32 ProDOSHourMask = 0x1F00;
|
const UInt32 ProDOSHourMask = 0x1F00;
|
||||||
const UInt32 ProDOSMinuteMask = 0x3F;
|
const UInt32 ProDOSMinuteMask = 0x3F;
|
||||||
@@ -133,6 +133,7 @@ namespace DiscImageChef.Plugins
|
|||||||
|
|
||||||
byte[] temporal;
|
byte[] temporal;
|
||||||
int year, month, day, hour, minute;
|
int year, month, day, hour, minute;
|
||||||
|
UInt16 temp_timestamp_left, temp_timestamp_right;
|
||||||
UInt32 temp_timestamp;
|
UInt32 temp_timestamp;
|
||||||
|
|
||||||
rootDirectoryKeyBlock.zero = BitConverter.ToUInt16(rootDirectoryKeyBlockBytes, 0x00);
|
rootDirectoryKeyBlock.zero = BitConverter.ToUInt16(rootDirectoryKeyBlockBytes, 0x00);
|
||||||
@@ -144,16 +145,24 @@ namespace DiscImageChef.Plugins
|
|||||||
rootDirectoryKeyBlock.header.volume_name = Encoding.ASCII.GetString(temporal);
|
rootDirectoryKeyBlock.header.volume_name = Encoding.ASCII.GetString(temporal);
|
||||||
rootDirectoryKeyBlock.header.reserved = BitConverter.ToUInt64(rootDirectoryKeyBlockBytes, 0x14);
|
rootDirectoryKeyBlock.header.reserved = BitConverter.ToUInt64(rootDirectoryKeyBlockBytes, 0x14);
|
||||||
|
|
||||||
// This is wrong as I don't know year epoch
|
temp_timestamp_left = BitConverter.ToUInt16(rootDirectoryKeyBlockBytes, 0x1C);
|
||||||
// May also be wrong because documentation shows it as a 32 bit integer
|
temp_timestamp_right = BitConverter.ToUInt16(rootDirectoryKeyBlockBytes, 0x1E);
|
||||||
// but does not say if it treats as 16 bit (probably) little endian
|
temp_timestamp = (uint)((temp_timestamp_left << 16) + temp_timestamp_right);
|
||||||
// pair or as a 32 bit little endian integer.
|
year = (int)((temp_timestamp & ProDOSYearMask) >> 25);
|
||||||
temp_timestamp = BitConverter.ToUInt32(rootDirectoryKeyBlockBytes, 0x1C);
|
|
||||||
year = (int)((temp_timestamp & ProDOSYearMask) >> 24);
|
|
||||||
month = (int)((temp_timestamp & ProDOSMonthMask) >> 21);
|
month = (int)((temp_timestamp & ProDOSMonthMask) >> 21);
|
||||||
day = (int)((temp_timestamp & ProDOSDayMask) >> 16);
|
day = (int)((temp_timestamp & ProDOSDayMask) >> 16);
|
||||||
hour = (int)((temp_timestamp & ProDOSHourMask) >> 8);
|
hour = (int)((temp_timestamp & ProDOSHourMask) >> 8);
|
||||||
minute = (int)(temp_timestamp & ProDOSMinuteMask);
|
minute = (int)(temp_timestamp & ProDOSMinuteMask);
|
||||||
|
year += 1900;
|
||||||
|
if (year < 1940)
|
||||||
|
year += 100;
|
||||||
|
if (MainClass.isDebug)
|
||||||
|
{
|
||||||
|
Console.WriteLine("DEBUG (ProDOS plugin): temp_timestamp_left = 0x{0:X4}", temp_timestamp_left);
|
||||||
|
Console.WriteLine("DEBUG (ProDOS plugin): temp_timestamp_right = 0x{0:X4}", temp_timestamp_right);
|
||||||
|
Console.WriteLine("DEBUG (ProDOS plugin): temp_timestamp = 0x{0:X8}", temp_timestamp);
|
||||||
|
Console.WriteLine("DEBUG (ProDOS plugin): Datetime field year {0}, month {1}, day {2}, hour {3}, minute {4}.", year, month, day, hour, minute);
|
||||||
|
}
|
||||||
rootDirectoryKeyBlock.header.creation_time = new DateTime(year, month, day, hour, minute, 0);
|
rootDirectoryKeyBlock.header.creation_time = new DateTime(year, month, day, hour, minute, 0);
|
||||||
|
|
||||||
rootDirectoryKeyBlock.header.version = rootDirectoryKeyBlockBytes[0x20];
|
rootDirectoryKeyBlock.header.version = rootDirectoryKeyBlockBytes[0x20];
|
||||||
|
|||||||
Reference in New Issue
Block a user