Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/vowpal_wabbit.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'vowpalwabbit/io_buf.h')
-rw-r--r--vowpalwabbit/io_buf.h29
1 files changed, 12 insertions, 17 deletions
diff --git a/vowpalwabbit/io_buf.h b/vowpalwabbit/io_buf.h
index e8b8157c..8b62ca76 100644
--- a/vowpalwabbit/io_buf.h
+++ b/vowpalwabbit/io_buf.h
@@ -120,13 +120,11 @@ class io_buf {
void set(char *p){space.end = p;}
virtual ssize_t read_file(int f, void* buf, size_t nbytes){
-#ifdef _WIN32
- return _read(f, buf, (unsigned int)nbytes);
-#else
- return read(f, buf, (unsigned int)nbytes);
-#endif
+ return read_file_or_socket(f, buf, nbytes);
}
+ static ssize_t read_file_or_socket(int f, void* buf, size_t nbytes);
+
size_t fill(int f) {
if (space.end_array - endloaded == 0)
{
@@ -144,15 +142,12 @@ class io_buf {
return 0;
}
- virtual ssize_t write_file(int f, const void* buf, size_t nbytes)
- {
-#ifdef _WIN32
- return _write(f, buf, (unsigned int)nbytes);
-#else
- return write(f, buf, (unsigned int)nbytes);
-#endif
+ virtual ssize_t write_file(int f, const void* buf, size_t nbytes) {
+ return write_file_or_socket(f, buf, nbytes);
}
+ static ssize_t write_file_or_socket(int f, const void* buf, size_t nbytes);
+
virtual void flush() {
if (write_file(files[0], space.begin, space.size()) != (int) space.size())
std::cerr << "error, failed to write example\n";
@@ -160,19 +155,19 @@ class io_buf {
virtual bool close_file(){
if(files.size()>0){
-#ifdef _WIN32
- _close(files.pop());
-#else
- close(files.pop());
-#endif
+ close_file_or_socket(files.pop());
return true;
}
return false;
}
+ static void close_file_or_socket(int f);
+
void close_files(){
while(close_file());
}
+
+ static bool is_socket(int f);
};
void buf_write(io_buf &o, char* &pointer, size_t n);