## win32-file-system.pkg
# Hooks to Win32 file system.
package Win32_FileSys
: Win32_File_System
{
package W32G = win32_general
type hndl = W32G::hndl
type word = W32G::word
fun hndlToIOD h = winix__premicrothread::io::IODESC (REF h)
fun IODToHndl (winix__premicrothread::io::IODESC (REF h)) = h
fun rebindIOD (winix__premicrothread::io::IODESC hr, h) = hr := h
fun cf name = W32G::cfun "win32_filesys" name
my findFirstFile: String -> (hndl * Null_Or( String ) )
=
cf "find_first_file"
my findNextFile: hndl -> Null_Or( String )
=
cf "find_next_file"
my findClose: hndl -> Bool
=
cf "find_close"
my setCurrentDirectory: String -> Bool = cf "change_directory"
my getCurrentDirectory' : Void -> String = cf "get_current_directory"
my createDirectory' : String -> Bool = cf "create_directory"
my removeDirectory: String -> Bool = cf "remove_directory"
cc = W32G::getConst "FILE_ATTRIBUTE"
my FILE_ATTRIBUTE_ARCHIVE: word = cc "ARCHIVE"
my FILE_ATTRIBUTE_DIRECTORY: word = cc "DIRECTORY"
my FILE_ATTRIBUTE_HIDDEN: word = cc "HIDDEN"
my FILE_ATTRIBUTE_NORMAL: word = cc "NORMAL"
my FILE_ATTRIBUTE_READONLY: word = cc "READONLY"
my FILE_ATTRIBUTE_SYSTEM: word = cc "SYSTEM"
my FILE_ATTRIBUTE_TEMPORARY: word = cc "TEMPORARY"
/** future win32 use
my FILE_ATTRIBUTE_ATOMIC_WRITE: word = cc "ATOMIC_WRITE"
my FILE_ATTRIBUTE_XACTION_WRITE: word = cc "XACTION_WRITE"
**/
my getFileAttributes: String -> Null_Or( word )
=
cf "get_file_attributes"
my getFileAttributes' : hndl -> Null_Or( word )
=
cf "get_file_attributes_by_handle"
fun isRegularFile h = # Assumes attributes accessible
let my THE a = getFileAttributes' h
in W32G::unt::bitwise_and (FILE_ATTRIBUTE_DIRECTORY, a) = 0wx0
end
my getFullPathName' : String -> String
=
cf "get_full_path_name"
my getFileSize: hndl -> (word * word ) = cf "get_file_size"
my getLowFileSize: hndl -> Null_Or( word ) = cf "get_low_file_size"
my getLowFileSizeByName: String -> Null_Or( word ) = cf "get_low_file_size_by_name"
# year, month, day-o-week, day, hour, minute, second, millisecs
type time_rec = (Int * Int * Int * Int * Int * Int * Int * Int)
fun trToSt (y, mon, dow, d, h, min, s, ms)
:
W32G::system_time
=
{ year=y, month=mon, dayOfWeek=dow, day=d, hour=h,
minute=min, second=s, milliSeconds=ms
}
fun stToTr { year, month, dayOfWeek, day,
hour, minute, second, milliSeconds } : time_rec
=
(year, month, dayOfWeek, day, hour, minute, second, milliSeconds)
my getFileTime: String -> Null_Or( time_rec)
=
cf "get_file_time"
getFileTime' = null_or::map trToSt o getFileTime
my setFileTime: (String * time_rec) -> Bool = cf "set_file_time"
fun setFileTime' (name, sysTime) = setFileTime (name, stToTr sysTime)
my deleteFile: String -> Bool = cf "delete_file"
my moveFile: (String * String) -> Bool = cf "move_file"
my getTempFileName'
:
Void -> Null_Or( String )
=
cf "get_temp_file_name"
};