From 792640df1f475527c0ef72f8439dfba9e1e3fb15 Mon Sep 17 00:00:00 2001 From: jason Date: Tue, 30 Jul 2024 09:41:49 -0400 Subject: [PATCH] remove File_Impl_Kind from file_linux --- core/os/os2/file_linux.odin | 16 +++++----------- core/os/os2/pipe_linux.odin | 5 ----- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/core/os/os2/file_linux.odin b/core/os/os2/file_linux.odin index 94477d87e..9f1559fdd 100644 --- a/core/os/os2/file_linux.odin +++ b/core/os/os2/file_linux.odin @@ -6,16 +6,10 @@ import "core:time" import "base:runtime" import "core:sys/linux" -File_Impl_Kind :: enum u8 { - File, - Pipe, -} - File_Impl :: struct { file: File, name: string, fd: linux.Fd, - kind: File_Impl_Kind, allocator: runtime.Allocator, } @@ -213,18 +207,18 @@ _write_at :: proc(f: ^File_Impl, p: []byte, offset: i64) -> (i64, Error) { } _file_size :: proc(f: ^File_Impl) -> (n: i64, err: Error) { - if f.kind == .Pipe { - return 0, .No_Size - } // TODO: Identify 0-sized "pseudo" files and return No_Size. This would // eliminate the need for the _read_entire_pseudo_file procs. - s: linux.Stat = --- errno := linux.fstat(f.fd, &s) if errno != .NONE { return -1, _get_platform_error(errno) } - return i64(s.size), nil + + if s.mode & linux.S_IFMT == linux.S_IFREG { + return i64(s.size), nil + } + return 0, .No_Size } _sync :: proc(f: ^File) -> Error { diff --git a/core/os/os2/pipe_linux.odin b/core/os/os2/pipe_linux.odin index 20c9e37f0..42315cf4e 100644 --- a/core/os/os2/pipe_linux.odin +++ b/core/os/os2/pipe_linux.odin @@ -13,10 +13,5 @@ _pipe :: proc() -> (r, w: ^File, err: Error) { r = _new_file(uintptr(fds[0])) or_return w = _new_file(uintptr(fds[1])) or_return - r_impl := (^File_Impl)(r.impl) - r_impl.kind = .Pipe - w_impl := (^File_Impl)(w.impl) - w_impl.kind = .Pipe - return }