2017-05-19 20:28:49 +01:00
|
|
|
// /***************************************************************************
|
2016-07-28 18:13:49 +01:00
|
|
|
// The Disc Image Chef
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// Filename : ArrayFill.cs
|
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
|
|
|
//
|
|
|
|
|
// Component : Helpers.
|
|
|
|
|
//
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// Fills an array with a specified value.
|
|
|
|
|
//
|
|
|
|
|
// --[ License ] --------------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// No license specified by creator.
|
|
|
|
|
//
|
|
|
|
|
// Published on https://github.com/mykohsu/Extensions/blob/master/ArrayExtensions.cs
|
|
|
|
|
//
|
|
|
|
|
// Assuming open source.
|
|
|
|
|
//
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2017-12-19 03:50:57 +00:00
|
|
|
// Copyright © 2011-2018 Natalia Portillo
|
2016-07-28 18:13:49 +01:00
|
|
|
// Copyright(C) 2014 mykohsu
|
|
|
|
|
// ****************************************************************************/
|
* FileSystemIDandChk/ArrayFill.cs:
* FileSystemIDandChk/FileSystemIDandChk.csproj:
Added array filling class from mykohsu.
* FileSystemIDandChk/Main.cs:
Print disk type as identified by image plugin
* FileSystemIDandChk/ImagePlugins/ImagePlugin.cs:
Added more disk types
* FileSystemIDandChk/ImagePlugins/TeleDisk.cs:
Added link to Dave's document.
Completely implemented OpenImage() for standard
(non-compressed) teledisk images.
Implemented GetImageSize(), GetSectors(), GetSectorSize(),
ReadSectors(), GetImageVersion(),
GetImageApplicationVersion(), GetImageCreationTime(),
GetImageLastModificationtime(), GetImageName(),
GetDiskType(), data sector decoders.
* FileSystemIDandChk/TODO:
Discovered a filesystem specification present on ECMA-67.
Dunno if CP/M, FAT or a different one, must check.
Teledisk plugin is working, but lacks "advanced compression"
and variable sectors per track support.
2014-06-07 04:54:15 +01:00
|
|
|
|
|
|
|
|
using System;
|
2016-09-21 01:54:09 +01:00
|
|
|
using System.Text;
|
* FileSystemIDandChk/ArrayFill.cs:
* FileSystemIDandChk/FileSystemIDandChk.csproj:
Added array filling class from mykohsu.
* FileSystemIDandChk/Main.cs:
Print disk type as identified by image plugin
* FileSystemIDandChk/ImagePlugins/ImagePlugin.cs:
Added more disk types
* FileSystemIDandChk/ImagePlugins/TeleDisk.cs:
Added link to Dave's document.
Completely implemented OpenImage() for standard
(non-compressed) teledisk images.
Implemented GetImageSize(), GetSectors(), GetSectorSize(),
ReadSectors(), GetImageVersion(),
GetImageApplicationVersion(), GetImageCreationTime(),
GetImageLastModificationtime(), GetImageName(),
GetDiskType(), data sector decoders.
* FileSystemIDandChk/TODO:
Discovered a filesystem specification present on ECMA-67.
Dunno if CP/M, FAT or a different one, must check.
Teledisk plugin is working, but lacks "advanced compression"
and variable sectors per track support.
2014-06-07 04:54:15 +01:00
|
|
|
|
2014-06-15 23:39:34 +01:00
|
|
|
namespace DiscImageChef
|
* FileSystemIDandChk/ArrayFill.cs:
* FileSystemIDandChk/FileSystemIDandChk.csproj:
Added array filling class from mykohsu.
* FileSystemIDandChk/Main.cs:
Print disk type as identified by image plugin
* FileSystemIDandChk/ImagePlugins/ImagePlugin.cs:
Added more disk types
* FileSystemIDandChk/ImagePlugins/TeleDisk.cs:
Added link to Dave's document.
Completely implemented OpenImage() for standard
(non-compressed) teledisk images.
Implemented GetImageSize(), GetSectors(), GetSectorSize(),
ReadSectors(), GetImageVersion(),
GetImageApplicationVersion(), GetImageCreationTime(),
GetImageLastModificationtime(), GetImageName(),
GetDiskType(), data sector decoders.
* FileSystemIDandChk/TODO:
Discovered a filesystem specification present on ECMA-67.
Dunno if CP/M, FAT or a different one, must check.
Teledisk plugin is working, but lacks "advanced compression"
and variable sectors per track support.
2014-06-07 04:54:15 +01:00
|
|
|
{
|
2016-01-13 19:59:44 +00:00
|
|
|
public static partial class ArrayHelpers
|
* FileSystemIDandChk/ArrayFill.cs:
* FileSystemIDandChk/FileSystemIDandChk.csproj:
Added array filling class from mykohsu.
* FileSystemIDandChk/Main.cs:
Print disk type as identified by image plugin
* FileSystemIDandChk/ImagePlugins/ImagePlugin.cs:
Added more disk types
* FileSystemIDandChk/ImagePlugins/TeleDisk.cs:
Added link to Dave's document.
Completely implemented OpenImage() for standard
(non-compressed) teledisk images.
Implemented GetImageSize(), GetSectors(), GetSectorSize(),
ReadSectors(), GetImageVersion(),
GetImageApplicationVersion(), GetImageCreationTime(),
GetImageLastModificationtime(), GetImageName(),
GetDiskType(), data sector decoders.
* FileSystemIDandChk/TODO:
Discovered a filesystem specification present on ECMA-67.
Dunno if CP/M, FAT or a different one, must check.
Teledisk plugin is working, but lacks "advanced compression"
and variable sectors per track support.
2014-06-07 04:54:15 +01:00
|
|
|
{
|
2017-12-23 03:51:42 +00:00
|
|
|
/// <summary>
|
|
|
|
|
/// Fills an array with the specified value
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="destinationArray">Array</param>
|
|
|
|
|
/// <param name="value">Value</param>
|
|
|
|
|
/// <typeparam name="T">Array type</typeparam>
|
* FileSystemIDandChk/ArrayFill.cs:
* FileSystemIDandChk/FileSystemIDandChk.csproj:
Added array filling class from mykohsu.
* FileSystemIDandChk/Main.cs:
Print disk type as identified by image plugin
* FileSystemIDandChk/ImagePlugins/ImagePlugin.cs:
Added more disk types
* FileSystemIDandChk/ImagePlugins/TeleDisk.cs:
Added link to Dave's document.
Completely implemented OpenImage() for standard
(non-compressed) teledisk images.
Implemented GetImageSize(), GetSectors(), GetSectorSize(),
ReadSectors(), GetImageVersion(),
GetImageApplicationVersion(), GetImageCreationTime(),
GetImageLastModificationtime(), GetImageName(),
GetDiskType(), data sector decoders.
* FileSystemIDandChk/TODO:
Discovered a filesystem specification present on ECMA-67.
Dunno if CP/M, FAT or a different one, must check.
Teledisk plugin is working, but lacks "advanced compression"
and variable sectors per track support.
2014-06-07 04:54:15 +01:00
|
|
|
public static void ArrayFill<T>(T[] destinationArray, T value)
|
|
|
|
|
{
|
|
|
|
|
// if called with a single value, wrap the value in an array and call the main function
|
2017-12-21 14:30:38 +00:00
|
|
|
ArrayFill(destinationArray, new[] {value});
|
* FileSystemIDandChk/ArrayFill.cs:
* FileSystemIDandChk/FileSystemIDandChk.csproj:
Added array filling class from mykohsu.
* FileSystemIDandChk/Main.cs:
Print disk type as identified by image plugin
* FileSystemIDandChk/ImagePlugins/ImagePlugin.cs:
Added more disk types
* FileSystemIDandChk/ImagePlugins/TeleDisk.cs:
Added link to Dave's document.
Completely implemented OpenImage() for standard
(non-compressed) teledisk images.
Implemented GetImageSize(), GetSectors(), GetSectorSize(),
ReadSectors(), GetImageVersion(),
GetImageApplicationVersion(), GetImageCreationTime(),
GetImageLastModificationtime(), GetImageName(),
GetDiskType(), data sector decoders.
* FileSystemIDandChk/TODO:
Discovered a filesystem specification present on ECMA-67.
Dunno if CP/M, FAT or a different one, must check.
Teledisk plugin is working, but lacks "advanced compression"
and variable sectors per track support.
2014-06-07 04:54:15 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-23 03:51:42 +00:00
|
|
|
/// <summary>
|
|
|
|
|
/// Fills an array with the contents of the specified array
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="destinationArray">Array</param>
|
|
|
|
|
/// <param name="value">Value</param>
|
|
|
|
|
/// <typeparam name="T">Array type</typeparam>
|
* FileSystemIDandChk/ArrayFill.cs:
* FileSystemIDandChk/FileSystemIDandChk.csproj:
Added array filling class from mykohsu.
* FileSystemIDandChk/Main.cs:
Print disk type as identified by image plugin
* FileSystemIDandChk/ImagePlugins/ImagePlugin.cs:
Added more disk types
* FileSystemIDandChk/ImagePlugins/TeleDisk.cs:
Added link to Dave's document.
Completely implemented OpenImage() for standard
(non-compressed) teledisk images.
Implemented GetImageSize(), GetSectors(), GetSectorSize(),
ReadSectors(), GetImageVersion(),
GetImageApplicationVersion(), GetImageCreationTime(),
GetImageLastModificationtime(), GetImageName(),
GetDiskType(), data sector decoders.
* FileSystemIDandChk/TODO:
Discovered a filesystem specification present on ECMA-67.
Dunno if CP/M, FAT or a different one, must check.
Teledisk plugin is working, but lacks "advanced compression"
and variable sectors per track support.
2014-06-07 04:54:15 +01:00
|
|
|
public static void ArrayFill<T>(T[] destinationArray, T[] value)
|
|
|
|
|
{
|
2017-12-20 23:07:46 +00:00
|
|
|
if(destinationArray == null) throw new ArgumentNullException(nameof(destinationArray));
|
* FileSystemIDandChk/ArrayFill.cs:
* FileSystemIDandChk/FileSystemIDandChk.csproj:
Added array filling class from mykohsu.
* FileSystemIDandChk/Main.cs:
Print disk type as identified by image plugin
* FileSystemIDandChk/ImagePlugins/ImagePlugin.cs:
Added more disk types
* FileSystemIDandChk/ImagePlugins/TeleDisk.cs:
Added link to Dave's document.
Completely implemented OpenImage() for standard
(non-compressed) teledisk images.
Implemented GetImageSize(), GetSectors(), GetSectorSize(),
ReadSectors(), GetImageVersion(),
GetImageApplicationVersion(), GetImageCreationTime(),
GetImageLastModificationtime(), GetImageName(),
GetDiskType(), data sector decoders.
* FileSystemIDandChk/TODO:
Discovered a filesystem specification present on ECMA-67.
Dunno if CP/M, FAT or a different one, must check.
Teledisk plugin is working, but lacks "advanced compression"
and variable sectors per track support.
2014-06-07 04:54:15 +01:00
|
|
|
|
2017-12-20 23:07:46 +00:00
|
|
|
if(value.Length > destinationArray.Length) throw new ArgumentException("Length of value array must not be more than length of destination");
|
* FileSystemIDandChk/ArrayFill.cs:
* FileSystemIDandChk/FileSystemIDandChk.csproj:
Added array filling class from mykohsu.
* FileSystemIDandChk/Main.cs:
Print disk type as identified by image plugin
* FileSystemIDandChk/ImagePlugins/ImagePlugin.cs:
Added more disk types
* FileSystemIDandChk/ImagePlugins/TeleDisk.cs:
Added link to Dave's document.
Completely implemented OpenImage() for standard
(non-compressed) teledisk images.
Implemented GetImageSize(), GetSectors(), GetSectorSize(),
ReadSectors(), GetImageVersion(),
GetImageApplicationVersion(), GetImageCreationTime(),
GetImageLastModificationtime(), GetImageName(),
GetDiskType(), data sector decoders.
* FileSystemIDandChk/TODO:
Discovered a filesystem specification present on ECMA-67.
Dunno if CP/M, FAT or a different one, must check.
Teledisk plugin is working, but lacks "advanced compression"
and variable sectors per track support.
2014-06-07 04:54:15 +01:00
|
|
|
|
|
|
|
|
// set the initial array value
|
|
|
|
|
Array.Copy(value, destinationArray, value.Length);
|
|
|
|
|
|
|
|
|
|
int arrayToFillHalfLength = destinationArray.Length / 2;
|
|
|
|
|
int copyLength;
|
|
|
|
|
|
2017-12-20 23:07:46 +00:00
|
|
|
for(copyLength = value.Length; copyLength < arrayToFillHalfLength; copyLength <<= 1) Array.Copy(destinationArray, 0, destinationArray, copyLength, copyLength);
|
* FileSystemIDandChk/ArrayFill.cs:
* FileSystemIDandChk/FileSystemIDandChk.csproj:
Added array filling class from mykohsu.
* FileSystemIDandChk/Main.cs:
Print disk type as identified by image plugin
* FileSystemIDandChk/ImagePlugins/ImagePlugin.cs:
Added more disk types
* FileSystemIDandChk/ImagePlugins/TeleDisk.cs:
Added link to Dave's document.
Completely implemented OpenImage() for standard
(non-compressed) teledisk images.
Implemented GetImageSize(), GetSectors(), GetSectorSize(),
ReadSectors(), GetImageVersion(),
GetImageApplicationVersion(), GetImageCreationTime(),
GetImageLastModificationtime(), GetImageName(),
GetDiskType(), data sector decoders.
* FileSystemIDandChk/TODO:
Discovered a filesystem specification present on ECMA-67.
Dunno if CP/M, FAT or a different one, must check.
Teledisk plugin is working, but lacks "advanced compression"
and variable sectors per track support.
2014-06-07 04:54:15 +01:00
|
|
|
|
|
|
|
|
Array.Copy(destinationArray, 0, destinationArray, copyLength, destinationArray.Length - copyLength);
|
|
|
|
|
}
|
2016-09-21 01:54:09 +01:00
|
|
|
|
2017-12-23 03:51:42 +00:00
|
|
|
/// <summary>
|
|
|
|
|
/// Converts a byte array to its hexadecimal representation
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="array">Byte array</param>
|
|
|
|
|
/// <param name="upper"><c>true</c> to use uppercase</param>
|
|
|
|
|
/// <returns></returns>
|
2017-12-22 16:35:31 +00:00
|
|
|
public static string ByteArrayToHex(byte[] array, bool upper = false)
|
2016-09-21 01:54:09 +01:00
|
|
|
{
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
2017-12-19 20:33:03 +00:00
|
|
|
for(long i = 0; i < array.LongLength; i++) sb.AppendFormat("{0:x2}", array[i]);
|
2016-09-21 01:54:09 +01:00
|
|
|
|
|
|
|
|
return upper ? sb.ToString().ToUpper() : sb.ToString();
|
|
|
|
|
}
|
* FileSystemIDandChk/ArrayFill.cs:
* FileSystemIDandChk/FileSystemIDandChk.csproj:
Added array filling class from mykohsu.
* FileSystemIDandChk/Main.cs:
Print disk type as identified by image plugin
* FileSystemIDandChk/ImagePlugins/ImagePlugin.cs:
Added more disk types
* FileSystemIDandChk/ImagePlugins/TeleDisk.cs:
Added link to Dave's document.
Completely implemented OpenImage() for standard
(non-compressed) teledisk images.
Implemented GetImageSize(), GetSectors(), GetSectorSize(),
ReadSectors(), GetImageVersion(),
GetImageApplicationVersion(), GetImageCreationTime(),
GetImageLastModificationtime(), GetImageName(),
GetDiskType(), data sector decoders.
* FileSystemIDandChk/TODO:
Discovered a filesystem specification present on ECMA-67.
Dunno if CP/M, FAT or a different one, must check.
Teledisk plugin is working, but lacks "advanced compression"
and variable sectors per track support.
2014-06-07 04:54:15 +01:00
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
}
|