Skip to content

Commit 065cdef

Browse files
MagicalTuxclaude
andcommitted
fix: remove unused buildDirectoryChunkData function and directoryChunk struct
Removed code that was created during refactoring but never actually used: - Deleted buildDirectoryChunkData function - Deleted directoryChunk struct - Simplified buildDirectoryEntryData to use local variables directly Resolves golangci-lint unused function warning. All tests pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 62a56e4 commit 065cdef

1 file changed

Lines changed: 6 additions & 69 deletions

File tree

writer.go

Lines changed: 6 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -592,64 +592,6 @@ type inodePosition struct {
592592
offset uint32 // offset within that block
593593
}
594594

595-
// directoryChunk represents a chunk of directory entries that share the same inode block
596-
type directoryChunk struct {
597-
entries []*writerInode
598-
startIdx int
599-
firstInodeNum uint32
600-
firstBlockNum int
601-
}
602-
603-
// buildDirectoryChunkData serializes a directory chunk to bytes
604-
func (w *Writer) buildDirectoryChunkData(chunk *directoryChunk, inodePos map[uint32]inodePosition, useRealOffsets bool) ([]byte, error) {
605-
buf := &bytes.Buffer{}
606-
order := binary.LittleEndian
607-
608-
// Write chunk header
609-
if err := writeBinary(buf, order, uint32(len(chunk.entries)-1)); err != nil {
610-
return nil, err
611-
}
612-
613-
// Write start block position (0 for simulation, real value for final)
614-
var startBlock uint32
615-
if useRealOffsets {
616-
// This will be set correctly in Pass 4
617-
startBlock = 0 // Placeholder, will be filled in by caller
618-
}
619-
if err := writeBinary(buf, order, startBlock); err != nil {
620-
return nil, err
621-
}
622-
623-
if err := writeBinary(buf, order, chunk.entries[0].ino); err != nil {
624-
return nil, err
625-
}
626-
627-
// Write entries
628-
for _, entry := range chunk.entries {
629-
offset := uint16(0)
630-
if useRealOffsets {
631-
offset = uint16(inodePos[entry.ino].offset)
632-
}
633-
if err := writeBinary(buf, order, offset); err != nil {
634-
return nil, err
635-
}
636-
if err := writeBinary(buf, order, int16(entry.ino)-int16(chunk.entries[0].ino)); err != nil {
637-
return nil, err
638-
}
639-
if err := writeBinary(buf, order, entry.fileType); err != nil {
640-
return nil, err
641-
}
642-
if err := writeBinary(buf, order, uint16(len(entry.name)-1)); err != nil {
643-
return nil, err
644-
}
645-
if err := writeBinary(buf, order, []byte(entry.name)); err != nil {
646-
return nil, err
647-
}
648-
}
649-
650-
return buf.Bytes(), nil
651-
}
652-
653595
// buildDirectoryEntryData builds directory entry data for an inode
654596
func (w *Writer) buildDirectoryEntryData(inode *writerInode, inodePos map[uint32]inodePosition, blockPositions []uint32) ([]byte, error) {
655597
if inode.fileType != DirType && inode.fileType != XDirType {
@@ -692,24 +634,19 @@ func (w *Writer) buildDirectoryEntryData(inode *writerInode, inodePos map[uint32
692634
chunkEnd++
693635
}
694636

695-
chunk := &directoryChunk{
696-
entries: inode.entries[chunkStart:chunkEnd],
697-
startIdx: chunkStart,
698-
firstInodeNum: inode.entries[chunkStart].ino,
699-
firstBlockNum: firstEntryBlock,
700-
}
637+
chunkEntries := inode.entries[chunkStart:chunkEnd]
701638

702639
// Add directory index entry for XDirType
703640
if inode.fileType == XDirType {
704641
inode.dirIndex = append(inode.dirIndex, DirIndexEntry{
705642
Index: uint32(dirBuf.Len()),
706643
Start: 0, // Will be set in computeDirectoryTableOffsets
707-
Name: chunk.entries[0].name,
644+
Name: chunkEntries[0].name,
708645
})
709646
}
710647

711648
// Write chunk header
712-
if err := writeBinary(dirBuf, order, uint32(len(chunk.entries)-1)); err != nil {
649+
if err := writeBinary(dirBuf, order, uint32(len(chunkEntries)-1)); err != nil {
713650
return nil, err
714651
}
715652

@@ -722,16 +659,16 @@ func (w *Writer) buildDirectoryEntryData(inode *writerInode, inodePos map[uint32
722659
return nil, err
723660
}
724661

725-
if err := writeBinary(dirBuf, order, chunk.entries[0].ino); err != nil {
662+
if err := writeBinary(dirBuf, order, chunkEntries[0].ino); err != nil {
726663
return nil, err
727664
}
728665

729666
// Write entries
730-
for _, entry := range chunk.entries {
667+
for _, entry := range chunkEntries {
731668
if err := writeBinary(dirBuf, order, uint16(inodePos[entry.ino].offset)); err != nil {
732669
return nil, err
733670
}
734-
if err := writeBinary(dirBuf, order, int16(entry.ino)-int16(chunk.entries[0].ino)); err != nil {
671+
if err := writeBinary(dirBuf, order, int16(entry.ino)-int16(chunkEntries[0].ino)); err != nil {
735672
return nil, err
736673
}
737674
if err := writeBinary(dirBuf, order, entry.fileType); err != nil {

0 commit comments

Comments
 (0)