0031353: TDocStd_Application does not have api to set progress indicator
[occt.git] / src / PCDM / PCDM.cxx
CommitLineData
b311480e 1// Created on: 1997-11-05
2// Created by: Jean-Louis Frenkel
3// Copyright (c) 1997-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 8// This library is free software; you can redistribute it and/or modify it under
9// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
42cf5bc1 17
18#include <CDM_Application.hxx>
19#include <CDM_Document.hxx>
20#include <FSD_BinaryFile.hxx>
21#include <FSD_CmpFile.hxx>
22#include <FSD_File.hxx>
23#include <PCDM.hxx>
24#include <PCDM_StorageDriver.hxx>
7fd59977 25#include <Plugin.hxx>
7fd59977 26#include <Resource_Manager.hxx>
27#include <Standard_GUID.hxx>
42cf5bc1 28#include <Standard_NoSuchObject.hxx>
29#include <Standard_SStream.hxx>
30#include <Storage_Schema.hxx>
31#include <TCollection_AsciiString.hxx>
32#include <TCollection_ExtendedString.hxx>
7fd59977 33#include <UTL.hxx>
7fd59977 34
35//=======================================================================
7fd59977 36//function : FileDriverType
37//purpose :
38//=======================================================================
39
39c8dc70 40PCDM_TypeOfFileDriver PCDM::FileDriverType(const TCollection_AsciiString& aFileName, Handle(Storage_BaseDriver)& aBaseDriver)
41{
7fd59977 42 if(FSD_CmpFile::IsGoodFileType(aFileName) == Storage_VSOk) {
43 aBaseDriver=new FSD_CmpFile;
44 return PCDM_TOFD_CmpFile;
45 }
46 else if(FSD_File::IsGoodFileType(aFileName) == Storage_VSOk) {
47 aBaseDriver=new FSD_File;
48 return PCDM_TOFD_File;
49 }
50 else if(FSD_BinaryFile::IsGoodFileType(aFileName) == Storage_VSOk) {
51 aBaseDriver=new FSD_BinaryFile;
52 return PCDM_TOFD_File;
53 }
54 else {
55 aBaseDriver=NULL;
56 return PCDM_TOFD_Unknown;
57 }
58}
4ff92abe 59
60//=======================================================================
61//function : FileDriverType
62//purpose :
63//=======================================================================
64
39c8dc70 65PCDM_TypeOfFileDriver PCDM::FileDriverType (Standard_IStream& theIStream, Handle(Storage_BaseDriver)& theBaseDriver)
4ff92abe 66{
67 TCollection_AsciiString aReadMagicNumber;
68
5fce1605 69 // read magic number from the file
4ff92abe 70 if (theIStream.good())
71 {
4ff92abe 72 aReadMagicNumber = Storage_BaseDriver::ReadMagicNumber (theIStream);
4ff92abe 73 }
74
75 if(aReadMagicNumber == FSD_CmpFile::MagicNumber())
76 {
77 theBaseDriver = new FSD_CmpFile;
78 return PCDM_TOFD_CmpFile;
79 }
80 else if (aReadMagicNumber == FSD_File::MagicNumber())
81 {
82 theBaseDriver = new FSD_File;
83 return PCDM_TOFD_File;
84 }
85 else if (aReadMagicNumber == FSD_BinaryFile::MagicNumber())
86 {
87 theBaseDriver = new FSD_BinaryFile;
88 return PCDM_TOFD_File;
89 }
5fce1605 90 else if (aReadMagicNumber.Search ("<?xml") != -1)
91 {
92 // skip xml declaration
93 char aChar = ' ';
94 while (theIStream.good() && !theIStream.eof() && aChar != '>')
95 {
96 theIStream.get(aChar);
97 }
98
99 return PCDM_TOFD_XmlFile;
100 }
4ff92abe 101
102 theBaseDriver = NULL;
103 return PCDM_TOFD_Unknown;
104}
105