]> git.tdb.fi Git - libs/core.git/blobdiff - source/file.cpp
Rewrite Buffered to support read-write buffering correctly
[libs/core.git] / source / file.cpp
index 9b1e433662c63e9fddfa8295fd7719789d471522..ac514121dfa05fe99afa9aee4e51ba9fe66361c1 100644 (file)
@@ -10,7 +10,7 @@ Distributed under the LGPL
 #include <unistd.h>
 #endif
 #include <msp/strings/formatter.h>
-#include "error.h"
+#include "except.h"
 #include "file.h"
 
 using namespace std;
@@ -105,7 +105,7 @@ void File::close()
 
        set_events(P_NONE);
 
-       signal_closing.emit();
+       signal_flush_required.emit();
 
 #ifdef WIN32
        CloseHandle(handle);
@@ -134,6 +134,15 @@ void File::set_block(bool b)
 #endif
 }
 
+void File::sync()
+{
+#ifndef WIN32
+       signal_flush_required.emit();
+
+       fsync(handle);
+#endif
+}
+
 /**
 Seeks the file to the given byte offset.
 
@@ -146,6 +155,8 @@ int File::seek(int off, SeekType st)
 {
        check_access(M_NONE);
 
+       signal_flush_required.emit();
+
        int type=sys_seek_type(st);
 #ifdef WIN32
        DWORD ret=SetFilePointer(handle, off, 0, type);
@@ -232,13 +243,6 @@ unsigned File::do_write(const char *buf, unsigned size)
        return ret;
 }
 
-void File::sync()
-{
-#ifndef WIN32
-       fsync(handle);
-#endif
-}
-
 /**
 Reads data from the file.