76a76f791eed73fffd238241488eea5298a4903c
[occt.git] / src / Storage / Storage_BaseDriver.cxx
1 // Copyright (c) 1998-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 //
4 // This file is part of Open CASCADE Technology software library.
5 //
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
11 //
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
14
15
16 #include <Storage_BaseDriver.hxx>
17 #include <Storage_StreamExtCharParityError.hxx>
18 #include <Storage_StreamFormatError.hxx>
19 #include <Storage_StreamTypeMismatchError.hxx>
20 #include <Storage_StreamWriteError.hxx>
21 #include <TCollection_AsciiString.hxx>
22 #include <TCollection_ExtendedString.hxx>
23
24 Storage_BaseDriver::Storage_BaseDriver() : myOpenMode(Storage_VSNone)
25 {
26 }
27 void Storage_BaseDriver::Delete()
28 {}
29
30 TCollection_AsciiString Storage_BaseDriver::ReadMagicNumber (Standard_IStream& theIStream)
31 {
32   // magic number has the same length which is 7: BINFILE, CMPFILE and FSDFILE
33   Standard_Size aMagicNumberLen = 7;
34
35   TCollection_AsciiString aReadMagicNumber;
36
37   char aChar;
38   Standard_Size aReadCharNb = 0;
39
40   while (theIStream.good() && (aReadCharNb < aMagicNumberLen))
41   {
42     theIStream.get(aChar);
43     aReadCharNb += (Standard_Size)theIStream.gcount();
44     aReadMagicNumber += aChar;
45   }
46
47   return aReadMagicNumber;
48 }