Luke Deller : msvcrt: Translate file open access pattern hints.

Alexandre Julliard julliard at winehq.org
Tue Aug 10 16:24:08 CDT 2021


Module: wine
Branch: master
Commit: 1ca67c8ba20886e1a71bb4a2aa94638beaba4534
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=1ca67c8ba20886e1a71bb4a2aa94638beaba4534

Author: Luke Deller <luke at deller.id.au>
Date:   Wed Aug  4 21:29:34 2021 +1000

msvcrt: Translate file open access pattern hints.

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>
Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/msvcrt/file.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c
index 6e955099090..b0eeaf2a351 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,12 @@ static int msvcrt_get_flags(const wchar_t* mode, int *open_flags, int* stream_fl
     case 'w':
       break;
     case 'S':
+      if (!(*open_flags & _O_RANDOM))
+          *open_flags |= _O_SEQUENTIAL;
+      break;
     case 'R':
-      FIXME("ignoring cache optimization flag: %c\n", mode[-1]);
+      if (!(*open_flags & _O_SEQUENTIAL))
+          *open_flags |= _O_RANDOM;
       break;
     default:
       ERR("incorrect mode flag: %c\n", mode[-1]);
@@ -2269,6 +2271,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);




More information about the wine-cvs mailing list