コード例 #1
0
ファイル: OMFile.cpp プロジェクト: UIKit0/aaf
void OMFile::openModify(void)
{
  TRACE("OMFile::openModify");

	OMStoredObjectFactory* factory = 0;
	// if client said DontCare, get from isRecognized(_rawStorage, _encoding)
	if( nullOMStoredObjectEncoding == _encoding )
	{
#if defined(OM_DEBUG)
		bool result =
#endif
		isRecognized(_rawStorage, _encoding);
		ASSERT("Recognized file", result);
		factory = findFactory(_encoding);
		ASSERT("Recognized file encoding", factory != 0);
	}
	else
	{
		// else get exact:  findfactory->isRecognized(_rawStorage)
		factory = findFactory(_encoding);
		ASSERT("Recognized file encoding", factory != 0);
#if defined(OM_DEBUG)
		bool result =
#endif
		factory->isRecognized(_rawStorage);
		ASSERT("Recognized file", result);
	}

  _rootStore = factory->openModify(_rawStorage);
  ASSERT("Valid store", _rootStore != 0);
}
コード例 #2
0
ファイル: OMFile.cpp プロジェクト: UIKit0/aaf
  // @mfunc Open an existing <c OMFile> for read-only access, the
  //        <c OMFile> is named <p fileName>, use the <c OMClassFactory>
  //        <p factory> to create the objects. The file must already
  //        exist.
  //   @parm The name of the file to open.
  //   @parm The factory to use for creating objects.
  //   @parm Specifies the use of lazy or eager loading.
  //   @rdesc The newly opened <c OMFile>.
OMFile* OMFile::openExistingRead(const wchar_t* fileName,
                                 const OMClassFactory* factory,
                                 void* clientOnRestoreContext,
                                 const OMLoadMode loadMode,
                                 OMDictionary* dictionary)
{
  TRACE("OMFile::openExistingRead");

  PRECONDITION("Valid file name", validWideString(fileName));
  PRECONDITION("Valid class factory", factory != 0);
  PRECONDITION("Valid dictionary", dictionary != 0);

  OMStoredObjectEncoding encoding;
#if defined(OM_DEBUG)
  bool result =
#endif
  isRecognized(fileName, encoding);
  ASSERT("Recognized file", result); // tjb - error
  OMStoredObjectFactory* f = findFactory(encoding);
  ASSERT("Recognized file encoding", f != 0);

  OMFile* newFile = 0;
  if (compatibleNamedFile(readOnlyMode, encoding)) {
    OMStoredObject* store = f->openRead(fileName);
    newFile = new OMFile(fileName,
                         clientOnRestoreContext,
                         encoding,
                         readOnlyMode,
                         store,
                         factory,
                         dictionary,
                         loadMode);
    ASSERT("Valid heap pointer", newFile != 0);
  } else {
    OMRawStorage* store = OMCachedDiskRawStorage::openExistingRead(fileName);
    ASSERT("Valid raw storage", store != 0);
    newFile = new OMFile(store,
                         clientOnRestoreContext,
			 nullOMStoredObjectEncoding, // don't care 
                         readOnlyMode,
                         factory,
                         dictionary,
                         loadMode);
    ASSERT("Valid heap pointer", newFile != 0);
    newFile->open();
  }
  POSTCONDITION("File is open", newFile->isOpen());
  return newFile;
}
コード例 #3
0
  // @mfunc Is the file named <p fileName> a recognized file ?
  //        If so, the result is true.
  //   @parm The name of the file.
  //   @rdesc True if the file is recognized, false otherwise.
bool
OMXMLStoredObjectFactory::isRecognized(const wchar_t* fileName)
{
  TRACE("OMXMLStoredObjectFactory::isRecognized");
  
  bool result;
  OMRawStorage* rawStorage = OMDiskRawStorage::openExistingRead(fileName);
  if (rawStorage != 0) {
    result = isRecognized(rawStorage);
    delete rawStorage;
  } else {
    result = false;
  }
  return result;
}