hare

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

open.ha (408B)


      1 // SPDX-License-Identifier: MPL-2.0
      2 // (c) Hare authors <https://harelang.org>
      3 
      4 use errors;
      5 use fs;
      6 use io;
      7 use os;
      8 
      9 // Returns a stream connected to the TTY of the current process. The caller must
     10 // close it using [[io::close]].
     11 export fn open() (io::file | error) = {
     12 	match (os::open("/dev/tty", fs::flag::RDWR)) {
     13 	case let f: io::file =>
     14 		return f;
     15 	case fs::error =>
     16 		return errors::noentry;
     17 	};
     18 };