reckfellENGINE

PckPacker

Writes files and removal entries into a PCK with explicit finalization.

On this page
class PckPackerReckfellSharpInherits RefCounted

Sequence: PckStart → AddFile or AddFileFromBuffer → Flush. Check Error at every step. The packer copies bytes; it does not perform project-resource import or export. Use ZipPacker for ZIP archives.

This example creates a pack with one UTF-8 file; the output directory must exist. Writing is not atomic: a partial file is not automatically removed on failure.

C#
using System.Text;
using Reckfell;

public static class PackBuildExample
{
    public static Error WriteTextPack(string outputPath, string text)
    {
        using var pack = new PckPacker();
        Error error = pack.PckStart(outputPath);
        if (error != Error.Ok)
            return error;
        error = pack.AddFileFromBuffer("asset://Extra/message.txt", Encoding.UTF8.GetBytes(text));
        if (error != Error.Ok)
            return error;
        return pack.Flush();
    }
}

See the PCK/ZIP guide for mounting, patch order and caching.

Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.

Constructors1

PckPackerConstructor
# PckPacker
C#
public PckPacker();

Creates a packer with no open file. Call PckStart, add files and explicitly check Flush. Use using to dispose the packer.

Methods6

AddFileError
# AddFile
C#
public Error AddFile(string targetPath, string sourcePath, bool encrypt = false);

Reads sourcePath and immediately writes its bytes to the open pack at logical targetPath. Does not import source models, discover dependencies or export a project. Requires successful PckStart; finalize additions with Flush.

Parameters
NameTypeDefault
targetPathstring—
sourcePathstring—
encryptboolfalse
targetPath

Logical path inside the pack. An optional asset:// prefix is stripped when written; this is not the output PCK filename.

sourcePath

Path to an existing readable file through FileAccess. Its current bytes are copied into the pack, not a reference to the file.

encrypt

Encrypt this file payload with the PckStart key. Does not change directory encryption.

Returns Error

Error.Ok on success; otherwise an error code. Check before the next step; failure does not imply automatic deletion of a partial file.

AddFileFromBuffer2 overloads
# AddFileFromBuffer · 1/2
C#
public Error AddFileFromBuffer(string targetPath, byte[] data, bool encrypt = false);

Immediately writes data bytes to the open pack at targetPath. Changing the source array after return does not alter bytes already written. Does not automatically serialize a Variant or Resource. Requires successful PckStart; finalize additions with Flush.

Parameters
NameTypeDefault
targetPathstring—
databyte[]—
encryptboolfalse
targetPath

Logical path inside the pack. An optional asset:// prefix is stripped when written; this is not the output PCK filename.

data

Payload bytes. Choose an encoding for text, for example Encoding.UTF8.GetBytes(text). The span overload requires an explicit encrypt argument.

encrypt

Encrypt this file payload with the PckStart key. Does not change directory encryption.

Returns Error

Error.Ok on success; otherwise an error code. Check before the next step; failure does not imply automatic deletion of a partial file.

# AddFileFromBuffer · 2/2
C#
public Error AddFileFromBuffer(string targetPath, ReadOnlySpan<byte> data, bool encrypt);

Immediately writes data bytes to the open pack at targetPath. Changing the source array after return does not alter bytes already written. Does not automatically serialize a Variant or Resource. Requires successful PckStart; finalize additions with Flush.

Parameters
NameTypeDefault
targetPathstring—
dataReadOnlySpan<byte>—
encryptbool—
targetPath

Logical path inside the pack. An optional asset:// prefix is stripped when written; this is not the output PCK filename.

data

Payload bytes. Choose an encoding for text, for example Encoding.UTF8.GetBytes(text). The span overload requires an explicit encrypt argument.

encrypt

Encrypt this file payload with the PckStart key. Does not change directory encryption.

Returns Error

Error.Ok on success; otherwise an error code. Check before the next step; failure does not imply automatic deletion of a partial file.

AddFileRemovalError
# AddFileRemoval
C#
public Error AddFileRemoval(string targetPath);

Adds a logical-path removal entry to the open PCK. Does not change the filesystem immediately: removal applies when the completed pack is mounted. A removal entry applies even with LoadResourcePack(..., replaceFiles: false). It neither deletes a physical disk file nor releases an already loaded Resource.

Parameters
NameTypeDefault
targetPathstring—
targetPath

Logical path inside the pack. An optional asset:// prefix is stripped when written; this is not the output PCK filename.

Returns Error

Error.Ok on success; otherwise an error code. Check before the next step; failure does not imply automatic deletion of a partial file.

FlushError
# Flush
C#
public Error Flush(bool verbose = false);

Writes the directory of added files and closes the current PCK. Call explicitly and check Error; another pack requires PckStart. Disposing an open packer also finalizes it, but does not return the Flush result to the caller. This is not an atomic-write or power-loss durability guarantee.

Parameters
NameTypeDefault
verboseboolfalse
verbose

When true, log added-file details during finalization. Does not change pack contents.

Returns Error

Error.Ok on success; otherwise an error code. Check before the next step; failure does not imply automatic deletion of a partial file.

PckStartError
# PckStart
C#
public Error PckStart(string pckPath, int alignment = 32, string key = "0000000000000000000000000000000000000000000000000000000000000000", bool encryptDirectory = false);

Opens the output for writing and starts a new PCK. Does not append .pck; an existing file can be overwritten. Finish the current pack before starting another. The key is validated even when encryption is disabled.

Parameters
NameTypeDefault
pckPathstring—
alignmentint32
keystring"0000000000000000000000000000000000000000000000000000000000000000"
encryptDirectoryboolfalse
pckPath

Output file path, such as user://extra.pck, or an absolute path. The parent directory must exist.

alignment

Positive alignment in bytes; defaults to 32. Zero and negative values are rejected.

key

Exactly 64 hexadecimal characters encoding a 32-byte AES-256 key, not a password. The default zero key is not secret. Reading encrypted data requires the matching loader key.

encryptDirectory

Encrypt the pack directory. Does not enable encryption of every file payload; each addition has its own encrypt flag.

Returns Error

Error.Ok on success; otherwise an error code. Check before the next step; failure does not imply automatic deletion of a partial file.

Reckfell Engine documentationBack to top ↑
QUICK LINKSGetting startedEntity hierarchyC# & .NET 10Scenes and prefabs
Reckfell guides and full API K
reckfellENGINE
RECKFELL ACCOUNT

Sign in

Sign in to your Reckfell account.

One account for the entire Reckfell platform.