-
Notifications
You must be signed in to change notification settings - Fork 66
04. six layer of os file types you need to know
The fast_io library offers six layers of OS file types.
wine_file: This is a host file descriptor wrapper for Wine, which allows running Windows applications on Unix-like operating systems.
nt_file: It serves as a wrapper for Windows NT APIs, providing an interface to handle files using the Windows NT APIs.
win32_file: Despite the name, this wrapper is not limited to 32-bit Windows. It encapsulates the HANDLE for Windows Win32 API.
posix_file: This layer adheres to the POSIX standard API, acting as a wrapper for UNIX file descriptors. Interestingly, even Windows has file descriptors, although they are distinct from Win32 HANDLEs.
c_file: A wrapper for C standard I/O’s FILE*, making it easier to work with files in C programs.
filebuf_file: This layer wraps C++'s std::filebuf, providing file I/O functionality.
It’s important to note that fast_io offers posix_file, c_file, and filebuf_file on all operating systems. However, wine_file, nt_file, and win32_file are specific to Windows. Additionally, wine_file is only available at runtime within a Wine environment.
The native_file type behaves differently depending on the environment:
On Windows, it corresponds to win32_file.
On other environments (including Cygwin and MSYS2), it behaves like posix_file.
Notice that even though win32_file, nt_file, and wine_file is also available on Cygwin and MSYS2, the native_file layer remains consistent with posix_file in those environments.
The iobuf_file serves as a wrapper that adds a buffer layer to the native_file. Specifically, it corresponds to basic_iobuf<native_file>.
Windows
Other operating systems (Linux as an example)
See example: examples/0007.legacy/construct_fstream_from_syscall.cc