]> 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 a22b832be46a4f56179544fa96cc2cc0d8de331b..ac514121dfa05fe99afa9aee4e51ba9fe66361c1 100644 (file)
@@ -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.