*/
struct GNUNET_DISK_MapHandle
{
+ /**
+ * Address where the map is in memory.
+ */
+ void *addr;
+
#ifdef MINGW
/**
* Underlying OS handle.
*/
HANDLE h;
#else
- /**
- * Address where the map is in memory.
- */
- void *addr;
-
/**
* Number of bytes mapped.
*/
#ifdef MINGW
DWORD mapAccess, protect;
- void *ret;
if ((access & GNUNET_DISK_MAP_TYPE_READ) &&
(access & GNUNET_DISK_MAP_TYPE_WRITE))
return NULL;
}
- ret = MapViewOfFile ((*m)->h, mapAccess, 0, 0, len);
- if (!ret)
+ (*m)->addr = MapViewOfFile ((*m)->h, mapAccess, 0, 0, len);
+ if (!(*m)->addr)
{
SetErrnoFromWinError (GetLastError ());
CloseHandle ((*m)->h);
GNUNET_free (*m);
}
- return ret;
+ return (*m)->addr;
#else
int prot;
}
#ifdef MINGW
- ret = UnmapViewOfFile (h->h) ? GNUNET_OK : GNUNET_SYSERR;
+ ret = UnmapViewOfFile (h->addr) ? GNUNET_OK : GNUNET_SYSERR;
if (ret != GNUNET_OK)
SetErrnoFromWinError (GetLastError ());
if (!CloseHandle (h->h) && (ret == GNUNET_OK))
enum GNUNET_DISK_OpenFlags flags,
enum GNUNET_DISK_AccessPermissions perm)
{
- struct GNUNET_DISK_FileHandle *ret;
-
#ifdef MINGW
+ struct GNUNET_DISK_FileHandle *ret;
HANDLE h;
DWORD openMode;
char *name;
return ret;
#else
- int fd;
-
if (mkfifo(fn, translate_unix_perms(perm)) == -1)
{
- if (errno == EEXIST && flags & GNUNET_DISK_OPEN_FAILIFEXISTS)
+ if ( (errno != EEXIST) ||
+ (0 != (flags & GNUNET_DISK_OPEN_FAILIFEXISTS)) )
return NULL;
}
- flags ~= GNUNET_DISK_OPEN_FAILIFEXISTS;
+ flags = flags & (~GNUNET_DISK_OPEN_FAILIFEXISTS);
return GNUNET_DISK_file_open(fn, flags, perm);
#endif
}