Commit 25d1f10b authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Avoid byte/string conversion in direntry.go.

parent baaeff99
...@@ -34,15 +34,11 @@ func NewDirEntryList(data []byte, off uint64) *DirEntryList { ...@@ -34,15 +34,11 @@ func NewDirEntryList(data []byte, off uint64) *DirEntryList {
} }
} }
func (l *DirEntryList) AddString(name string, inode uint64, mode uint32) bool {
return l.Add([]byte(name), inode, mode)
}
func (l *DirEntryList) AddDirEntry(e DirEntry) bool { func (l *DirEntryList) AddDirEntry(e DirEntry) bool {
return l.Add([]byte(e.Name), uint64(raw.FUSE_UNKNOWN_INO), e.Mode) return l.Add(e.Name, uint64(raw.FUSE_UNKNOWN_INO), e.Mode)
} }
func (l *DirEntryList) Add(name []byte, inode uint64, mode uint32) bool { func (l *DirEntryList) Add(name string, inode uint64, mode uint32) bool {
dirent := raw.Dirent{ dirent := raw.Dirent{
Off: l.offset+1, Off: l.offset+1,
Ino: inode, Ino: inode,
...@@ -64,7 +60,7 @@ func (l *DirEntryList) Add(name []byte, inode uint64, mode uint32) bool { ...@@ -64,7 +60,7 @@ func (l *DirEntryList) Add(name []byte, inode uint64, mode uint32) bool {
if err != nil { if err != nil {
panic("Serialization of Dirent failed") panic("Serialization of Dirent failed")
} }
l.buf.Write(name) l.buf.WriteString(name)
if padding > 0 { if padding > 0 {
l.buf.Write(eightPadding[:padding]) l.buf.Write(eightPadding[:padding])
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment