///////////////////////////////////////////////////////////////////////////////
// CreateObject -- creates the named object and fills out its properties
//      appropriately. Returns NULL if any errors occur and fills up the 
//      error queue.
//      
//      This does not create the object if dev > 0 and the object's mDev is not
//      equal to it (thus preventing the crossing of file systems)
//
//      TODO -- in the future, this should become some kind of lazy evaluation so
//          that we don't have to get all the stats() we don't need to.
///////////////////////////////////////////////////////////////////////////////
iFCO * cFSDataSourceIter::CreateObject(const cFCOName& name, bool bCreatePeers )
{
    cFSObject* pNewObj = new cFSObject(name);

    if( ! bCreatePeers )
    {
        // when bCreatePeers is false, it means we should set mDev to the 
        // device number of the current object (ie -- it is a new "start point")
        // If we don't do this here, InitializeTypeInfo() will reject creating the
        // node.
        // -- 9 June 99 mdb
        //
        mDev = 0;
        if( ! InitializeTypeInfo( pNewObj ) )
        {
            pNewObj->Release();
            return 0;
        }
        mDev = pNewObj->GetFSPropSet().GetDev();
    }

    return pNewObj;
}
Пример #2
0
MagickExport void
InitializeMagick(const char *path)
{
  const char
    *p;

  /* NOTE: This routine sets up the path to the client which needs to
     be determined before almost anything else works right. This also
     includes logging!!! So we can't start logging until the path is
     actually saved. As soon as we know what the path is we make the
     same call to DefineClientSettings to set it up. Please make sure
     that this rule is followed in any future updates the this code!!!
  */
  if (MagickInitialized == InitInitialized)
    return;
  SPINLOCK_WAIT;
  MagickInitialized=InitInitialized;
  SPINLOCK_RELEASE;
  
#if defined(MSWINDOWS)
# if defined(_DEBUG) && !defined(__BORLANDC__)
  {
    int
      debug;
    
    debug=_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
    debug|=_CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_DELAY_FREE_MEM_DF |
      _CRTDBG_LEAK_CHECK_DF;
    // debug=_CrtSetDbgFlag(debug);
    // _ASSERTE(_CrtCheckMemory());
  }
# endif /* defined(_DEBUG) */
#endif /* defined(MSWINDOWS) */
  
  (void) setlocale(LC_ALL,"");
  (void) setlocale(LC_NUMERIC,"C");

  /* Initialize semaphores */
  InitializeSemaphore();

  /* Initialize logging */
  InitializeLogInfo();

  /* Seed the random number generator */
  srand(MagickRandNewSeed());

  /* Initialize our random number generator */
  InitializeMagickRandomGenerator();

  /*
    Set logging flags using the value of MAGICK_DEBUG if it is set in
    the environment.
  */
  if ((p=getenv("MAGICK_DEBUG")) != (const char *) NULL)
    (void) SetLogEventMask(p);

  (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
			"Initialize Magick");

  /*
    Set the filesystem block size.
  */
  {
    size_t
      block_size=16384;
    
    if ((p=getenv("MAGICK_IOBUF_SIZE")) != (const char *) NULL)
      block_size = (size_t) MagickAtoL(p);
    
    MagickSetFileSystemBlockSize(block_size);
  }

  /*
    Establish the path, filename, and display name of the client app
  */
  InitializeMagickClientPathAndName(path);
  /*
    If the client name did not get setup for any reason, we take one
    last shot at it using the data the caller passed us.
  */
  if (GetClientName() == (const char *) NULL)
    DefineClientName(path);

  /*
    Adjust minimum coder class if requested.
  */
  if ((p=getenv("MAGICK_CODER_STABILITY")) != (const char *) NULL)
    {
      if (LocaleCompare(p,"UNSTABLE") == 0)
        MinimumCoderClass=UnstableCoderClass;
      else if (LocaleCompare(p,"STABLE") == 0)
        MinimumCoderClass=StableCoderClass;
      else if (LocaleCompare(p,"PRIMARY") == 0)
        MinimumCoderClass=PrimaryCoderClass;
    }

  InitializeMagickSignalHandlers(); /* Signal handlers */
  InitializeTemporaryFiles();       /* Temporary files */
  InitializeMagickResources();      /* Resources */
  InitializeMagickRegistry();       /* Image/blob registry */
  InitializeConstitute();           /* Constitute semaphore */
  InitializeMagickInfoList();       /* Coder registrations + modules */
  InitializeMagicInfo();            /* File format detection */
  InitializeTypeInfo();             /* Font information */
  InitializeDelegateInfo();         /* External delegate information */
  InitializeColorInfo();            /* Color database */
  MagickInitializeCommandInfo();    /* Command parser */

  /* Let's log the three important setting as we exit this routine */
  (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
    "Path: \"%s\" Name: \"%s\" Filename: \"%s\"",
      GetClientPath(),GetClientName(),GetClientFilename());
}