Loading src/TNL/File.cpp +13 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,14 @@ File :: File() { } File :: ~File() { // destroying a file without closing is a memory leak // (an open file descriptor is left behind, on Linux there is typically // only a limited number of descriptors available to each process) close(); } bool File :: open( const String& fileName, const tnlIOMode mode ) { Loading Loading @@ -60,6 +68,11 @@ bool File :: close() std::cerr << "I was not able to close the file " << fileName << " properly!" << std::endl; return false; } // reset all attributes mode = tnlUndefinedMode; file = NULL; fileOK = false; fileName = ""; readElements = writtenElements = 0; return true; }; Loading src/TNL/File.h +2 −0 Original line number Diff line number Diff line Loading @@ -57,6 +57,8 @@ class File File(); ~File(); bool open( const String& fileName, const tnlIOMode mode ); Loading src/TNL/Object.cpp +4 −19 Original line number Diff line number Diff line Loading @@ -85,10 +85,7 @@ bool Object :: save( const String& fileName ) const std::cerr << "I am not bale to open the file " << fileName << " for writing." << std::endl; return false; } const bool status = this->save( file ); if( ! file. close() ) std::cerr << "An error occurred when I was closing the file " << fileName << "." << std::endl; return status; return this->save( file ); } bool Object :: load( const String& fileName ) Loading @@ -99,10 +96,7 @@ bool Object :: load( const String& fileName ) std::cerr << "I am not bale to open the file " << fileName << " for reading." << std::endl; return false; } const bool status = this->load( file ); if( ! file. close() ) std::cerr << "An error occurred when I was closing the file " << fileName << "." << std::endl; return status; return this->load( file ); } bool Object :: boundLoad( const String& fileName ) Loading @@ -113,14 +107,7 @@ bool Object :: boundLoad( const String& fileName ) std::cerr << "I am not bale to open the file " << fileName << " for reading." << std::endl; return false; } if( ! this->boundLoad( file ) ) return false; if( ! file. close() ) { std::cerr << "An error occurred when I was closing the file " << fileName << "." << std::endl; return false; } return true; return this->boundLoad( file ); } void Object::setDeprecatedReadMode() Loading Loading @@ -155,9 +142,7 @@ bool getObjectType( const String& fileName, String& type ) std::cerr << "I am not able to open the file " << fileName << " for detecting the object inside!" << std::endl; return false; } bool ret_val = getObjectType( binaryFile, type ); binaryFile. close(); return ret_val; return getObjectType( binaryFile, type ); } bool parseObjectType( const String& objectType, Loading Loading
src/TNL/File.cpp +13 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,14 @@ File :: File() { } File :: ~File() { // destroying a file without closing is a memory leak // (an open file descriptor is left behind, on Linux there is typically // only a limited number of descriptors available to each process) close(); } bool File :: open( const String& fileName, const tnlIOMode mode ) { Loading Loading @@ -60,6 +68,11 @@ bool File :: close() std::cerr << "I was not able to close the file " << fileName << " properly!" << std::endl; return false; } // reset all attributes mode = tnlUndefinedMode; file = NULL; fileOK = false; fileName = ""; readElements = writtenElements = 0; return true; }; Loading
src/TNL/File.h +2 −0 Original line number Diff line number Diff line Loading @@ -57,6 +57,8 @@ class File File(); ~File(); bool open( const String& fileName, const tnlIOMode mode ); Loading
src/TNL/Object.cpp +4 −19 Original line number Diff line number Diff line Loading @@ -85,10 +85,7 @@ bool Object :: save( const String& fileName ) const std::cerr << "I am not bale to open the file " << fileName << " for writing." << std::endl; return false; } const bool status = this->save( file ); if( ! file. close() ) std::cerr << "An error occurred when I was closing the file " << fileName << "." << std::endl; return status; return this->save( file ); } bool Object :: load( const String& fileName ) Loading @@ -99,10 +96,7 @@ bool Object :: load( const String& fileName ) std::cerr << "I am not bale to open the file " << fileName << " for reading." << std::endl; return false; } const bool status = this->load( file ); if( ! file. close() ) std::cerr << "An error occurred when I was closing the file " << fileName << "." << std::endl; return status; return this->load( file ); } bool Object :: boundLoad( const String& fileName ) Loading @@ -113,14 +107,7 @@ bool Object :: boundLoad( const String& fileName ) std::cerr << "I am not bale to open the file " << fileName << " for reading." << std::endl; return false; } if( ! this->boundLoad( file ) ) return false; if( ! file. close() ) { std::cerr << "An error occurred when I was closing the file " << fileName << "." << std::endl; return false; } return true; return this->boundLoad( file ); } void Object::setDeprecatedReadMode() Loading Loading @@ -155,9 +142,7 @@ bool getObjectType( const String& fileName, String& type ) std::cerr << "I am not able to open the file " << fileName << " for detecting the object inside!" << std::endl; return false; } bool ret_val = getObjectType( binaryFile, type ); binaryFile. close(); return ret_val; return getObjectType( binaryFile, type ); } bool parseObjectType( const String& objectType, Loading