X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMESHUtils%2FSMESH_File.hxx;h=cf36b652b6806fac06beaa5a30ab048b823cf66c;hb=674c0d8b9d98776136d216ec8f1bad56acac5bf5;hp=3734e96d6f70cd40b9c18e7918a3799240954a3c;hpb=bd4e115a78b52e3fbc016e5e30bb0e19b2a9e7d6;p=modules%2Fsmesh.git diff --git a/src/SMESHUtils/SMESH_File.hxx b/src/SMESHUtils/SMESH_File.hxx index 3734e96d6..cf36b652b 100644 --- a/src/SMESHUtils/SMESH_File.hxx +++ b/src/SMESHUtils/SMESH_File.hxx @@ -1,9 +1,9 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either -// version 2.1 of the License. +// version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,7 +29,7 @@ #include #include -#ifdef WNT +#ifdef WIN32 #include #else #include @@ -42,24 +42,30 @@ class SMESHUtils_EXPORT SMESH_File { public: - SMESH_File(const std::string& name, bool open=true); + SMESH_File(const std::string& name, bool openForReading=true); ~SMESH_File(); std::string getName() const { return _name; } - bool open(); + const std::string& error() const { return _error; } void close(); bool remove(); - int size() const; + long size(); + + bool exists(); + + bool isDirectory(); // ------------------------ // Access to file contents // ------------------------ + bool open(); // for reading + operator const char*() const { return _pos; } bool operator++() { return ++_pos < _end; } @@ -68,6 +74,8 @@ public: bool eof() const { return _pos >= _end; } + const char* end() const { return _end; } + const char* getPos() const { return _pos; } void setPos(const char* pos); @@ -78,11 +86,32 @@ public: bool getInts(std::vector& ids); + // ------------------------ + // Writting a binary file + // ------------------------ + + bool openForWriting(); // binary writing only + + template + bool write( const T* values, size_t nbTValues ) + { + return writeRaw((const void*) values, nbTValues * sizeof(T)); + } + + template + bool write( const T& value ) + { + return writeRaw((const void*) & value, sizeof(T)); + } + + bool writeRaw(const void* data, size_t size); + private: std::string _name; //!< file name int _size; //!< file size -#ifdef WNT + std::string _error; +#ifdef WIN32 HANDLE _file, _mapObj; #else int _file;