76#define UTF16LE_BOM 0xFEFF
77#define UTF16BE_BOM 0xFFFE
78#define BOM_MASK 0xFFFF
79#define UTF8_BOM 0xBFBBEF
83template <
typename Character>
124extern "C" int _open(
char const*
const path,
int const oflag, ...)
134extern "C" int _wopen(
wchar_t const*
const path,
int const oflag, ...)
146template <
typename Character>
197 char const*
const path,
209 wchar_t const*
const path,
337static file_options
decode_options(
int const oflag,
int const shflag,
int const pmode)
throw()
413 if (last_char_position == -1)
459 if ((oflag & text_mode_mask) == 0)
464 if ((fmode & text_mode_mask) == 0)
467 oflag |= fmode & text_mode_mask;
471 _ASSERTE((oflag & text_mode_mask) != 0);
473 switch (oflag & text_mode_mask)
567 if (
count > 0 && write_bom == 1)
588 _ASSERTE(0 &&
"Only UTF-16 little endian & UTF-8 is supported for reads");
635 for (
int total_written = 0; bom_length > total_written; )
637 char const*
const bom_begin =
reinterpret_cast<char const*
>(&bom);
642 int const written =
_write(fh, bom_begin + total_written, bom_length - total_written);
646 total_written += written;
656 int*
const punlock_flag,
658 wchar_t const*
const path,
698 security_attributes.
nLength =
sizeof(security_attributes);
714 options.access &= ~GENERIC_READ;
787 if (text_mode_result != 0)
790 return text_mode_result;
808 options.access &= ~GENERIC_READ;
836 int*
const punlock_flag,
838 char const*
const path,
889 char const*
const path,
901 wchar_t const*
const path,
void __cdecl __acrt_errno_map_os_error(unsigned long)
int __cdecl _alloc_osfhnd(void)
_Check_return_ int __cdecl _chsize_nolock(_In_ int _FileHandle, _In_ __int64 _Size)
int __cdecl __acrt_lowio_set_os_handle(int, intptr_t)
_Check_return_opt_ int __cdecl _close_nolock(_In_ int _FileHandle)
_Check_return_opt_ __int64 __cdecl _lseeki64_nolock(_In_ int _FileHandle, _In_ __int64 _Offset, _In_ int _Origin)
int __cdecl _free_osfhnd(int)
void __cdecl __acrt_lowio_unlock_fh(_In_ int _FileHandle)
#define _VALIDATE_RETURN(expr, errorcode, retexpr)
errno_t __acrt_mbs_to_wcs_cp(char const *const null_terminated_input_string, __crt_win32_buffer< wchar_t, ResizePolicy > &win32_buffer, unsigned int const code_page)
unsigned int __acrt_get_utf8_acp_compatibility_codepage()
#define INVALID_HANDLE_VALUE
#define FILE_ATTRIBUTE_NORMAL
DWORD WINAPI GetFileType(HANDLE hFile)
static char * cvt(double arg, int ndigits, int *decpt, int *sign, char *buf, int eflag)
GLuint GLuint GLsizei count
GLuint GLint GLboolean GLint GLenum access
static int check_bom(const unsigned char **source, size_t *len)
_CRTIMP errno_t __cdecl _get_fmode(_Out_ int *_PMode)
#define _VALIDATE_RETURN_ERRCODE(expr, errorcode)
#define TRUNCATE_EXISTING
#define FILE_FLAG_BACKUP_SEMANTICS
#define FILE_FLAG_RANDOM_ACCESS
#define FILE_FLAG_DELETE_ON_CLOSE
#define FILE_FLAG_SEQUENTIAL_SCAN
#define create_file(name, size)
DWORD const GENERIC_READ_WRITE
#define FILE_ATTRIBUTE_READONLY
#define FILE_SHARE_DELETE
#define FILE_ATTRIBUTE_TEMPORARY
#define UNREFERENCED_PARAMETER(P)
static errno_t truncate_ctrl_z_if_present(int const fh)
static errno_t configure_text_mode(int const fh, file_options const options, int oflag, __crt_lowio_text_mode &text_mode)
errno_t __cdecl _wsopen_dispatch(wchar_t const *const path, int const oflag, int const shflag, int const pmode, int *const pfh, int const secure)
errno_t __cdecl _wsopen_nolock(int *const punlock_flag, int *const pfh, wchar_t const *const path, int const oflag, int const shflag, int const pmode, int const secure)
static errno_t __cdecl common_sopen_dispatch(_In_z_ Character const *const path, int const oflag, int const shflag, int const pmode, int *const pfh, int const secure)
errno_t __cdecl _sopen_nolock(int *const punlock_flag, int *const pfh, char const *const path, int const oflag, int const shflag, int const pmode, int const secure)
errno_t __cdecl _wsopen_s(int *const pfh, wchar_t const *const path, int const oflag, int const shflag, int const pmode)
static DWORD decode_sharing_flags(int const shflag, int const access)
int __cdecl _sopen(char const *const path, int const oflag, int const shflag,...)
int _open(char const *const path, int const oflag,...)
static int __cdecl common_open(_In_z_ Character const *const path, int const oflag, int const pmode)
static DWORD decode_access_flags(int const oflag)
static bool is_text_mode(int const oflag)
int __cdecl _wsopen(wchar_t const *const path, int const oflag, int const shflag,...)
static file_options decode_options(int const oflag, int const shflag, int const pmode)
static DWORD decode_open_create_flags(int const oflag)
errno_t __cdecl _sopen_s(int *const pfh, char const *const path, int const oflag, int const shflag, int const pmode)
errno_t __cdecl _sopen_dispatch(char const *const path, int const oflag, int const shflag, int const pmode, int *const pfh, int const secure)
int _wopen(wchar_t const *const path, int const oflag,...)
_CRTIMP int __cdecl _write(_In_ int _FileHandle, _In_reads_bytes_(_MaxCharCount) const void *_Buf, _In_ unsigned int _MaxCharCount)
FD_TYPE file_type(FDSC **curr, char *fixed)
int __cdecl _read_nolock(int const fh, void *const result_buffer, unsigned const result_buffer_size)
LPVOID lpSecurityDescriptor
DWORD WINAPI GetLastError(void)
#define FILE_TYPE_UNKNOWN
#define ERROR_NEGATIVE_SEEK
void int int ULONGLONG int va_list * ap