hare

The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 2efbf1e82766551b2d185c7122ce6d0ff6dd68f4
parent c61d0ebb36a7e3492da0347568cca1e4af0c2438
Author: Drew DeVault <sir@cmpwn.com>
Date:   Mon, 19 Apr 2021 12:52:03 -0400

os: remove open.ha

Can be merged into os/fs.ha

Diffstat:
Dos/+linux/open.ha | 27---------------------------
Mos/fs.ha | 25+++++++++++++++++++++++++
Mscripts/gen-stdlib | 1-
Mstdlib.mk | 2--
4 files changed, 25 insertions(+), 30 deletions(-)

diff --git a/os/+linux/open.ha b/os/+linux/open.ha @@ -1,27 +0,0 @@ -use fs; -use io; -use path; - -// Opens a file. -// -// If no flags are provided, [fs::flags::RDONLY], [fs::flags::NOCTTY], -// [fs::flags::CLOEXEC] are used when opening the file. If you pass your own -// flags, it is recommended that you add the latter two unless you know that you -// do not want them. -export fn open(path: str, flags: fs::flags...) (*io::stream | fs::error) = - fs::open(cwd, path, flags...); - -// Creates a new file and opens it for writing. -// -// If no flags are provided, [fs::flags::WRONLY], [fs::flags::NOCTTY], -// [fs::flags::CLOEXEC] are used when opening the file. If you pass your own -// flags, it is recommended that you add the latter two unless you know that you -// do not want them. -// -// Only the permission bits of the mode are used. If other bits are set, they -// are discarded. -export fn create( - path: str, - mode: fs::mode, - flags: fs::flags... -) (*io::stream | fs::error) = fs::create(cwd, path, mode, flags...); diff --git a/os/fs.ha b/os/fs.ha @@ -1,4 +1,5 @@ use fs; +use io; use path; // Provides an implementation of [fs::fs] for the host filesystem. @@ -50,3 +51,27 @@ export fn chown(path: str, uid: uint, gid: uint) (void | fs::error) = fs::chown( // ../ sequences, roots the path, and returns a new path. The caller must free // the return value. export fn resolve(path: str) str = fs::resolve(cwd, path); + +// Opens a file. +// +// If no flags are provided, [fs::flags::RDONLY], [fs::flags::NOCTTY], +// [fs::flags::CLOEXEC] are used when opening the file. If you pass your own +// flags, it is recommended that you add the latter two unless you know that you +// do not want them. +export fn open(path: str, flags: fs::flags...) (*io::stream | fs::error) = + fs::open(cwd, path, flags...); + +// Creates a new file and opens it for writing. +// +// If no flags are provided, [fs::flags::WRONLY], [fs::flags::NOCTTY], +// [fs::flags::CLOEXEC] are used when opening the file. If you pass your own +// flags, it is recommended that you add the latter two unless you know that you +// do not want them. +// +// Only the permission bits of the mode are used. If other bits are set, they +// are discarded. +export fn create( + path: str, + mode: fs::mode, + flags: fs::flags... +) (*io::stream | fs::error) = fs::create(cwd, path, mode, flags...); diff --git a/scripts/gen-stdlib b/scripts/gen-stdlib @@ -507,7 +507,6 @@ os() { '$(PLATFORM)/exit.ha' \ '$(PLATFORM)/dirfdfs.ha' \ '$(PLATFORM)/fdstream.ha' \ - '$(PLATFORM)/open.ha' \ '$(PLATFORM)/stdfd.ha' \ '$(PLATFORM)/fs.ha' \ stdfd.ha \ diff --git a/stdlib.mk b/stdlib.mk @@ -675,7 +675,6 @@ stdlib_os_srcs= \ $(STDLIB)/os/$(PLATFORM)/exit.ha \ $(STDLIB)/os/$(PLATFORM)/dirfdfs.ha \ $(STDLIB)/os/$(PLATFORM)/fdstream.ha \ - $(STDLIB)/os/$(PLATFORM)/open.ha \ $(STDLIB)/os/$(PLATFORM)/stdfd.ha \ $(STDLIB)/os/$(PLATFORM)/fs.ha \ $(STDLIB)/os/stdfd.ha \ @@ -1558,7 +1557,6 @@ testlib_os_srcs= \ $(STDLIB)/os/$(PLATFORM)/exit.ha \ $(STDLIB)/os/$(PLATFORM)/dirfdfs.ha \ $(STDLIB)/os/$(PLATFORM)/fdstream.ha \ - $(STDLIB)/os/$(PLATFORM)/open.ha \ $(STDLIB)/os/$(PLATFORM)/stdfd.ha \ $(STDLIB)/os/$(PLATFORM)/fs.ha \ $(STDLIB)/os/stdfd.ha \