MiniQuake2

src/miniquake2/qcommon/filesystem.ml

Provides miniquake2 qcommon filesystem facilities for this project.

Package
miniquake2.qcommon.filesystem
Reachable
Yes

Imports

Declarations

addDirectory

function addDirectory(system, directory)

Add directory.

ParameterTypeDefaultDescription
systemdynamic—system value consumed by this operation.
directorydynamic—directory value consumed by this operation.

View source

addGameDirectory

function addGameDirectory(system, directory)

Add game directory.

ParameterTypeDefaultDescription
systemdynamic—system value consumed by this operation.
directorydynamic—directory value consumed by this operation.

View source

addPack

function addPack(system, filename)

Add pack.

ParameterTypeDefaultDescription
systemdynamic—system value consumed by this operation.
filenamedynamic—filename value consumed by this operation.

View source

BASE_DIRECTORY_NAME

const BASE_DIRECTORY_NAME = "baseq2"

Defines the base directory name constant used by the miniquake2 qcommon filesystem module.

View source

canonicalVirtualName

function canonicalVirtualName(name)

Resolve dot segments inside the virtual root. Historical retail PAKs contain names such as models/monsters/tank/../ctank/skin.pcx; they are safe once canonicalized, while attempts to walk above the virtual root remain errors.

ParameterTypeDefaultDescription
namedynamic—Name of the affected item.

View source

CloseHandle

extern function CloseHandle(handle as ptr) from "kernel32.dll" returns bool

Invokes the native CloseHandle entry point used by the miniquake2 qcommon filesystem module.

ParameterTypeDefaultDescription
handleptr—Native or runtime handle used by the operation.

Returns: Native bool result produced by the call.

View source

create

function create(baseDirectory, gameDirectory)

Creates create for the miniquake2 qcommon filesystem module.

ParameterTypeDefaultDescription
baseDirectorydynamic—baseDirectory value consumed by this operation.
gameDirectorydynamic—gameDirectory value consumed by this operation.

View source

CreateFileW

extern function CreateFileW(path as wstr, access as int, share as int, security as ptr, creation as int, flags as int, template as ptr) from "kernel32.dll" returns ptr

Invokes the native CreateFileW entry point used by the miniquake2 qcommon filesystem module.

ParameterTypeDefaultDescription
pathwstr—Path of the file or directory used by the operation.
accessint—access value consumed by this operation.
shareint—share value consumed by this operation.
securityptr—security value consumed by this operation.
creationint—creation value consumed by this operation.
flagsint—Bit flags controlling the operation.
templateptr—template value consumed by this operation.

Returns: Native ptr result produced by the call.

View source

fileExists

function fileExists(system, name)

Return the file exists value.

ParameterTypeDefaultDescription
systemdynamic—system value consumed by this operation.
namedynamic—Name of the affected item.

View source

findPackFile

function findPackFile(pack, name)

Find pack file.

ParameterTypeDefaultDescription
packdynamic—pack value consumed by this operation.
namedynamic—Name of the affected item.

View source

GetFileSizeEx

extern function GetFileSizeEx(handle as ptr, size as bytes) from "kernel32.dll" returns bool

Invokes the native GetFileSizeEx entry point used by the miniquake2 qcommon filesystem module.

ParameterTypeDefaultDescription
handleptr—Native or runtime handle used by the operation.
sizebytes—Size in the units required by the operation.

Returns: Native bool result produced by the call.

View source

initialize

function initialize(baseDirectory, gameDirectory)

Performs the initialize operation for the miniquake2 qcommon filesystem module.

ParameterTypeDefaultDescription
baseDirectorydynamic—baseDirectory value consumed by this operation.
gameDirectorydynamic—gameDirectory value consumed by this operation.

View source

loadPack

function loadPack(filename)

Load pack.

ParameterTypeDefaultDescription
filenamedynamic—filename value consumed by this operation.

View source

MAX_FILES_IN_PACK

const MAX_FILES_IN_PACK = 4096

Defines the max files in pack constant used by the miniquake2 qcommon filesystem module.

View source

musicTrackName

function musicTrackName(track)

Return the music track name.

ParameterTypeDefaultDescription
trackdynamic—track value consumed by this operation.

View source

musicTrackPath

function musicTrackPath(system, track)

Prefer loose files so the native Vorbis bridge owns compressed retail data without retaining a multi-megabyte MiniLang byte array for the whole level. The 2023 Steam release stores the original soundtrack below rerelease/baseq2/music while classic source ports commonly use baseq2/music. PAK-contained replacements remain available through readFile.

ParameterTypeDefaultDescription
systemdynamic—system value consumed by this operation.
trackdynamic—track value consumed by this operation.

View source

normalizeVirtualName

function normalizeVirtualName(name)

Normalize virtual name.

ParameterTypeDefaultDescription
namedynamic—Name of the affected item.

View source

PACK_LOOKUP_SIZE

const PACK_LOOKUP_SIZE = 8192

Defines the pack lookup size constant used by the miniquake2 qcommon filesystem module.

View source

packLookupSlot

inline function packLookupSlot(name)

Return the deterministic open-addressing slot for a canonical PAK name.

ParameterTypeDefaultDescription
namedynamic—Name of the affected item.

View source

parsePack

function parsePack(data, filename)

Parse pack.

ParameterTypeDefaultDescription
datadynamic—Input data consumed by the operation.
filenamedynamic—filename value consumed by this operation.

View source

ReadFile

extern function ReadFile(handle as ptr, buffer as bytes, count as int, bytesRead as bytes, overlapped as ptr) from "kernel32.dll" returns bool

Invokes the native ReadFile entry point used by the miniquake2 qcommon filesystem module.

ParameterTypeDefaultDescription
handleptr—Native or runtime handle used by the operation.
bufferbytes—Buffer that receives or supplies the operation data.
countint—Number of items or units to process.
bytesReadbytes—bytesRead value consumed by this operation.
overlappedptr—overlapped value consumed by this operation.

Returns: Native bool result produced by the call.

View source

readFile

function readFile(system, name)

Read file.

ParameterTypeDefaultDescription
systemdynamic—system value consumed by this operation.
namedynamic—Name of the affected item.

View source

readMusicTrack

function readMusicTrack(system, track)

Read music track.

ParameterTypeDefaultDescription
systemdynamic—system value consumed by this operation.
trackdynamic—track value consumed by this operation.

View source

virtualNameValid

function virtualNameValid(name)

Report whether virtual name valid.

ParameterTypeDefaultDescription
namedynamic—Name of the affected item.

View source