Mercurial > hg > audiodb
changeset 591:0242e5d1643c
Address portability issues in database creation
Define a getpagesize() macro which returns The Right Thing on WIN32
Use Windows permissions flags in open() with O_CREAT.
author | mas01cr |
---|---|
date | Tue, 11 Aug 2009 21:42:24 +0000 |
parents | 4eedc18634f5 |
children | cfa74bcc1249 |
files | audioDB-internals.h create.cpp |
diffstat | 2 files changed, 12 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/audioDB-internals.h Tue Aug 11 21:42:18 2009 +0000 +++ b/audioDB-internals.h Tue Aug 11 21:42:24 2009 +0000 @@ -4,6 +4,7 @@ #if !defined(WIN32) #include <sys/mman.h> #endif +#include <sys/stat.h> #include <sys/types.h> #include <errno.h> @@ -355,6 +356,10 @@ #define align_up(x,w) (((x) + ((1<<w)-1)) & ~((1<<w)-1)) #define align_down(x,w) ((x) & ~((1<<w)-1)) +#if defined(WIN32) +#define getpagesize() (64*1024) +#endif + #define align_page_up(x) (((x) + (getpagesize()-1)) & ~(getpagesize()-1)) #define align_page_down(x) ((x) & ~(getpagesize()-1))
--- a/create.cpp Tue Aug 11 21:42:18 2009 +0000 +++ b/create.cpp Tue Aug 11 21:42:24 2009 +0000 @@ -46,7 +46,13 @@ datadim = ADB_DEFAULT_DATADIM; } - if ((fd = open(path, O_RDWR|O_CREAT|O_EXCL, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)) < 0) { + if ((fd = open(path, O_RDWR|O_CREAT|O_EXCL, +#if defined(WIN32) + _S_IREAD|_S_IWRITE +#else + S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH +#endif + )) < 0) { goto error; }