Crate libxivdat[][src]

Expand description

A Rust library for working with Final Fantasy XIV .DAT files. These files store client-side game config including macros, hotkeys, and ui settings.

Libxivdat provides low-level file i/o via DATFile, a std::fs::File-like interface that automatically manages the header, footer, and content masking of DAT files.

Each DAT file contains unique data structures. Higher-level support for specific file types is implemented on a type-by-type basis as optional features. See the chart below for more information and feature names.

DAT Data Structures

Internally, some DAT file content blocks use a variable-length data structure referred to as a section in this library. A section consists of a single UTF-8 char type tag, u16le size, and a null-terminated UTF-8 string. A single resource (ie, a macro) is then comprised of a repeating pattern of sections. Other DAT files use fixed-size resource blocks, with each resource immediately following the last. These are referred to as “Block DATs” below.

Some DAT files contain unique binary data that does not follow the “standard” DAT format. Others contain UTF-8 plaintext and are not binary files at all. Support for these files is not currently planned.

DAT Support Table

SymbolDescription
Full support
🌀Partial support
No support
FileContainsTypeDATFile Read/WriteHigh Level Module
ACQ.DATRecent /tell historySection🌀 - section
ADDON.DAT?Unique
COMMON.DATCharacter configurationPlaintext
CONTROL0.DATGamepad control configPlaintext
CONTROL1.DATKeyboard/mouse control configPlaintext
FFXIV_CHARA_XX.DATCharacter appearance presetsUnique
GEARSET.DATGearsetsBlock
GS.DATGold Saucer config (Triad decks)Block
HOTBAR.DATHotbar layoutsBlock
ITEMFDR.DAT“Search for item” indexing?Block
ITEMODR.DATItem order in bagsBlock
KEYBIND.DATKeybindsSection🌀 - section
LOGFLTR.DATChat log filters?Block
MACRO.DATCharacter-specific macrosSection✅ - macro
MACROSYS.DATSystem-wide macrosSection✅ - macro
UISAVE.DATUI configBlock

Examples:

Reading a file:

use libxivdat::dat_file::read_content;
let data_vec = read_content(&path_to_dat_file).unwrap();

Writing to an existing file:

DAT files contain metadata in the header that pertains to how data should be written. Because of this, creating a new DAT file and writing contents are separate steps.

use libxivdat::dat_file::write_content;
let data_vec = write_content(&path_to_dat_file, b"This is some data.").unwrap();

Creating a new file:

use libxivdat::dat_file::DATFile;
use libxivdat::dat_type::DATType;
DATFile::create_with_content(&path_to_dat_file, DATType::Macro, b"This is some data.").unwrap();

File-like access:

use libxivdat::dat_file::read_content;
use libxivdat::dat_file::DATFile;
use libxivdat::dat_type::DATType;
use std::io::{Read,Seek,SeekFrom,Write};

let mut dat_file = DATFile::open(&path_to_dat_file).unwrap();

let mut first_256_bytes = [0u8; 256];
dat_file.read(&mut first_256_bytes).unwrap();

Modules

Contains the DATError wrapper error. This error type is used for all functions that do not implement a std::io trait.

Contains a generic, low-level tool set for working with any standard binary DAT files. This provides the convenience functions read_content() and write_content() as well as the std::fs::File-like DATFile interface.

Contains the enum of all supported file types, DATType and functions for accessing default header and mask values specific to each type.

Contains general-purpose traits and functions applicable to all high-level, file-type-specific modules such as xiv_macro.

Contains a generic tool set for working with any section-based binary DAT files. This module contains two equivalent implementations: Section, read_section(), and read_section_content() for working with files on disk and SectionData, as_section(), and as_section_vec() for working with pre-allocated byte arrays.

Contains the high-level toolkit for working with macro files, MACRO.DAT and MACROSYS.DAT. This module contains two equivalent implementations: Macro, read_macro(), and read_macro_content() for working with files on disk and MacroData, as_macro(), and as_macro_vec() for working with pre-allocated byte arrays and `SectionData.