ResourceForkReader 1.0.0
dotnet add package ResourceForkReader --version 1.0.0
NuGet\Install-Package ResourceForkReader -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ResourceForkReader" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ResourceForkReader" Version="1.0.0" />
<PackageReference Include="ResourceForkReader" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ResourceForkReader --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: ResourceForkReader, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ResourceForkReader@1.0.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ResourceForkReader&version=1.0.0
#tool nuget:?package=ResourceForkReader&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
ResourceForkReader
ResourceForkReader is a .NET library for reading and parsing classic Mac resource fork files. It provides a simple API to extract resources, inspect headers, and work with resource data in modern .NET applications.
Features
- Read and parse resource fork files (e.g., from classic Mac applications)
- Access resource types, IDs, names, and data
- Support for common resource record types
- Utility methods for working with resource data
- Low-level access to resource fork structure (headers, maps, attributes)
Installation
Install via NuGet:
dotnet add package ResourceForkReader
Or via the NuGet Package Manager:
Install-Package ResourceForkReader
Quick Start Example
using ResourceForkReader;
using System.IO;
// Open a resource fork file
using var stream = File.OpenRead("MyResourceFile.res");
// Parse the resource fork
var resourceFork = new ResourceFork(stream);
// List all resource types and entries
foreach (var (type, entries) in resourceFork.Map.Types)
{
Console.WriteLine($"Type: {type}");
foreach (var entry in entries)
{
Console.WriteLine($" ID: {entry.ID}, Attributes: {entry.Attributes}");
// Read resource data
byte[] data = resourceFork.GetResourceData(entry);
// ... process data ...
}
}
API Overview
ResourceFork
ResourceFork(Stream stream): Parses a resource fork from a seekable, readable stream.Header: Gets theResourceForkHeader(offsets and lengths for data/map sections).Map: Gets theResourceForkMap(resource types, entries, and structure).GetResourceData(ResourceListEntry entry): Returns the resource data as a byte array.GetResourceData(ResourceListEntry entry, Stream output): Writes resource data to a stream.
ResourceForkHeader
DataOffset,MapOffset,DataLength,MapLength: Offsets and lengths for resource data and map sections.
ResourceForkMap
Types:Dictionary<string, List<ResourceListEntry>>mapping 4-char type codes (e.g., "CODE", "STR#") to resource entries.ResourceTypeCount: Number of resource types in the map.
ResourceTypeListItem
Type: 4-character resource type code.ResourceCount: Number of resources of this type.ResourceListOffset: Offset to the list of resources of this type.
ResourceListEntry
ID: Resource ID (ushort).NameOffset: Offset to the resource name (if present).Attributes: Resource attributes (see below).DataOffset: Offset to the resource data.ReservedHandle: Reserved for handle to resource.
ResourceAttribute (enum)
None,Changed,Preload,Protected,Locked,Purgeable,SystemHeap, etc.
Advanced Usage
Reading Resource Data to a Stream
using var output = File.Create("resource.bin");
int length = resourceFork.GetResourceData(entry, output);
Console.WriteLine($"Wrote {length} bytes");
Inspecting Resource Fork Structure
Console.WriteLine($"DataOffset: {header.DataOffset}, MapOffset: {header.MapOffset}");
Console.WriteLine($"Resource Types: {map.ResourceTypeCount}");
Working with String Resources
using ResourceForkReader.Records;
// Read a 'STR ' resource
var strEntries = resourceFork.Map.Types["STR "];
foreach (var entry in strEntries)
{
var stringRecord = new StringRecord(resourceFork.GetResourceData(entry));
Console.WriteLine($"String: {stringRecord.Value}");
}
// Read a 'STR#' (string list) resource
var strListEntries = resourceFork.Map.Types["STR#"];
foreach (var entry in strListEntries)
{
var stringList = new StringListRecord(resourceFork.GetResourceData(entry));
foreach (var str in stringList.Values)
{
Console.WriteLine($" - {str}");
}
}
Resource Fork Structure
- Header: Contains offsets and lengths for the data and map sections.
- Map: Contains a copy of the header, resource type list, and resource name list.
- Types: Each type (e.g., "CODE", "STR#") has a list of entries.
- Entries: Each entry has an ID, attributes, data offset, and optional name.
License
MIT License.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net9.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.