(* OCaml-Win32
 * win32_file.ml
 * Copyright (c) 2002-2004 by Harry Chomsky
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the Free
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *)

open Win32_core

(********************************************************************)
(* System Services: Files and I/O: SDK Documentation: Storage: Storage Reference: File Management Reference *)

external are_file_apis_ansi : unit -> bool = "are_file_apis_ansi"

external cancel_io : file:handle -> unit = "cancel_io"

external copy_file : from_name:string -> to_name:string -> fail_if_exists:bool -> unit = "copy_file"

external create_file :
    name:string ->
    access:access_mask ->
    share:file_share_option list ->
    security:security_attributes option ->
    creation:file_create_option ->
    attributes:file_attribute list ->
    flags:file_flag list ->
    sqos:sqos_option list ->
    template:handle ->
    handle = "create_file_bytecode" "create_file_native"

external delete_file : name:string -> unit = "delete_file"

external find_files : name:string -> func:(data:find_data -> bool) -> unit = "find_files"

external flush_file_buffers : file:handle -> unit = "flush_file_buffers"

external get_binary_type : name:string -> binary_type list = "get_binary_type"

external get_file_attributes : name:string -> file_attribute list = "get_file_attributes"

external get_file_information_by_handle : file:handle -> by_handle_file_information = "get_file_information_by_handle"

external get_file_size : file:handle -> int64 = "get_file_size"

external get_file_type : file:handle -> file_type = "get_file_type"

external get_full_path_name : name:string -> (string * int) = "get_full_path_name"

external get_short_path_name : name:string -> string = "get_short_path_name"

external get_temp_file_name : path:string -> prefix:string -> unique:int32 -> (string * int32) = "get_temp_file_name"

external get_temp_path : unit -> string = "get_temp_path"

external lock_file : file:handle -> offset:int64 -> length:int64 -> unit = "lock_file"

external move_file : from_name:string -> to_name:string -> unit = "move_file"

external move_file_ex : from_name:string -> to_name:string option -> options:move_file_option list -> unit = "move_file_ex"

external read_file :
    file:handle ->
    buffer:sized_raw ->
    (error_code * int) = "read_file"
external read_file_overlapped :
    file:handle ->
    ptr:pointer ->
    size:int ->
    overlapped:overlapped ->
    (error_code * int) = "read_file_overlapped"

external search_path :
    path:string option ->
    name:string ->
    extension:string option ->
    (string * int) = "search_path"

external set_end_of_file : file:handle -> unit = "set_end_of_file"

external set_file_apis_to_ansi : unit -> unit = "set_file_apis_to_ansi"

external set_file_apis_to_oem : unit -> unit = "set_file_apis_to_oem"

external set_file_attributes : name:string -> attributes:file_attribute list -> unit = "set_file_attributes"

external set_file_pointer : file:handle -> distance:int64 -> seek_method:seek_method -> int64 = "set_file_pointer"

external unlock_file : file:handle -> offset:int64 -> length:int64 -> unit = "unlock_file"

external write_file :
    file:handle ->
    buffer:sized_raw ->
    (error_code * int) = "write_file"
external write_file_overlapped :
    file:handle ->
    ptr:pointer ->
    size:int ->
    overlapped:overlapped ->
    (error_code * int) = "write_file_overlapped"
