[PATCH v3 2/4] msvcrt: Translate file open access pattern hints

Luke Deller luke at deller.id.au
Tue Aug 3 09:57:23 CDT 2021


Translate access pattern hints supplied to fopen / _open into the
corresponding attributes for the lower level CreateFileW call.

Signed-off-by: Luke Deller <luke at deller.id.au>
---
 dlls/msvcrt/file.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c
index 6e955099090..716d397d246 100644
--- a/dlls/msvcrt/file.c
+++ b/dlls/msvcrt/file.c
@@ -22,8 +22,6 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  *
- * TODO
- * Use the file flag hints O_SEQUENTIAL, O_RANDOM, O_SHORT_LIVED
  */
 
 #include <direct.h>
@@ -1609,8 +1607,10 @@ static int msvcrt_get_flags(const wchar_t* mode, int *open_flags, int* stream_fl
     case 'w':
       break;
     case 'S':
+      *open_flags |= _O_SEQUENTIAL;
+      break;
     case 'R':
-      FIXME("ignoring cache optimization flag: %c\n", mode[-1]);
+      *open_flags |= _O_RANDOM;
       break;
     default:
       ERR("incorrect mode flag: %c\n", mode[-1]);
@@ -2269,6 +2269,13 @@ int CDECL _wsopen_dispatch( const wchar_t* path, int oflags, int shflags, int pm
       sharing |= FILE_SHARE_DELETE;
   }
 
+  if (oflags & _O_RANDOM)
+      attrib |= FILE_FLAG_RANDOM_ACCESS;
+  if (oflags & _O_SEQUENTIAL)
+      attrib |= FILE_FLAG_SEQUENTIAL_SCAN;
+  if (oflags & _O_SHORT_LIVED)
+      attrib |= FILE_ATTRIBUTE_TEMPORARY;
+
   sa.nLength              = sizeof( SECURITY_ATTRIBUTES );
   sa.lpSecurityDescriptor = NULL;
   sa.bInheritHandle       = !(oflags & _O_NOINHERIT);
-- 
2.25.1




More information about the wine-devel mailing list