Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 1997-08-08 |
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. | |
b311480e | 16 | |
7fd59977 | 17 | // Modified by rmi, Wed Jan 14 08:17:35 1998 |
18 | ||
42cf5bc1 | 19 | #include <CDF_Application.hxx> |
7fd59977 | 20 | #include <CDF_Directory.hxx> |
21 | #include <CDF_MetaDataDriver.hxx> | |
42cf5bc1 | 22 | #include <CDF_Session.hxx> |
42cf5bc1 | 23 | #include <CDM_CanCloseStatus.hxx> |
24 | #include <CDM_Document.hxx> | |
25 | #include <CDM_MetaData.hxx> | |
26 | #include <PCDM_Reader.hxx> | |
7fd59977 | 27 | #include <PCDM_ReadWriter.hxx> |
28 | #include <PCDM_RetrievalDriver.hxx> | |
29 | #include <PCDM_StorageDriver.hxx> | |
7fd59977 | 30 | #include <Plugin.hxx> |
42cf5bc1 | 31 | #include <Standard_ErrorHandler.hxx> |
32 | #include <Standard_GUID.hxx> | |
33 | #include <Standard_NoSuchObject.hxx> | |
34 | #include <Standard_ProgramError.hxx> | |
7fd59977 | 35 | #include <UTL.hxx> |
36 | ||
92efcf78 | 37 | IMPLEMENT_STANDARD_RTTIEXT(CDF_Application,CDM_Application) |
38 | ||
7fd59977 | 39 | #define theMetaDataDriver CDF_Session::CurrentSession()->MetaDataDriver() |
40 | ||
41 | ||
42 | //======================================================================= | |
43 | //function : | |
44 | //purpose : | |
45 | //======================================================================= | |
15e8b082 | 46 | CDF_Application::CDF_Application():myRetrievableStatus(PCDM_RS_OK) {} |
7fd59977 | 47 | |
48 | //======================================================================= | |
49 | //function : Load | |
50 | //purpose : | |
51 | //======================================================================= | |
52 | Handle(CDF_Application) CDF_Application::Load(const Standard_GUID& aGUID) { | |
53 | return Handle(CDF_Application)::DownCast(Plugin::Load(aGUID)); | |
54 | } | |
55 | ||
56 | //======================================================================= | |
57 | //function : Open | |
58 | //purpose : | |
59 | //======================================================================= | |
60 | void CDF_Application::Open(const Handle(CDM_Document)& aDocument) { | |
61 | CDF_Session::CurrentSession()->Directory()->Add(aDocument); | |
62 | aDocument->Open(this); | |
63 | Activate(aDocument,CDF_TOA_New); | |
64 | } | |
65 | ||
66 | //======================================================================= | |
67 | //function : CanClose | |
68 | //purpose : | |
69 | //======================================================================= | |
70 | CDM_CanCloseStatus CDF_Application::CanClose(const Handle(CDM_Document)& aDocument) { | |
71 | return aDocument->CanClose(); | |
72 | } | |
73 | ||
74 | //======================================================================= | |
75 | //function : Close | |
76 | //purpose : | |
77 | //======================================================================= | |
78 | void CDF_Application::Close(const Handle(CDM_Document)& aDocument) { | |
79 | CDF_Session::CurrentSession()->Directory()->Remove(aDocument); | |
80 | aDocument->Close(); | |
81 | } | |
82 | ||
83 | //======================================================================= | |
84 | //function : Retrieve | |
85 | //purpose : | |
86 | //======================================================================= | |
87 | Handle(CDM_Document) CDF_Application::Retrieve(const TCollection_ExtendedString& aFolder, | |
88 | const TCollection_ExtendedString& aName, | |
89 | const Standard_Boolean UseStorageConfiguration) { | |
90 | TCollection_ExtendedString nullVersion; | |
91 | return Retrieve(aFolder,aName,nullVersion,UseStorageConfiguration); | |
92 | } | |
93 | ||
94 | //======================================================================= | |
95 | //function : Retrieve | |
96 | //purpose : | |
97 | //======================================================================= | |
98 | Handle(CDM_Document) CDF_Application::Retrieve(const TCollection_ExtendedString& aFolder, | |
99 | const TCollection_ExtendedString& aName, | |
100 | const TCollection_ExtendedString& aVersion, | |
742cc8b0 | 101 | const Standard_Boolean UseStorageConfiguration) |
102 | { | |
7fd59977 | 103 | Handle(CDM_MetaData) theMetaData; |
104 | ||
105 | if(aVersion.Length() == 0) | |
106 | theMetaData=theMetaDataDriver->MetaData(aFolder,aName); | |
107 | else | |
108 | theMetaData=theMetaDataDriver->MetaData(aFolder,aName,aVersion); | |
109 | ||
7fd59977 | 110 | CDF_TypeOfActivation theTypeOfActivation=TypeOfActivation(theMetaData); |
111 | Handle(CDM_Document) theDocument=Retrieve(theMetaData,UseStorageConfiguration,Standard_False); | |
112 | ||
7fd59977 | 113 | CDF_Session::CurrentSession()->Directory()->Add(theDocument); |
114 | Activate(theDocument,theTypeOfActivation); | |
115 | ||
7fd59977 | 116 | theDocument->Open(this); |
117 | return theDocument; | |
7fd59977 | 118 | } |
119 | ||
120 | //======================================================================= | |
121 | //function : CanRetrieve | |
122 | //purpose : | |
123 | //======================================================================= | |
15e8b082 | 124 | PCDM_ReaderStatus CDF_Application::CanRetrieve(const TCollection_ExtendedString& aFolder, const TCollection_ExtendedString& aName) { |
7fd59977 | 125 | TCollection_ExtendedString aVersion; |
126 | return CanRetrieve(aFolder,aName,aVersion); | |
127 | } | |
128 | ||
129 | //======================================================================= | |
130 | //function : CanRetrieve | |
131 | //purpose : | |
132 | //======================================================================= | |
15e8b082 | 133 | PCDM_ReaderStatus CDF_Application::CanRetrieve(const TCollection_ExtendedString& aFolder, const TCollection_ExtendedString& aName, const TCollection_ExtendedString& aVersion) { |
7fd59977 | 134 | |
7fd59977 | 135 | if (!theMetaDataDriver->Find(aFolder,aName,aVersion)) |
15e8b082 | 136 | return PCDM_RS_UnknownDocument; |
7fd59977 | 137 | else if (!theMetaDataDriver->HasReadPermission(aFolder,aName,aVersion)) |
15e8b082 | 138 | return PCDM_RS_PermissionDenied; |
7fd59977 | 139 | else { |
7fd59977 | 140 | Handle(CDM_MetaData) theMetaData = theMetaDataDriver->MetaData(aFolder,aName,aVersion); |
141 | ||
7fd59977 | 142 | if(theMetaData->IsRetrieved()) { |
143 | return theMetaData->Document()->IsModified() | |
15e8b082 | 144 | ? PCDM_RS_AlreadyRetrievedAndModified : PCDM_RS_AlreadyRetrieved; |
7fd59977 | 145 | } |
146 | else { | |
147 | TCollection_ExtendedString theFileName=theMetaData->FileName(); | |
148 | TCollection_ExtendedString theFormat=PCDM_ReadWriter::FileFormat(theFileName); | |
149 | if(theFormat.Length()==0) { | |
150 | TCollection_ExtendedString ResourceName=UTL::Extension(theFileName); | |
151 | ResourceName+=".FileFormat"; | |
152 | if(UTL::Find(Resources(),ResourceName)) { | |
153 | theFormat=UTL::Value(Resources(),ResourceName); | |
154 | } | |
155 | else | |
15e8b082 | 156 | return PCDM_RS_UnrecognizedFileFormat; |
7fd59977 | 157 | } |
6fe96f84 | 158 | |
159 | // check actual availability of the driver | |
160 | try { | |
161 | Handle(PCDM_Reader) aReader = ReaderFromFormat(theFormat); | |
162 | if (aReader.IsNull()) | |
163 | return PCDM_RS_NoDriver; | |
164 | } | |
165 | catch (Standard_Failure) | |
166 | { | |
167 | // no need to report error, this was just check for availability | |
168 | } | |
7fd59977 | 169 | } |
170 | } | |
15e8b082 | 171 | return PCDM_RS_OK; |
7fd59977 | 172 | } |
173 | ||
7fd59977 | 174 | //======================================================================= |
175 | //function : Activate | |
176 | //purpose : | |
177 | //======================================================================= | |
178 | //void CDF_Application::Activate(const Handle(CDM_Document)& aDocument,const CDF_TypeOfActivation aTypeOfActivation) { | |
179 | void CDF_Application::Activate(const Handle(CDM_Document)& ,const CDF_TypeOfActivation ) { | |
180 | } | |
181 | ||
182 | //======================================================================= | |
183 | //function : DefaultFolder | |
184 | //purpose : | |
185 | //======================================================================= | |
186 | Standard_ExtString CDF_Application::DefaultFolder(){ | |
187 | if(myDefaultFolder.Length() == 0) { | |
188 | myDefaultFolder=CDF_Session::CurrentSession()->MetaDataDriver()->DefaultFolder(); | |
189 | } | |
190 | return myDefaultFolder.ToExtString(); | |
191 | } | |
192 | ||
193 | //======================================================================= | |
194 | //function : SetDefaultFolder | |
195 | //purpose : | |
196 | //======================================================================= | |
197 | Standard_Boolean CDF_Application::SetDefaultFolder(const Standard_ExtString aFolder) { | |
198 | Standard_Boolean found = CDF_Session::CurrentSession()->MetaDataDriver()->FindFolder(aFolder); | |
199 | if(found) myDefaultFolder=aFolder; | |
200 | return found; | |
201 | } | |
202 | ||
7fd59977 | 203 | //======================================================================= |
204 | //function : Retrieve | |
205 | //purpose : | |
206 | //======================================================================= | |
207 | Handle(CDM_Document) CDF_Application::Retrieve(const Handle(CDM_MetaData)& aMetaData,const Standard_Boolean UseStorageConfiguration) { | |
208 | return Retrieve(aMetaData,UseStorageConfiguration,Standard_True); | |
209 | } | |
210 | ||
7fd59977 | 211 | //======================================================================= |
212 | //function : Retrieve | |
213 | //purpose : | |
214 | //======================================================================= | |
215 | Handle(CDM_Document) CDF_Application::Retrieve(const Handle(CDM_MetaData)& aMetaData,const Standard_Boolean UseStorageConfiguration, const Standard_Boolean IsComponent) { | |
216 | ||
217 | Handle(CDM_Document) theDocumentToReturn; | |
15e8b082 | 218 | myRetrievableStatus = PCDM_RS_DriverFailure; |
7fd59977 | 219 | if(IsComponent) { |
220 | Standard_SStream aMsg; | |
221 | switch (CanRetrieve(aMetaData)) { | |
15e8b082 | 222 | case PCDM_RS_UnknownDocument: |
7fd59977 | 223 | aMsg << "could not find the referenced document: " << aMetaData->Path() << "; not found." <<(char)0 << endl; |
15e8b082 | 224 | myRetrievableStatus = PCDM_RS_UnknownDocument; |
7fd59977 | 225 | Standard_Failure::Raise(aMsg); |
226 | break; | |
15e8b082 | 227 | case PCDM_RS_PermissionDenied: |
7fd59977 | 228 | aMsg << "Could not find the referenced document: " << aMetaData->Path() << "; permission denied. " <<(char)0 << endl; |
15e8b082 | 229 | myRetrievableStatus = PCDM_RS_PermissionDenied; |
7fd59977 | 230 | Standard_Failure::Raise(aMsg); |
231 | break; | |
232 | default: | |
233 | break; | |
234 | } | |
235 | ||
236 | } | |
237 | Standard_Boolean AlreadyRetrieved=aMetaData->IsRetrieved(); | |
15e8b082 | 238 | if(AlreadyRetrieved) myRetrievableStatus = PCDM_RS_AlreadyRetrieved; |
7fd59977 | 239 | Standard_Boolean Modified=AlreadyRetrieved && aMetaData->Document()->IsModified(); |
15e8b082 | 240 | if(Modified) myRetrievableStatus = PCDM_RS_AlreadyRetrievedAndModified; |
6fe96f84 | 241 | if(!AlreadyRetrieved || Modified) |
242 | { | |
243 | TCollection_ExtendedString aFormat; | |
244 | if (!Format(aMetaData->FileName(), aFormat)) | |
245 | { | |
246 | Standard_SStream aMsg; | |
247 | aMsg << "Could not determine format for the file " << aMetaData->FileName() << (char)0; | |
248 | Standard_NoSuchObject::Raise(aMsg); | |
249 | } | |
250 | Handle(PCDM_Reader) theReader = ReaderFromFormat (aFormat); | |
251 | ||
7fd59977 | 252 | Handle(CDM_Document) theDocument; |
253 | ||
254 | if(Modified) { | |
255 | theDocument=aMetaData->Document(); | |
256 | theDocument->RemoveAllReferences(); | |
257 | } | |
258 | else | |
259 | theDocument=theReader->CreateDocument(); | |
260 | ||
261 | SetReferenceCounter(theDocument,PCDM_RetrievalDriver::ReferenceCounter(aMetaData->FileName(), MessageDriver())); | |
262 | ||
263 | SetDocumentVersion(theDocument,aMetaData); | |
264 | theMetaDataDriver->ReferenceIterator()->LoadReferences(theDocument,aMetaData,this,UseStorageConfiguration); | |
265 | ||
266 | try { | |
267 | OCC_CATCH_SIGNALS | |
268 | theReader->Read(aMetaData->FileName(),theDocument,this); | |
269 | } | |
270 | catch (Standard_Failure) { | |
15e8b082 M |
271 | myRetrievableStatus = theReader->GetStatus(); |
272 | if(myRetrievableStatus > PCDM_RS_AlreadyRetrieved){ | |
7fd59977 | 273 | Standard_SStream aMsg; |
274 | aMsg << Standard_Failure::Caught() << endl; | |
275 | Standard_Failure::Raise(aMsg); | |
276 | } | |
277 | } | |
15e8b082 | 278 | myRetrievableStatus = theReader->GetStatus(); |
7fd59977 | 279 | theDocument->SetMetaData(aMetaData); |
280 | ||
281 | theDocumentToReturn=theDocument; | |
282 | } | |
283 | else | |
284 | theDocumentToReturn=aMetaData->Document(); | |
285 | ||
286 | return theDocumentToReturn; | |
287 | } | |
288 | ||
289 | //======================================================================= | |
290 | //function : DocumentVersion | |
291 | //purpose : | |
292 | //======================================================================= | |
293 | Standard_Integer CDF_Application::DocumentVersion(const Handle(CDM_MetaData)& theMetaData) { | |
294 | // const Handle(CDM_MessageDriver)& aMsgDriver = MessageDriver(); | |
295 | return PCDM_RetrievalDriver::DocumentVersion(theMetaData->FileName(), MessageDriver()); | |
296 | } | |
297 | ||
298 | //======================================================================= | |
299 | //function : TypeOfActivation | |
300 | //purpose : | |
301 | //======================================================================= | |
302 | CDF_TypeOfActivation CDF_Application::TypeOfActivation(const Handle(CDM_MetaData)& aMetaData) { | |
303 | ||
304 | if(aMetaData->IsRetrieved()) { | |
305 | Handle(CDM_Document) theDocument=aMetaData->Document(); | |
306 | if(theDocument->IsOpened()) { | |
307 | if(theDocument->IsModified()) | |
308 | return CDF_TOA_Modified; | |
309 | else | |
310 | return CDF_TOA_Unchanged; | |
311 | } | |
312 | ||
313 | else | |
314 | return CDF_TOA_New; | |
315 | } | |
316 | return CDF_TOA_New; | |
317 | } | |
318 | ||
4ff92abe | 319 | //======================================================================= |
320 | //function : Read | |
321 | //purpose : | |
322 | //======================================================================= | |
323 | Handle(CDM_Document) CDF_Application::Read (Standard_IStream& theIStream) | |
324 | { | |
325 | Handle(CDM_Document) aDoc; | |
326 | Handle(Storage_Data) dData; | |
327 | ||
328 | TCollection_ExtendedString aFormat; | |
329 | ||
330 | try | |
331 | { | |
332 | OCC_CATCH_SIGNALS | |
333 | ||
334 | aFormat = PCDM_ReadWriter::FileFormat (theIStream, dData); | |
335 | } | |
336 | catch (Standard_Failure) | |
337 | { | |
338 | myRetrievableStatus = PCDM_RS_FormatFailure; | |
339 | ||
340 | Standard_SStream aMsg; | |
341 | aMsg << Standard_Failure::Caught() << endl; | |
342 | Standard_Failure::Raise(aMsg); | |
343 | } | |
344 | ||
345 | if (aFormat.IsEmpty()) | |
346 | { | |
347 | myRetrievableStatus = PCDM_RS_FormatFailure; | |
348 | return aDoc; | |
349 | } | |
350 | ||
351 | // 1. use a format name to detect plugin corresponding to the format to continue reading | |
352 | Handle(PCDM_Reader) aReader = ReaderFromFormat (aFormat); | |
353 | ||
354 | // 2. create document with the detected reader | |
355 | aDoc = aReader->CreateDocument(); | |
356 | ||
357 | // 3. read the content of theIStream to aDoc | |
358 | try | |
359 | { | |
360 | OCC_CATCH_SIGNALS | |
361 | ||
362 | aReader->Read (theIStream, dData, aDoc, this); | |
363 | } | |
364 | catch (Standard_Failure) | |
365 | { | |
366 | myRetrievableStatus = aReader->GetStatus(); | |
367 | if (myRetrievableStatus > PCDM_RS_AlreadyRetrieved) | |
368 | { | |
369 | Standard_SStream aMsg; | |
370 | aMsg << Standard_Failure::Caught() << endl; | |
371 | Standard_Failure::Raise(aMsg); | |
372 | } | |
373 | } | |
374 | ||
375 | myRetrievableStatus = aReader->GetStatus(); | |
376 | ||
377 | return aDoc; | |
378 | } | |
379 | ||
7fd59977 | 380 | //======================================================================= |
381 | //function : ReaderFromFormat | |
382 | //purpose : | |
383 | //======================================================================= | |
6fe96f84 | 384 | Handle(PCDM_Reader) CDF_Application::ReaderFromFormat(const TCollection_ExtendedString& theFormat) |
385 | { | |
386 | // check map of readers | |
387 | Handle(PCDM_RetrievalDriver) aReader; | |
2613378e | 388 | if (myReaders.FindFromKey (theFormat, aReader)) |
6fe96f84 | 389 | return aReader; |
390 | ||
391 | // support of legacy method of loading reader as plugin | |
392 | TCollection_ExtendedString aResourceName = theFormat; | |
393 | aResourceName += ".RetrievalPlugin"; | |
394 | if (!UTL::Find(Resources(), aResourceName)) | |
395 | { | |
2613378e | 396 | myReaders.Add(theFormat, aReader); |
7fd59977 | 397 | Standard_SStream aMsg; |
6fe96f84 | 398 | aMsg << "Could not found the item:" << aResourceName <<(char)0; |
15e8b082 | 399 | myRetrievableStatus = PCDM_RS_WrongResource; |
7fd59977 | 400 | Standard_NoSuchObject::Raise(aMsg); |
6fe96f84 | 401 | } |
402 | ||
403 | // Get GUID as a string. | |
404 | TCollection_ExtendedString strPluginId = UTL::Value(Resources(), aResourceName); | |
405 | ||
406 | // If the GUID (as a string) contains blanks, remove them. | |
407 | if (strPluginId.Search(' ') != -1) | |
408 | strPluginId.RemoveAll(' '); | |
409 | ||
410 | // Convert to GUID. | |
411 | Standard_GUID aPluginId = UTL::GUID(strPluginId); | |
412 | ||
7fd59977 | 413 | try { |
414 | OCC_CATCH_SIGNALS | |
6fe96f84 | 415 | aReader = Handle(PCDM_RetrievalDriver)::DownCast(Plugin::Load(aPluginId)); |
7fd59977 | 416 | } |
6fe96f84 | 417 | catch (Standard_Failure) |
418 | { | |
2613378e | 419 | myReaders.Add(theFormat, aReader); |
15e8b082 | 420 | myRetrievableStatus = PCDM_RS_WrongResource; |
6fe96f84 | 421 | Standard_Failure::Caught()->Reraise(); |
7fd59977 | 422 | } |
6fe96f84 | 423 | if (!aReader.IsNull()) { |
424 | aReader->SetFormat(theFormat); | |
425 | } | |
426 | else | |
427 | { | |
15e8b082 | 428 | myRetrievableStatus = PCDM_RS_WrongResource; |
6fe96f84 | 429 | } |
430 | ||
431 | // record in map | |
2613378e | 432 | myReaders.Add(theFormat, aReader); |
6fe96f84 | 433 | return aReader; |
7fd59977 | 434 | } |
435 | ||
436 | //======================================================================= | |
6fe96f84 | 437 | //function : WriterFromFormat |
7fd59977 | 438 | //purpose : |
439 | //======================================================================= | |
6fe96f84 | 440 | Handle(PCDM_StorageDriver) CDF_Application::WriterFromFormat(const TCollection_ExtendedString& theFormat) |
441 | { | |
442 | // check map of writers | |
443 | Handle(PCDM_StorageDriver) aDriver; | |
2613378e | 444 | if (myWriters.FindFromKey(theFormat, aDriver)) |
6fe96f84 | 445 | return aDriver; |
446 | ||
447 | // support of legacy method of loading reader as plugin | |
448 | TCollection_ExtendedString aResourceName = theFormat; | |
449 | aResourceName += ".StoragePlugin"; | |
450 | if(!UTL::Find(Resources(), aResourceName)) | |
451 | { | |
2613378e | 452 | myWriters.Add(theFormat, aDriver); |
6fe96f84 | 453 | Standard_SStream aMsg; |
454 | aMsg << "Could not found the resource definition:" << aResourceName <<(char)0; | |
455 | Standard_NoSuchObject::Raise(aMsg); | |
456 | } | |
7fd59977 | 457 | |
6fe96f84 | 458 | // Get GUID as a string. |
459 | TCollection_ExtendedString strPluginId = UTL::Value(Resources(), aResourceName); | |
7fd59977 | 460 | |
6fe96f84 | 461 | // If the GUID (as a string) contains blanks, remove them. |
462 | if (strPluginId.Search(' ') != -1) | |
463 | strPluginId.RemoveAll(' '); | |
464 | ||
465 | // Convert to GUID. | |
466 | Standard_GUID aPluginId = UTL::GUID(strPluginId); | |
467 | ||
468 | try { | |
469 | OCC_CATCH_SIGNALS | |
470 | aDriver = Handle(PCDM_StorageDriver)::DownCast(Plugin::Load(aPluginId)); | |
471 | } | |
472 | catch (Standard_Failure) | |
473 | { | |
2613378e | 474 | myWriters.Add(theFormat, aDriver); |
6fe96f84 | 475 | myRetrievableStatus = PCDM_RS_WrongResource; |
476 | Standard_Failure::Caught()->Reraise(); | |
477 | } | |
478 | if (aDriver.IsNull()) | |
479 | { | |
480 | myRetrievableStatus = PCDM_RS_WrongResource; | |
481 | } | |
482 | else | |
483 | { | |
484 | aDriver->SetFormat(theFormat); | |
7fd59977 | 485 | } |
6fe96f84 | 486 | |
487 | // record in map | |
2613378e | 488 | myWriters.Add(theFormat, aDriver); |
6fe96f84 | 489 | return aDriver; |
7fd59977 | 490 | } |
491 | ||
492 | //======================================================================= | |
493 | //function : Format | |
494 | //purpose : dp | |
495 | //======================================================================= | |
496 | Standard_Boolean CDF_Application::Format(const TCollection_ExtendedString& aFileName, | |
497 | TCollection_ExtendedString& theFormat) | |
498 | { | |
499 | ||
500 | theFormat = PCDM_ReadWriter::FileFormat(aFileName); | |
0d969553 | 501 | // It is good if the format is in the file. Otherwise base on the extension. |
7fd59977 | 502 | if(theFormat.Length()==0) { |
503 | TCollection_ExtendedString ResourceName; | |
504 | ResourceName=UTL::Extension(aFileName); | |
505 | ResourceName+=".FileFormat"; | |
506 | ||
507 | if(UTL::Find(Resources(),ResourceName)) { | |
508 | theFormat = UTL::Value(Resources(),ResourceName); | |
509 | } | |
510 | else return Standard_False; | |
511 | } | |
512 | return Standard_True; | |
513 | } | |
514 | ||
7fd59977 | 515 | //======================================================================= |
516 | //function : CanRetrieve | |
517 | //purpose : | |
518 | //======================================================================= | |
15e8b082 | 519 | PCDM_ReaderStatus CDF_Application::CanRetrieve(const Handle(CDM_MetaData)& aMetaData) { |
7fd59977 | 520 | if(aMetaData->HasVersion()) |
521 | return CanRetrieve(aMetaData->Folder(),aMetaData->Name(),aMetaData->Version()); | |
522 | else | |
523 | return CanRetrieve(aMetaData->Folder(),aMetaData->Name()); | |
524 | } |