mirror of
https://github.com/claunia/Claunia.RsrcFork.git
synced 2025-12-16 19:24:46 +00:00
Added XML documentation.
This commit is contained in:
@@ -27,8 +27,16 @@ using System;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
namespace Claunia.RsrcFork
|
namespace Claunia.RsrcFork
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Contains convertes between .NET and Pascal strings. Only ASCII supported right now.
|
||||||
|
/// </summary>
|
||||||
public static class PascalString
|
public static class PascalString
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Converts an ASCII Pascal string to a .NET string.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The .NET string.</returns>
|
||||||
|
/// <param name="PStr">The ASCII Pascal string.</param>
|
||||||
public static string GetString(byte[] PStr)
|
public static string GetString(byte[] PStr)
|
||||||
{
|
{
|
||||||
if(PStr == null || PStr[0] >= PStr.Length)
|
if(PStr == null || PStr[0] >= PStr.Length)
|
||||||
@@ -37,6 +45,11 @@ namespace Claunia.RsrcFork
|
|||||||
return Encoding.ASCII.GetString(PStr, 1, PStr[0]);
|
return Encoding.ASCII.GetString(PStr, 1, PStr[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts a .NET string to an ASCII Pascal string.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The ASCII Pascal string.</returns>
|
||||||
|
/// <param name="str">The .NET string.</param>
|
||||||
public static byte[] GetBytes(string str)
|
public static byte[] GetBytes(string str)
|
||||||
{
|
{
|
||||||
if(str == null)
|
if(str == null)
|
||||||
|
|||||||
@@ -32,6 +32,9 @@ using System.Text;
|
|||||||
|
|
||||||
namespace Claunia.RsrcFork
|
namespace Claunia.RsrcFork
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This class represents a resource type.
|
||||||
|
/// </summary>
|
||||||
public class Resource
|
public class Resource
|
||||||
{
|
{
|
||||||
readonly Dictionary<short, string> resourceNames;
|
readonly Dictionary<short, string> resourceNames;
|
||||||
@@ -47,7 +50,7 @@ namespace Claunia.RsrcFork
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializates the specified resource type
|
/// Initializates the specified resource type.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="stream">Stream where the resources of this reside.</param>
|
/// <param name="stream">Stream where the resources of this reside.</param>
|
||||||
/// <param name="resources">How many resource of this type are.</param>
|
/// <param name="resources">How many resource of this type are.</param>
|
||||||
@@ -116,7 +119,7 @@ namespace Claunia.RsrcFork
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the name of the specified resource id, or null if there is no name
|
/// Gets the name of the specified resource id, or null if there is no name.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>The name.</returns>
|
/// <returns>The name.</returns>
|
||||||
/// <param name="id">Identifier.</param>
|
/// <param name="id">Identifier.</param>
|
||||||
@@ -127,7 +130,7 @@ namespace Claunia.RsrcFork
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the resource contents
|
/// Gets the resource contents.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>The resource.</returns>
|
/// <returns>The resource.</returns>
|
||||||
/// <param name="id">Identifier.</param>
|
/// <param name="id">Identifier.</param>
|
||||||
@@ -152,17 +155,31 @@ namespace Claunia.RsrcFork
|
|||||||
return resource;
|
return resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the length of the resource specified by ID.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The length.</returns>
|
||||||
|
/// <param name="id">Resource identifier.</param>
|
||||||
public long GetLength(short id)
|
public long GetLength(short id)
|
||||||
{
|
{
|
||||||
ResourceData data;
|
ResourceData data;
|
||||||
return !resources.TryGetValue(id, out data) ? 0 : data.length;
|
return !resources.TryGetValue(id, out data) ? 0 : data.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the IDs of all the resources contained by this instance.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The identifiers.</returns>
|
||||||
public short[] GetIds()
|
public short[] GetIds()
|
||||||
{
|
{
|
||||||
return ids.ToArray();
|
return ids.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks if the resource specified by ID is contained by this instance.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns><c>true</c>, if the resource is contained in this instance, <c>false</c> otherwise.</returns>
|
||||||
|
/// <param name="id">Resource identifier.</param>
|
||||||
public bool ContainsId(short id)
|
public bool ContainsId(short id)
|
||||||
{
|
{
|
||||||
return ids.Contains(id);
|
return ids.Contains(id);
|
||||||
|
|||||||
@@ -30,6 +30,9 @@ using System.Linq;
|
|||||||
|
|
||||||
namespace Claunia.RsrcFork
|
namespace Claunia.RsrcFork
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This class represents a resource fork.
|
||||||
|
/// </summary>
|
||||||
public class ResourceFork
|
public class ResourceFork
|
||||||
{
|
{
|
||||||
Stream rsrcStream;
|
Stream rsrcStream;
|
||||||
@@ -40,7 +43,7 @@ namespace Claunia.RsrcFork
|
|||||||
List<uint> osTypes;
|
List<uint> osTypes;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializates a resource fork using a byte array as backend
|
/// Initializates a resource fork using a byte array as backend.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="buffer">Buffer.</param>
|
/// <param name="buffer">Buffer.</param>
|
||||||
public ResourceFork(byte[] buffer)
|
public ResourceFork(byte[] buffer)
|
||||||
@@ -50,7 +53,7 @@ namespace Claunia.RsrcFork
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializates a resource fork using a stream as backed
|
/// Initializates a resource fork using a stream as backed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="stream">Stream.</param>
|
/// <param name="stream">Stream.</param>
|
||||||
public ResourceFork(Stream stream)
|
public ResourceFork(Stream stream)
|
||||||
@@ -65,7 +68,10 @@ namespace Claunia.RsrcFork
|
|||||||
rsrcStream.Close();
|
rsrcStream.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Init()
|
/// <summary>
|
||||||
|
/// Initializes this instance.
|
||||||
|
/// </summary>
|
||||||
|
void Init()
|
||||||
{
|
{
|
||||||
header = new ResourceHeader();
|
header = new ResourceHeader();
|
||||||
byte[] tmp = new byte[4];
|
byte[] tmp = new byte[4];
|
||||||
|
|||||||
@@ -30,28 +30,71 @@ using Claunia.RsrcFork;
|
|||||||
|
|
||||||
namespace Resources
|
namespace Resources
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This class handles the "VERS" resource fork
|
||||||
|
/// </summary>
|
||||||
public class Version
|
public class Version
|
||||||
{
|
{
|
||||||
static uint ostype = 0x76657273;
|
static uint ostype = 0x76657273;
|
||||||
|
|
||||||
#region On-disk structure
|
#region On-disk structure
|
||||||
|
/// <summary>
|
||||||
|
/// Major version.
|
||||||
|
/// </summary>
|
||||||
public byte MajorVersion;
|
public byte MajorVersion;
|
||||||
|
/// <summary>
|
||||||
|
/// Minor version.
|
||||||
|
/// </summary>
|
||||||
public byte MinorVersion;
|
public byte MinorVersion;
|
||||||
|
/// <summary>
|
||||||
|
/// Development stage.
|
||||||
|
/// </summary>
|
||||||
public DevelopmentStage DevStage;
|
public DevelopmentStage DevStage;
|
||||||
|
/// <summary>
|
||||||
|
/// Pre-release version.
|
||||||
|
/// </summary>
|
||||||
public byte PreReleaseVersion;
|
public byte PreReleaseVersion;
|
||||||
|
/// <summary>
|
||||||
|
/// Region code.
|
||||||
|
/// </summary>
|
||||||
public ushort RegionCode;
|
public ushort RegionCode;
|
||||||
|
/// <summary>
|
||||||
|
/// Version string.
|
||||||
|
/// </summary>
|
||||||
public string VersionString;
|
public string VersionString;
|
||||||
|
/// <summary>
|
||||||
|
/// Version message.
|
||||||
|
/// </summary>
|
||||||
public string VersionMessage;
|
public string VersionMessage;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Known development stages
|
||||||
|
/// </summary>
|
||||||
public enum DevelopmentStage : byte
|
public enum DevelopmentStage : byte
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Pre-alpha.
|
||||||
|
/// </summary>
|
||||||
PreAlpha = 0x20,
|
PreAlpha = 0x20,
|
||||||
|
/// <summary>
|
||||||
|
/// Alpha.
|
||||||
|
/// </summary>
|
||||||
Alpha = 0x40,
|
Alpha = 0x40,
|
||||||
|
/// <summary>
|
||||||
|
/// Beta.
|
||||||
|
/// </summary>
|
||||||
Beta = 0x60,
|
Beta = 0x60,
|
||||||
|
/// <summary>
|
||||||
|
/// Final release.
|
||||||
|
/// </summary>
|
||||||
Final = 0x80
|
Final = 0x80
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="T:Resources.Version"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="resource">Byte array containing the "VERS" resource.</param>
|
||||||
public Version(byte[] resource)
|
public Version(byte[] resource)
|
||||||
{
|
{
|
||||||
byte[] tmpShort, tmpStr, tmpMsg;
|
byte[] tmpShort, tmpStr, tmpMsg;
|
||||||
@@ -72,6 +115,10 @@ namespace Resources
|
|||||||
VersionMessage = PascalString.GetString(tmpMsg);
|
VersionMessage = PascalString.GetString(tmpMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a byte array with the "VERS" resource contained by this instance.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The "VERS" resource.</returns>
|
||||||
public byte[] GetBytes()
|
public byte[] GetBytes()
|
||||||
{
|
{
|
||||||
byte[] tmpShort, tmpStr, tmpMsg;
|
byte[] tmpShort, tmpStr, tmpMsg;
|
||||||
@@ -92,6 +139,10 @@ namespace Resources
|
|||||||
return vers;
|
return vers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the OSTYPE of this resource.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The OSTYPE.</value>
|
||||||
public static uint OSType {
|
public static uint OSType {
|
||||||
get {
|
get {
|
||||||
return ostype;
|
return ostype;
|
||||||
|
|||||||
@@ -30,8 +30,16 @@ using System.Linq;
|
|||||||
|
|
||||||
namespace Claunia.RsrcFork
|
namespace Claunia.RsrcFork
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This class contains static methods for OSTYPE handling.
|
||||||
|
/// </summary>
|
||||||
public static class Types
|
public static class Types
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a descriptive name of a resource from its OSTYPE.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The name corresponding to the specified OSTYPE.</returns>
|
||||||
|
/// <param name="OSType">The OSTYPE.</param>
|
||||||
public static string GetName(uint OSType)
|
public static string GetName(uint OSType)
|
||||||
{
|
{
|
||||||
switch(OSType) {
|
switch(OSType) {
|
||||||
@@ -680,6 +688,11 @@ namespace Claunia.RsrcFork
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a descriptive name of a resource from its OSTYPE.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The name corresponding to the specified OSTYPE.</returns>
|
||||||
|
/// <param name="OSType">The OSTYPE.</param>
|
||||||
public static string GetName(string OSType)
|
public static string GetName(string OSType)
|
||||||
{
|
{
|
||||||
if(OSType.Length != 4)
|
if(OSType.Length != 4)
|
||||||
|
|||||||
Reference in New Issue
Block a user