+
+//================================================================================
+/*!
+ * \brief Open for binary writing only.
+ */
+//================================================================================
+
+bool SMESH_File::openForWriting()
+{
+#ifdef WIN32
+
+ _file = CreateFile( _name.c_str(), // name of the write
+ GENERIC_WRITE, // open for writing
+ 0, // do not share
+ NULL, // default security
+ OPEN_ALWAYS, // CREATE NEW or OPEN EXISTING
+ FILE_ATTRIBUTE_NORMAL, // normal file
+ NULL); // no attr. template
+ return ( _file != INVALID_HANDLE_VALUE );
+
+#else
+
+ _file = ::open( _name.c_str(),
+ O_WRONLY | O_CREAT,
+ S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH ); // rw-r--r--
+ return _file >= 0;
+
+#endif
+}
+
+//================================================================================
+/*!
+ * \brief Write binary data
+ */
+//================================================================================
+
+bool SMESH_File::writeRaw(const void* data, size_t size)
+{
+#ifdef WIN32
+
+ DWORD nbWritten = 0;
+ BOOL err = WriteFile( _file, data, size, & nbWritten, NULL);
+
+ return (( err == FALSE ) &&
+ ( nbWritten == (DWORD) size ));
+
+#else
+
+ ssize_t nbWritten = ::write( _file, data, size );
+ return ( nbWritten == (ssize_t) size );
+
+#endif
+}