diff options
| author | Paul Buetow <paul@buetow.org> | 2025-03-11 09:52:30 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-03-11 09:52:30 +0200 |
| commit | f9d8d2d9a107204fddf13b8f60845e817076d1f8 (patch) | |
| tree | b38437d816f589dc18246290c95124fe25962e5e /internal/file.go | |
| parent | a7f6f047de1e0ae56a0ef3a4c74e86f4f8f6eeb7 (diff) | |
refactor and initial tree
Diffstat (limited to 'internal/file.go')
| -rw-r--r-- | internal/file.go | 84 |
1 files changed, 0 insertions, 84 deletions
diff --git a/internal/file.go b/internal/file.go deleted file mode 100644 index fe519ba..0000000 --- a/internal/file.go +++ /dev/null @@ -1,84 +0,0 @@ -package internal - -import ( - "fmt" - "os" - "strconv" - "strings" -) - -type file interface { - String() string - Name() string -} - -type fdFile struct { - fd int32 - name string -} - -func newFdFile(fd int32, name string) fdFile { - return fdFile{fd, name} -} - -func newFdFileWithPid(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, "?"} -} - -func (f fdFile) Name() string { - return f.name -} - -func (f fdFile) String() string { - var sb strings.Builder - - if len(f.name) == 0 { - sb.WriteString("?") - } else { - sb.WriteString(f.name) - sb.WriteString(" (") - sb.WriteString(strconv.FormatInt(int64(f.fd), 10)) - sb.WriteString(")") - } - - return sb.String() -} - -type oldnameNewnameFile struct { - oldname, newname string -} - -func (f oldnameNewnameFile) Name() string { - return f.newname -} - -func (f oldnameNewnameFile) String() string { - var sb strings.Builder - - sb.WriteString("old:") - sb.WriteString(f.oldname) - sb.WriteString(" ->new:") - sb.WriteString(f.newname) - - return sb.String() -} - -type pathnameFile struct { - pathname string -} - -func (f pathnameFile) Name() string { - return f.pathname -} - -func (f pathnameFile) String() string { - var sb strings.Builder - - sb.WriteString("pathname:") - sb.WriteString(f.pathname) - - return sb.String() -} |
