summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2012-07-11 18:20:13 -0400
committerEliot Horowitz <eliot@10gen.com>2012-07-11 18:23:36 -0400
commit87c31eb85c48d42e203cdcaf557c2e94c59d4e7d (patch)
treed6dbf3ea28d7ed049c3ca9f66d4c5f25a13bf988
parenta31879b251308a14b5414b6a5d3f9dae495b23ea (diff)
downloadmongo-87c31eb85c48d42e203cdcaf557c2e94c59d4e7d.tar.gz
SERVER-6414 - windows compile
-rw-r--r--db/extsort.cpp17
1 files 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;