


## posix-binary-base-io.pkg
# Compiled by:
# src/lib/std/src/standard-core.sublib# This implements the UNIX version of the
# OS-specific binary primitive IO package.
#
# The Text IO version is implemented by a trivial
# translation of these operations -- see:
#
# src/lib/std/src/posix/posix-text-base-io.pkgstipulate
package fpg = file_position_guts; # file_position_guts is from src/lib/std/src/bind-position-31.pkg package vec = vector_of_one_byte_unts; # vector_of_one_byte_unts is from src/lib/std/src/vector-of-one-byte-unts.pkg package pf = posix_1003_1b; # posix_1003_1b is from src/lib/std/src/posix-1003.1b/posix-1003-1b.pkg package pio = posix_1003_1b;
herein
package posix_binary_base_io: (weak) Winix_Base_Io { # Winix_Base_Io is from src/lib/std/src/io/winix-base-io.api #
package base_io
=
binary_base_io; # binary_base_io is from src/lib/std/src/io/binary-base-io.pkg File_Descriptor
=
pf::File_Descriptor;
to_fpi = fpg::from_int; # "fpi" == "File Position from Int", presumably.
fun announce s x y
=
{ # print "Posix: "; print (s: String); print "\n";
x y;
};
buffer_size_b = 4096;
make_reader = pio::make_binary_reader;
make_writer = pio::make_binary_writer;
fun open_for_read name
=
make_reader {
fd => announce "openf" pf::openf (name, pf::O_RDONLY, pf::o::flags [] ),
name,
blocking_mode => TRUE
};
standard_mode
=
pf::s::flags
[ # mode 0666
pf::s::irusr, pf::s::iwusr,
pf::s::irgrp, pf::s::iwgrp,
pf::s::iroth, pf::s::iwoth
];
fun create_file (name, mode, flags)
=
announce "createf" pf::createf (name, mode, flags, standard_mode);
fun open_for_write name
=
make_writer {
fd=>create_file (name, pf::O_WRONLY, pf::o::trunc),
name,
blocking_mode=>TRUE,
append_mode=>FALSE,
chunk_size=>buffer_size_b
};
fun open_for_append name
=
make_writer {
fd => create_file (name, pf::O_WRONLY, pf::o::append),
name => name,
blocking_mode => TRUE,
append_mode => TRUE,
chunk_size => buffer_size_b
};
}; # posix_binary_base_io
end;
## COPYRIGHT (c) 1995 AT&T Bell Laboratories.
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2011,
## released under Gnu Public Licence version 3.


