include/llfio/v2.0/detail/impl/windows/import.hpp
// Utility routine for building an ACCESS_MASK from a handle::mode
Utility routine for building an ACCESS_MASK from a handle::mode
Utility routine for building an ACCESS_MASK from a handle :: mode
inline result<ACCESS_MASK> access_mask_from_handle_mode(native_handle_type &nativeh, handle::mode _mode, handle::flag flags)
{
  ACCESS_MASK access = SYNCHRONIZE;  
  switch(_mode)
  {
  case handle::mode::unchanged:
    return errc::invalid_argument;
  case handle::mode::none:
    break;
  case handle::mode::attr_read:
    access |= FILE_READ_ATTRIBUTES | STANDARD_RIGHTS_READ;
    break;
  case handle::mode::attr_write:
    access |= DELETE | FILE_READ_ATTRIBUTES | STANDARD_RIGHTS_READ | FILE_WRITE_ATTRIBUTES | STANDARD_RIGHTS_WRITE;
    break;
  case handle::mode::read:
    access |= GENERIC_READ;
    nativeh.behaviour |= native_handle_type::disposition::seekable | native_handle_type::disposition::readable;
    break;
  case handle::mode::write:
    access |= DELETE | GENERIC_WRITE | GENERIC_READ;
    nativeh.behaviour |= native_handle_type::disposition::seekable | native_handle_type::disposition::readable | native_handle_type::disposition::writable;
    break;
  case handle::mode::append:
    access |= DELETE | GENERIC_READ | FILE_WRITE_ATTRIBUTES | STANDARD_RIGHTS_WRITE | FILE_APPEND_DATA;
    nativeh.behaviour |= native_handle_type::disposition::writable | native_handle_type::disposition::append_only;
    break;
  }
  if(flags & handle::flag::unlink_on_first_close)
  {
    access |= DELETE;
  }
  return access;
}
inline result < ACCESS_MASK > access_mask_from_handle_mode ( native_handle_type & nativeh , handle :: mode _mode , handle :: flag flags ) { ACCESS_MASK access = SYNCHRONIZE ; switch ( _mode ) { case handle :: mode :: unchanged : return errc :: invalid_argument ; case handle :: mode :: none : break ; case handle :: mode :: attr_read : access |= FILE_READ_ATTRIBUTES | STANDARD_RIGHTS_READ ; break ; case handle :: mode :: attr_write : access |= DELETE | FILE_READ_ATTRIBUTES | STANDARD_RIGHTS_READ | FILE_WRITE_ATTRIBUTES | STANDARD_RIGHTS_WRITE ; break ; case handle :: mode :: read : access |= GENERIC_READ ; nativeh . behaviour |= native_handle_type :: disposition :: seekable | native_handle_type :: disposition :: readable ; break ; case handle :: mode :: write : access |= DELETE | GENERIC_WRITE | GENERIC_READ ; nativeh . behaviour |= native_handle_type :: disposition :: seekable | native_handle_type :: disposition :: readable | native_handle_type :: disposition :: writable ; break ; case handle :: mode :: append : access |= DELETE | GENERIC_READ | FILE_WRITE_ATTRIBUTES | STANDARD_RIGHTS_WRITE | FILE_APPEND_DATA ; nativeh . behaviour |= native_handle_type :: disposition :: writable | native_handle_type :: disposition :: append_only ; break ; } if ( flags & handle :: flag :: unlink_on_first_close ) { access |= DELETE ; } return access ; }
Utility routine for building an ACCESS_MASK from a handle::mode
Utility routine for building an ACCESS_MASK from a handle :: mode
// appears that this is the bare minimum for the call to succeed // Should we allow unlink on close if opening read only? I guess if Windows allows it, so should we.