0026229: Add the possibility in OCAF to open/save a document from/to a stream object
[occt.git] / src / Storage / Storage_BaseDriver.cxx
CommitLineData
b311480e 1// Copyright (c) 1998-1999 Matra Datavision
973c2be1 2// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 3//
973c2be1 4// This file is part of Open CASCADE Technology software library.
b311480e 5//
d5f74e42 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
973c2be1 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.
b311480e 11//
973c2be1 12// Alternatively, this file may be used under the terms of Open CASCADE
13// commercial license or contractual agreement.
b311480e 14
42cf5bc1 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>
7fd59977 23
24Storage_BaseDriver::Storage_BaseDriver() : myOpenMode(Storage_VSNone)
25{
26}
27void Storage_BaseDriver::Delete()
28{}
29
4ff92abe 30TCollection_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}