#line 419 "/home/travis/build/felix-lang/felix/src/packages/filesystem.fdoc"
  
  class Win32FileStat
  {
    //2 things:
    //
    // (1) AFAICT, Windows doesn't define mode_t and uses unsigned int.
    // (2) We still pull in sys/types.h because sys/stat.h uses it (and
    //     it must come first).
    //
    //(source http://msdn.microsoft.com/en-US/library/14h5k7ff(v=vs.80)).
  
    //pod type mode_t = "mode_t" requires Posix_headers::sys_types_h;
  
    pod type mode_t = "int";
    pod type stat_t = "struct __stat64" requires Posix_headers::sys_stat_h;
  
    instance Bits[mode_t] {} // defaults to C operators
    instance Eq[mode_t] { fun == : mode_t * mode_t -> bool = "$1==$2"; }
    open Eq[mode_t];
    open Bits[mode_t];
  
    // file types
    const _S_IFMT  : mode_t; // file type mask
    const _S_IFDIR : mode_t;
    const _S_IFREG : mode_t;
  
    // permissions
    const _S_IWRITE: mode_t; // RWX mask: owner
    const _S_IREAD  : mode_t;
    val access_mask = _S_IREAD \| _S_IWRITE;
  
  
    fun raw_mode: &stat_t -> mode_t = "$1->st_mode";
    fun file_type(m:mode_t)=>m \& _S_IFMT;
    fun file_perm(m:mode_t)=>m \& ~_S_IFMT;
  
    ctor uint: mode_t = "(unsigned int)$1";
  
  
    inherit FileStat_class[Win32, stat_t, mode_t];
  
    instance FileStat_class[Win32, stat_t, mode_t]
    {
      proc stat: string * &stat_t * &int = "*$3=_stat64($1.c_str(),$2);";
      // set access and modification time of a file
      proc utime: string * double * double * &int =
      """
        {
        __utimbuf64 u;
        u.actime=(time_t)$2;
        u.modtime=(time_t)$3;
        *$4 = _utime64($1.c_str(),&u);
        }
      """
  
      requires Win32_headers::sys_utime_h;
  
      gen chmod: string * mode_t -> int = "_chmod($1.c_str(),$2)" requires Win32_headers::io_h;
      gen umask: mode_t -> mode_t = "_umask($1)";
  
      fun file_type (s:&stat_t): file_type_t =>
        let m = file_type$ raw_mode s in
        if m == _S_IFDIR then DIRECTORY
        elif m == _S_IFREG then REGULAR
        else INDETERMINATE
        endif
      ;
  
    } // instance
  }