diff options
Diffstat (limited to 'internal/file')
| -rw-r--r-- | internal/file/file.go | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/internal/file/file.go b/internal/file/file.go index ff8dae2..e8c818f 100644 --- a/internal/file/file.go +++ b/internal/file/file.go @@ -14,6 +14,7 @@ type File interface { String() string Name() string Flags() Flags + FD() int32 } type FdFile struct { @@ -24,15 +25,15 @@ type FdFile struct { } func NewFd(fd int32, name string, flags int32) FdFile { - f := FdFile{ - fd: fd, - name: name, - flags: Flags(flags), - } - if f.flags == -1 { - f.flags = unknownFlag - } - return f + f := FdFile{ + fd: fd, + name: name, + flags: Flags(flags), + } + if f.flags == -1 { + f.flags = unknownFlag + } + return f } func NewFdWithPid(fd int32, pid uint32) (f FdFile) { @@ -99,6 +100,10 @@ func (f FdFile) Flags() Flags { return f.flags } +func (f FdFile) FD() int32 { + return f.fd +} + func (f *FdFile) SetFlags(flags int32) { f.flags = Flags(flags) } @@ -123,6 +128,10 @@ func (f oldnameNewnameFile) Flags() Flags { return unknownFlag } +func (f oldnameNewnameFile) FD() int32 { + return -1 +} + func (f oldnameNewnameFile) String() string { var sb strings.Builder @@ -153,6 +162,10 @@ func (f pathnameFile) Flags() Flags { return unknownFlag } +func (f pathnameFile) FD() int32 { + return -1 +} + func (f pathnameFile) String() string { var sb strings.Builder |
