Skip to content

feat(core): add public FatAttributes constants (R/H/S/A)#6

Open
evanofficial wants to merge 1 commit into
mainfrom
feat/fat-attribute-constants
Open

feat(core): add public FatAttributes constants (R/H/S/A)#6
evanofficial wants to merge 1 commit into
mainfrom
feat/fat-attribute-constants

Conversation

@evanofficial

@evanofficial evanofficial commented Jun 28, 2026

Copy link
Copy Markdown
Collaborator

Closes #1.

What

Adds a public, named FatAttributes object exposing the FAT directory-entry attribute bits (the byte at entry offset 0x0B), so callers of Fat12Volume.setAttributes and readers of Fat12Entry.attributes no longer hard-code magic numbers like 0x01 / 0x02 / 0x04 / 0x20.

Constant Value
READ_ONLY 0x01
HIDDEN 0x02
SYSTEM 0x04
VOLUME_ID 0x08
DIRECTORY 0x10
ARCHIVE 0x20

READ_ONLY/HIDDEN/SYSTEM/ARCHIVE are the four user-settable bits setAttributes writes; VOLUME_ID/DIRECTORY are exposed read-only for callers inspecting Fat12Entry.attributes.

Changes

  • New FatAttributes.kt with KDoc citing the FAT spec offset.
  • setAttributes KDoc now references the named constants instead of bare hex.
  • FatAttributesTest: asserts the bit values, or-combination (READ_ONLY or HIDDEN == 0x03, user mask == 0x27), and a round-trip through setAttributes -> Fat12Entry.attributes.

Notes

  • Additive only — no change to any write / verify / rollback path.
  • Internal DirRegion.ATTR_* constants left private as the issue requested.

Testing

./gradlew :core:test green.

Summary by CodeRabbit

  • New Features

    • Added named FAT attribute constants for common directory-entry flags, making attribute handling easier and clearer for integrators.
  • Documentation

    • Updated attribute-related guidance to reflect the new named constants and preserved bits.
  • Tests

    • Added coverage to verify constant values, bit combinations, and attribute updates behave as expected.

Expose a public, named FatAttributes object for the FAT directory-entry
attribute bits (the byte at entry offset 0x0B) so callers of
Fat12Volume.setAttributes and readers of Fat12Entry.attributes no longer
have to hard-code magic numbers like 0x01 / 0x02 / 0x04 / 0x20.

The four user-settable bits (READ_ONLY, HIDDEN, SYSTEM, ARCHIVE) plus the
read-only VOLUME_ID / DIRECTORY bits are exposed with KDoc citing the FAT
spec offset. The setAttributes KDoc now references the named constants.

Adds FatAttributesTest covering the bit values, or-combination, and a
round-trip through setAttributes -> Fat12Entry.attributes.

Fixes #1
@coderabbitai

coderabbitai Bot commented Jun 28, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

.coderabbit.yaml has a parsing error

The CodeRabbit configuration file in this repository has a parsing error and default settings were used instead. Please fix the error(s) in the configuration file. You can initialize chat with CodeRabbit to get help with the configuration file.

💥 Parsing errors (1)
Validation error: Too big: expected string to have <=250 characters at "tone_instructions"
⚙️ Configuration instructions
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 45c7f56c-54ad-4eeb-979c-1af8aef3e3d6

📥 Commits

Reviewing files that changed from the base of the PR and between d5f998f and 7340f07.

📒 Files selected for processing (3)
  • core/src/main/kotlin/com/ams/fat12ex/core/Fat12Volume.kt
  • core/src/main/kotlin/com/ams/fat12ex/core/FatAttributes.kt
  • core/src/test/kotlin/com/ams/fat12ex/core/FatAttributesTest.kt

📝 Walkthrough

Walkthrough

A new FatAttributes Kotlin object is added exposing six public named integer constants for FAT directory-entry attribute bits (READ_ONLY, HIDDEN, SYSTEM, VOLUME_ID, DIRECTORY, ARCHIVE). The setAttributes KDoc in Fat12Volume is updated to reference these constants. A new FatAttributesTest class validates constant values, bitwise combinations, and round-trip attribute setting.

FatAttributes constants, docs, and tests

Layer / File(s) Summary
FatAttributes object and setAttributes KDoc
core/src/main/kotlin/com/ams/fat12ex/core/FatAttributes.kt, core/src/main/kotlin/com/ams/fat12ex/core/Fat12Volume.kt
New FatAttributes object defines READ_ONLY, HIDDEN, SYSTEM, VOLUME_ID, DIRECTORY, and ARCHIVE as public const val integers. The setAttributes comment is updated to reference FatAttributes-qualified names and USER_ATTR_MASK/PRESERVE_ATTR_MASK.
Constant and round-trip tests
core/src/test/kotlin/com/ams/fat12ex/core/FatAttributesTest.kt
FatAttributesTest asserts each constant's exact hex value, verifies bitwise OR composites, and performs a round-trip: builds an in-memory FAT12 image, calls setAttributes, reads back Fat12Entry.attributes, and checks set/cleared bits.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Poem

🐇 Six little bits in a row,
READ_ONLY, HIDDEN, all aglow,
No magic hex, just names so clear,
The FAT spec constants now appear.
Hop hop hooray, the tests are green! 🌿

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding public FAT attribute constants in core.
Linked Issues check ✅ Passed The PR adds the requested public FatAttributes object, updates KDoc, and includes unit and round-trip tests matching the issue criteria.
Out of Scope Changes check ✅ Passed The changes stay within the requested scope: constants, documentation, and tests, with no unrelated feature work evident.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/fat-attribute-constants

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add public named FAT file-attribute constants (R/H/S/A)

1 participant