summaryrefslogtreecommitdiff
path: root/internal/file/file.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-03-14 23:51:11 +0200
committerPaul Buetow <paul@buetow.org>2025-03-14 23:51:11 +0200
commitb3bbc7ae0ea6747686626d26d0e5484ed06f49fe (patch)
tree822c47f84326f9920e503ca040338b249ccceb0f /internal/file/file.go
parent5cac6a84181a6121e27c5c763a3e34254180fa4b (diff)
unexport types
Diffstat (limited to 'internal/file/file.go')
-rw-r--r--internal/file/file.go39
1 files changed, 20 insertions, 19 deletions
diff --git a/internal/file/file.go b/internal/file/file.go
index a9de8d3..31c119e 100644
--- a/internal/file/file.go
+++ b/internal/file/file.go
@@ -13,27 +13,27 @@ type File interface {
Name() string
}
-type FdFile struct {
+type fdFile struct {
fd int32
name string
}
-func NewFd(fd int32, name []byte) FdFile {
- return FdFile{fd, stringValue(name)}
+func NewFd(fd int32, name []byte) fdFile {
+ return fdFile{fd, stringValue(name)}
}
-func NewFdWithPid(fd int32, pid uint32) FdFile {
+func NewFdWithPid(fd int32, pid uint32) fdFile {
if linkName, err := os.Readlink(fmt.Sprintf("/proc/%d/fd/%d", pid, fd)); err == nil {
- return FdFile{fd, linkName}
+ return fdFile{fd, linkName}
}
- return FdFile{fd, "?"}
+ return fdFile{fd, "?"}
}
-func (f FdFile) Name() string {
+func (f fdFile) Name() string {
return f.name
}
-func (f FdFile) String() string {
+func (f fdFile) String() string {
var sb strings.Builder
if len(f.name) == 0 {
@@ -48,19 +48,19 @@ func (f FdFile) String() string {
return sb.String()
}
-type OldnameNewnameFile struct {
+type oldnameNewnameFile struct {
Oldname, Newname string
}
-func NewOldnameNewname(oldname, newname []byte) OldnameNewnameFile {
- return OldnameNewnameFile{stringValue(oldname), stringValue(newname)}
+func NewOldnameNewname(oldname, newname []byte) oldnameNewnameFile {
+ return oldnameNewnameFile{stringValue(oldname), stringValue(newname)}
}
-func (f OldnameNewnameFile) Name() string {
+func (f oldnameNewnameFile) Name() string {
return f.Newname
}
-func (f OldnameNewnameFile) String() string {
+func (f oldnameNewnameFile) String() string {
var sb strings.Builder
sb.WriteString("old:")
@@ -71,19 +71,19 @@ func (f OldnameNewnameFile) String() string {
return sb.String()
}
-type PathnameFile struct {
+type pathnameFile struct {
Pathname string
}
-func NewPathname(pathname []byte) PathnameFile {
- return PathnameFile{stringValue(pathname)}
+func NewPathname(pathname []byte) pathnameFile {
+ return pathnameFile{stringValue(pathname)}
}
-func (f PathnameFile) Name() string {
+func (f pathnameFile) Name() string {
return f.Pathname
}
-func (f PathnameFile) String() string {
+func (f pathnameFile) String() string {
var sb strings.Builder
sb.WriteString("pathname:")
@@ -92,7 +92,8 @@ 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 {
- // TODO: Hopefully, this won't cause a panic when the filename is as long as the array itself
+ // TODO: Hopefully, this won't cause a panic when the filename is as long as the array itself. Unit test this!
return string(byteStr[:bytes.IndexByte(byteStr, 0)])
}