PreviousUpNext

15.4.1163  src/lib/std/src/posix/winix-data-file-io-driver-for-posix–premicrothread.pkg

## winix-data-file-io-driver-for-posix--premicrothread.pkg
#
# Here we implement the posix version of platform-specific
# data ("binary") file I/O support.  
#
# This file gets used in:
#
#     src/lib/std/src/posix/winix-data-file-for-posix--premicrothread.pkg
#
# Compare to:
#
#     src/lib/std/src/posix/winix-text-file-io-driver-for-posix--premicrothread.pkg
#     src/lib/std/src/win32/winix-data-file-io-driver-for-win32--premicrothread.pkg
#     src/lib/std/src/posix/winix-data-file-io-driver-for-posix.pkg

# Compiled by:
#     src/lib/std/src/standard-core.sublib


stipulate
    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  =  posixlib;                                                            # posixlib                                                      is from   src/lib/std/src/psx/posixlib.pkg
    package pio =  posixlib;
herein  

    package  winix_data_file_io_driver_for_posix__premicrothread

    : (weak) Winix_Extended_File_Io_Driver_For_Os__Premicrothread                       # Winix_Extended_File_Io_Driver_For_Os__Premicrothread          is from   src/lib/std/src/io/winix-extended-file-io-driver-for-os--premicrothread.api

    {
        #
        package drv =  winix_base_data_file_io_driver_for_posix__premicrothread;        # winix_base_data_file_io_driver_for_posix__premicrothread      is from   src/lib/std/src/io/winix-base-data-file-io-driver-for-posix--premicrothread.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;
            };

        best_io_quantum = 4096;                                                         # Reading and writing 4KB at a time should be reasonably efficient.

        make_filereader =  pio::make_data_filereader;
        make_filewriter =  pio::make_data_filewriter;

        fun open_for_read  filename
            =
            make_filereader
              {
                file_descriptor =>   announce "openf"   pf::openf (filename, pf::O_RDONLY, pf::o::flags [] ),
                filename,
                ok_to_block => 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  filename
            =
            make_filewriter
              {
                file_descriptor =>  create_file (filename, pf::O_WRONLY, pf::o::trunc),
                filename,
                ok_to_block =>  TRUE,
                append_mode =>  FALSE,
                best_io_quantum
              };

        fun open_for_append  filename
            =
            make_filewriter
              {
                file_descriptor =>  create_file (filename, pf::O_WRONLY, pf::o::append),
                filename,
                ok_to_block     =>  TRUE,
                append_mode     =>  TRUE,
                #
                best_io_quantum
              };

    };                                                                  # package winix_data_file_io_driver_for_posix__premicrothread 
end;



## COPYRIGHT (c) 1995 AT&T Bell Laboratories.
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2015,
## released per terms of SMLNJ-COPYRIGHT.


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext