An implementation of the Nitro Archive virtual file system used by the Nintendo DS
Go to file
2024-12-30 16:23:59 -08:00
cli feat(cli-create): Implement naix output 2024-12-30 16:23:59 -08:00
docs docs: Mirror DS cartridge filesystem documentation from gbatek 2024-12-26 19:16:02 -08:00
lib refactor(cli): Standardize usage of FAIL macro in all commands 2024-12-29 15:44:17 -08:00
.clang-format feat: Implement narc_strerror, narc_load 2024-12-27 00:06:09 -08:00
.editorconfig init: Bootstrap project 2024-12-26 18:56:41 -08:00
.gitignore refactor: Restructure lib includes, separate lib and cli build targets 2024-12-27 21:20:50 -08:00
.pre-commit-config.yaml init: Bootstrap project 2024-12-26 18:56:41 -08:00
LICENSE init: Bootstrap project 2024-12-26 18:56:41 -08:00
Makefile feat(lib-files): Port file-extension computation to a library routine 2024-12-29 13:50:50 -08:00
README.md docs: Stash initial API contract target in README 2024-12-26 21:04:36 -08:00

narc

An implementation of the Nitro Archive virtual file system used by the Nintendo DS.

Table of Contents

Install

Usage

API

#include <stddef.h>
#include <stdint.h>

struct narc;

/*
 * Allocate memory for a new NARC.
 */
struct narc *narc_alloc(void);

/*
 * Free allocated NARC memory.
 */
void narc_free(struct narc *narc);

/*
 * Load a NARC from an existing file on disk at the given path.
 */
int narc_load(struct narc *narc, const char *file_path);

/*
 * Write a NARC to a file on disk at the given path.
 */
int narc_write(struct narc *narc, const char *file_path);

/*
 * Add a file image to the end of a NARC. If successful, then `out_file_id` will
 * be set to the file ID of the persisted image.
 */
int narc_add(struct narc *narc, unsigned char file_image[], uint16_t *out_file_id);

/*
 * Read a file image with the given ID from a NARC. If such a file image exists,
 * then `out_file_image` will be set to the in-memory address of the file image
 * within the NARC and `out_file_size` will be set to the byte-size of that
 * image.
 */
int narc_read(struct narc *narc, uint16_t file_id, unsigned char *out_file_image[], size_t *out_file_size);

/*
 * Compute the SHA-1 hash of this NARC.
 *
 * The resulting hash will always be 20 bytes in length.
 */
uint8_t *narc_hash(struct narc *narc);

/*
 * Compute the SHA-1 hash of a file image with the given ID within a NARC. If
 * such a file exists, then `out_file_hash` will be set to the resulting 20-byte
 * hash.
 */
int narc_hash_file(struct narc *narc, uint16_t file_id, uint8_t *out_file_hash[]);

/*
 * Report the number of files contained within a NARC.
 */
uint16_t narc_num_files(struct narc *narc);

/*
 * Print a report on internal information about a NARC. Useful for debugging.
 */
void narc_printf(struct narc *narc);

Acknowledgements

  • Martin Korth's gbatek documentation, which is an excellent read on all matters related to the GameBoy Advance and Nintendo DS. In particular, his section on DS cartridge file systems was instrumental in building this implementation. The relevant documentation has been mirrored here in docs, for convenience and preservation.

Contributing

License

narc is free software licensed under the Apache License, version 2.0. For further details, refer to the included license text.