diff options
| author | Paul Buetow <paul@buetow.org> | 2025-04-16 23:19:15 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-04-16 23:19:15 +0300 |
| commit | cd289eb0d978297b1e331da202eee09ca4c1290c (patch) | |
| tree | 893466694b6cd7430bb00e353a8c8db55b42b07c /internal/file | |
| parent | ed7668ec893e21b4cf071c98dd5a292105aeec34 (diff) | |
add Equals
Diffstat (limited to 'internal/file')
| -rw-r--r-- | internal/file/file.go | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/internal/file/file.go b/internal/file/file.go index aff9b8b..9edd27b 100644 --- a/internal/file/file.go +++ b/internal/file/file.go @@ -4,6 +4,7 @@ import ( "bufio" "bytes" "fmt" + "ior/internal/types" "os" "strconv" "strings" @@ -25,7 +26,7 @@ type FdFile struct { func NewFd(fd int32, name []byte, flags int32) FdFile { f := FdFile{ fd: fd, - name: StringValue(name), + name: types.StringValue(name), flags: Flags(flags), } if f.flags == -1 { @@ -106,7 +107,7 @@ type oldnameNewnameFile struct { } func NewOldnameNewname(oldname, newname []byte) oldnameNewnameFile { - return oldnameNewnameFile{StringValue(oldname), StringValue(newname)} + return oldnameNewnameFile{types.StringValue(oldname), types.StringValue(newname)} } func (f oldnameNewnameFile) Name() string { @@ -136,7 +137,7 @@ type pathnameFile struct { } func NewPathname(pathname []byte) pathnameFile { - return pathnameFile{StringValue(pathname)} + return pathnameFile{types.StringValue(pathname)} } func (f pathnameFile) Name() string { @@ -158,8 +159,3 @@ func (f pathnameFile) String() string { return sb.String() } - -// As data comes in from arrays, converted to slices, there will be null-bytes at the end.. -func StringValue(byteStr []byte) string { - return string(byteStr[:bytes.IndexByte(byteStr, 0)]) -} |
