X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMESHUtils%2FSMESH_File.hxx;h=b4651cc39c0e43a706e47899f9984d2b5146e478;hb=2fcf0d1b8edebabea1afbf3d5395bdf883ad750d;hp=5232fec0f69a54e96610ff55267dc54e72520365;hpb=b0a908c0d20341651771d0249fb10882f54b2aad;p=modules%2Fsmesh.git diff --git a/src/SMESHUtils/SMESH_File.hxx b/src/SMESHUtils/SMESH_File.hxx index 5232fec0f..b4651cc39 100644 --- a/src/SMESHUtils/SMESH_File.hxx +++ b/src/SMESHUtils/SMESH_File.hxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2020 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 @@ -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,10 +86,31 @@ public: bool getInts(std::vector& ids); + // ------------------------ + // Writing 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 + long _size; //!< file size + std::string _error; #ifdef WIN32 HANDLE _file, _mapObj; #else