feat(core): add public FatAttributes constants (R/H/S/A)#6
Conversation
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
|
Warning
|
| 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.
Closes #1.
What
Adds a public, named
FatAttributesobject exposing the FAT directory-entry attribute bits (the byte at entry offset0x0B), so callers ofFat12Volume.setAttributesand readers ofFat12Entry.attributesno longer hard-code magic numbers like0x01/0x02/0x04/0x20.READ_ONLY0x01HIDDEN0x02SYSTEM0x04VOLUME_ID0x08DIRECTORY0x10ARCHIVE0x20READ_ONLY/HIDDEN/SYSTEM/ARCHIVEare the four user-settable bitssetAttributeswrites;VOLUME_ID/DIRECTORYare exposed read-only for callers inspectingFat12Entry.attributes.Changes
FatAttributes.ktwith KDoc citing the FAT spec offset.setAttributesKDoc 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 throughsetAttributes->Fat12Entry.attributes.Notes
DirRegion.ATTR_*constants left private as the issue requested.Testing
./gradlew :core:testgreen.Summary by CodeRabbit
New Features
Documentation
Tests