From 87c31eb85c48d42e203cdcaf557c2e94c59d4e7d Mon Sep 17 00:00:00 2001 From: Eliot Horowitz Date: Wed, 11 Jul 2012 18:20:13 -0400 Subject: SERVER-6414 - windows compile --- db/extsort.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/db/extsort.cpp b/db/extsort.cpp index 0838b7ffb4e..7786b8b821e 100644 --- a/db/extsort.cpp +++ b/db/extsort.cpp @@ -217,7 +217,11 @@ namespace mongo { // ----------------------------------- BSONObjExternalSorter::FileIterator::FileIterator( string file ) { +#ifdef _WIN32 + _file = _open( file.c_str(), _O_RDWR | _O_CREAT | O_NOATIME, _S_IREAD | _S_IWRITE ); +#else _file = ::open( file.c_str(), O_CREAT | O_RDWR | O_NOATIME , S_IRUSR | S_IWUSR ); +#endif massert( 16392, str::stream() << "FileIterator can't open file: " << file << errnoWithDescription(), @@ -232,8 +236,13 @@ namespace mongo { } BSONObjExternalSorter::FileIterator::~FileIterator() { - if ( _file >= 0 ) - close( _file ); + if ( _file >= 0 ) { +#ifdef _WIN32 + fileClose( _file ); +#else + ::close( _file ); +#endif + } } bool BSONObjExternalSorter::FileIterator::more() { @@ -244,7 +253,11 @@ namespace mongo { bool BSONObjExternalSorter::FileIterator::_read( char* buf, long long count ) { long long total = 0; while ( total < count ) { +#ifdef _WIN32 + long long now = _read( _file, buf, count ); +#else long long now = ::read( _file, buf, count ); +#endif if ( now < 0 ) { log() << "read failed for BSONObjExternalSorter " << errnoWithDescription() << endl; return false; -- cgit v1.2.1