Akihiro Sagawa : winmm: Inherit the seek position when using standard file handle.
Alexandre Julliard
julliard at winehq.org
Thu Apr 4 13:54:16 CDT 2013
Module: wine
Branch: master
Commit: 7a222508679328875b795392f2b90a6f2b313016
URL: http://source.winehq.org/git/wine.git/?a=commit;h=7a222508679328875b795392f2b90a6f2b313016
Author: Akihiro Sagawa <sagawa.aki at gmail.com>
Date: Thu Apr 4 22:28:14 2013 +0900
winmm: Inherit the seek position when using standard file handle.
---
dlls/winmm/mmio.c | 4 ++--
dlls/winmm/tests/mmio.c | 20 ++++++++++++++++++++
2 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/dlls/winmm/mmio.c b/dlls/winmm/mmio.c
index 551ccbf..73cad60 100644
--- a/dlls/winmm/mmio.c
+++ b/dlls/winmm/mmio.c
@@ -670,9 +670,9 @@ static HMMIO MMIO_Open(LPSTR szFileName, MMIOINFO* refmminfo, DWORD dwOpenFlags,
refmminfo->wErrorRet = send_message(wm->ioProc, &wm->info, MMIOM_OPEN,
(LPARAM)szFileName, 0, FALSE);
- /* grab file size, when possible */
+ /* update offsets and grab file size, when possible */
if (wm->info.fccIOProc != FOURCC_MEM && (send_message(wm->ioProc, &wm->info, MMIOM_SEEK, 0, SEEK_CUR, FALSE)) != -1) {
- pos = wm->info.lDiskOffset;
+ pos = wm->info.lBufOffset = wm->info.lDiskOffset;
send_message(wm->ioProc, &wm->info, MMIOM_SEEK, 0, SEEK_END, FALSE);
wm->dwFileSize = wm->info.lDiskOffset;
send_message(wm->ioProc, &wm->info, MMIOM_SEEK, pos, SEEK_SET, FALSE);
diff --git a/dlls/winmm/tests/mmio.c b/dlls/winmm/tests/mmio.c
index d4697db..495b870 100644
--- a/dlls/winmm/tests/mmio.c
+++ b/dlls/winmm/tests/mmio.c
@@ -704,6 +704,8 @@ static void test_mmioSeek(void)
const LONG size = sizeof(RIFF_buf), offset = 16;
char test_file[MAX_PATH];
MMRESULT res;
+ HFILE hfile;
+ OFSTRUCT ofs;
/* test memory file */
memset(&mmio, 0, sizeof(mmio));
@@ -784,6 +786,24 @@ static void test_mmioSeek(void)
mmioClose(hmmio, 0);
}
+ /* test seek position inheritance from standard file handle */
+ hfile = OpenFile(test_file, &ofs, OF_READ);
+ ok(hfile != HFILE_ERROR, "Failed to open the file, err %d\n", GetLastError());
+ if (hfile != HFILE_ERROR) {
+ pos = _llseek(hfile, offset, SEEK_SET);
+ ok(pos != HFILE_ERROR, "Failed to seek, err %d\n", GetLastError());
+ memset(&mmio, 0, sizeof(mmio));
+ mmio.fccIOProc = FOURCC_DOS;
+ mmio.adwInfo[0] = (DWORD)hfile;
+ hmmio = mmioOpen(NULL, &mmio, MMIO_READ | MMIO_DENYWRITE | MMIO_ALLOCBUF);
+ ok(hmmio != NULL, "mmioOpen error %u\n", mmio.wErrorRet);
+ if (hmmio != NULL) {
+ pos = mmioSeek(hmmio, 0, SEEK_CUR);
+ ok(pos == offset, "expected %d, got %d\n", offset, pos);
+ mmioClose(hmmio, 0);
+ }
+ }
+
DeleteFileA(test_file);
}
More information about the wine-cvs
mailing list