[PATCH 25/30] Removed #ifdef WIN32 from playbackFileParser #ifdef


Michael Schonberg <mschonberg@...>
 

The windows specific logic for memory mapped files was incorrect and
likely would not work. PAGE_READONLY should be passed to
CreateFileMapping(), not OpenFile(). It is not clear whether this ever
worked on Windows, and it can be added correctly in the future if
required.

Signed-off-by: Mike Schonberg <mschonberg@...>
---
common/c_cpp/src/c/linux/port.h | 1 +
mama/c_cpp/src/c/playback/playbackFileParser.c | 31 +-----------------------
2 files changed, 2 insertions(+), 30 deletions(-)

diff --git a/common/c_cpp/src/c/linux/port.h b/common/c_cpp/src/c/linux/port.h
index 27cf055..4e69c7c 100644
--- a/common/c_cpp/src/c/linux/port.h
+++ b/common/c_cpp/src/c/linux/port.h
@@ -36,6 +36,7 @@ extern "C"
#include <pthread.h>
#include <sys/types.h>
#include <sys/ioctl.h>
+#include <sys/mman.h>
#include <sys/vfs.h>
#include <sys/param.h>
#include <sys/resource.h>
diff --git a/mama/c_cpp/src/c/playback/playbackFileParser.c b/mama/c_cpp/src/c/playback/playbackFileParser.c
index c05b926..16d38cf 100644
--- a/mama/c_cpp/src/c/playback/playbackFileParser.c
+++ b/mama/c_cpp/src/c/playback/playbackFileParser.c
@@ -152,10 +152,7 @@ mamaPlaybackFileParser_openFile (mamaPlaybackFileParser fileParser,
char* fileName)
{
mama_status status = MAMA_STATUS_OK;
-#ifdef WIN32
- OFSTRUCT of;
- HANDLE hMMFile;
-#endif
+
mamaPlaybackFileParserImpl* impl =
(mamaPlaybackFileParserImpl*)fileParser;
if (impl == NULL) return MAMA_STATUS_NULL_ARG;
@@ -166,22 +163,6 @@ mamaPlaybackFileParser_openFile (mamaPlaybackFileParser fileParser,
"openFile: checking for file: %s", fileName);
mamaPlaybackFileParser_setSize (impl,fileName);

-#ifdef WIN32
-
-
-
- if ((impl->myFileDescriptor = (OpenFile (fileName, &of, PAGE_READONLY))) >= 0)
- {
- hMMFile = CreateFileMapping ((void*)impl->myFileDescriptor, NULL, 0x02, 0, 0, NULL);
-
- impl->myFiledata = (char *)MapViewOfFile (hMMFile,
- FILE_MAP_READ,
- 0,
- 0,
- 0);
-
-
-#else
if ((impl->myFileDescriptor = (open (fileName,
/*O_RDWR*/O_RDONLY | O_NONBLOCK,
0))) >= 0)
@@ -191,14 +172,8 @@ mamaPlaybackFileParser_openFile (mamaPlaybackFileParser fileParser,
MAP_SHARED,
impl->myFileDescriptor,
0);
-
-#endif
if (!impl->myFiledata)
{
-#ifdef WIN32
- int err;
- err=GetLastError();
-#endif
mama_log(MAMA_LOG_LEVEL_NORMAL,
"memory mapping failed?\n");
exit(1);
@@ -225,11 +200,7 @@ mamaPlaybackFileParser_closeFile (mamaPlaybackFileParser fileParser)
{
return MAMA_STATUS_NULL_ARG;
}
-#ifdef WIN32
- CloseHandle((void*)impl->myFileDescriptor);
-#else
munmap(impl->myFiledata, impl->myFileSize);
-#endif
return MAMA_STATUS_OK;
}

--
1.7.7.6

Join Openmama-dev@lists.openmama.org to automatically receive all group messages.