Of course Windows has it's own _read and _write function whcih conflict with our own. Rename to mmap_read and mmap_write.
This commit is contained in:
@@ -150,7 +150,7 @@ const char* SGMMapFile::advance(off_t amount) {
|
|||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t SGMMapFile::_read(void *buf, size_t count) {
|
ssize_t SGMMapFile::mmap_read(void *buf, size_t count) {
|
||||||
const char *ptr = buffer + offset;
|
const char *ptr = buffer + offset;
|
||||||
size_t result = forward(count);
|
size_t result = forward(count);
|
||||||
|
|
||||||
@@ -159,7 +159,7 @@ ssize_t SGMMapFile::_read(void *buf, size_t count) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t SGMMapFile::_write(const void *buf, size_t count) {
|
ssize_t SGMMapFile::mmap_write(const void *buf, size_t count) {
|
||||||
char *ptr = buffer + offset;
|
char *ptr = buffer + offset;
|
||||||
size_t result = forward(count);
|
size_t result = forward(count);
|
||||||
|
|
||||||
@@ -172,7 +172,7 @@ ssize_t SGMMapFile::_write(const void *buf, size_t count) {
|
|||||||
// read a block of data of specified size
|
// read a block of data of specified size
|
||||||
int SGMMapFile::read( char *buf, int length ) {
|
int SGMMapFile::read( char *buf, int length ) {
|
||||||
// read a chunk
|
// read a chunk
|
||||||
ssize_t result = _read(buf, length);
|
ssize_t result = mmap_read(buf, length);
|
||||||
if ( length > 0 && result == 0 ) {
|
if ( length > 0 && result == 0 ) {
|
||||||
if (repeat < 0 || iteration < repeat - 1) {
|
if (repeat < 0 || iteration < repeat - 1) {
|
||||||
iteration++;
|
iteration++;
|
||||||
@@ -183,7 +183,7 @@ int SGMMapFile::read( char *buf, int length ) {
|
|||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
offset = 0; // lseek(0, SEEK_SET)
|
offset = 0; // lseek(0, SEEK_SET)
|
||||||
return _read(buf, length);
|
return mmap_read(buf, length);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
eof_flag = true;
|
eof_flag = true;
|
||||||
@@ -193,7 +193,7 @@ int SGMMapFile::read( char *buf, int length ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int SGMMapFile::read( char *buf, int length, int num ) {
|
int SGMMapFile::read( char *buf, int length, int num ) {
|
||||||
return _read(buf, num*length)/length;
|
return mmap_read(buf, num*length)/length;
|
||||||
}
|
}
|
||||||
|
|
||||||
// read a line of data, length is max size of input buffer
|
// read a line of data, length is max size of input buffer
|
||||||
@@ -201,13 +201,13 @@ int SGMMapFile::readline( char *buf, int length ) {
|
|||||||
int pos = offset; // pos = lseek(0, SEEK_CUR)
|
int pos = offset; // pos = lseek(0, SEEK_CUR)
|
||||||
|
|
||||||
// read a chunk
|
// read a chunk
|
||||||
ssize_t result = _read(buf, length);
|
ssize_t result = mmap_read(buf, length);
|
||||||
if ( length > 0 && result == 0 ) {
|
if ( length > 0 && result == 0 ) {
|
||||||
if ((repeat < 0 || iteration < repeat - 1) && pos != 0) {
|
if ((repeat < 0 || iteration < repeat - 1) && pos != 0) {
|
||||||
iteration++;
|
iteration++;
|
||||||
|
|
||||||
pos = offset = 0; // pos = lseek(0, SEEK_SET)
|
pos = offset = 0; // pos = lseek(0, SEEK_SET)
|
||||||
result = _read(buf, length);
|
result = mmap_read(buf, length);
|
||||||
} else {
|
} else {
|
||||||
eof_flag = true;
|
eof_flag = true;
|
||||||
}
|
}
|
||||||
@@ -235,7 +235,7 @@ std::string SGMMapFile::read_all() {
|
|||||||
|
|
||||||
// write data to a file
|
// write data to a file
|
||||||
int SGMMapFile::write( const char *buf, const int length ) {
|
int SGMMapFile::write( const char *buf, const int length ) {
|
||||||
int result = _write(buf, length);
|
int result = mmap_write(buf, length);
|
||||||
|
|
||||||
if ( result != length ) {
|
if ( result != length ) {
|
||||||
SG_LOG( SG_IO, SG_ALERT, "Error writing data: " << file_name );
|
SG_LOG( SG_IO, SG_ALERT, "Error writing data: " << file_name );
|
||||||
|
|||||||
@@ -70,8 +70,8 @@ class SGMMapFile : public SGIOChannel {
|
|||||||
# define simple_unmmap(a, b, c) munmap((a), (b))
|
# define simple_unmmap(a, b, c) munmap((a), (b))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ssize_t _read(void *buf, size_t count);
|
ssize_t mmap_read(void *buf, size_t count);
|
||||||
ssize_t _write(const void *buf, size_t count);
|
ssize_t mmap_write(const void *buf, size_t count);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user