Beispiel #1
0
static bool ReadPluginInfo(CPluginInfo &pluginInfo, bool needCheckDll)
{
  if (needCheckDll)
  {
    NDLL::CLibrary lib;
    if (!lib.LoadEx(pluginInfo.FilePath, LOAD_LIBRARY_AS_DATAFILE))
      return false;
  }
  NDLL::CLibrary lib;
  if (!lib.Load(pluginInfo.FilePath))
    return false;
  GetPluginPropertyFunc getPluginProperty = (GetPluginPropertyFunc)lib.GetProc("GetPluginProperty");
  if (getPluginProperty == NULL)
    return false;
  
  NCOM::CPropVariant prop;
  if (getPluginProperty(NPlugin::kName, &prop) != S_OK)
    return false;
  if (prop.vt != VT_BSTR)
    return false;
  pluginInfo.Name = prop.bstrVal;
  prop.Clear();
  
  if (getPluginProperty(NPlugin::kClassID, &prop) != S_OK)
    return false;
  if (prop.vt == VT_EMPTY)
    pluginInfo.ClassIDDefined = false;
  else if (prop.vt != VT_BSTR)
    return false;
  else
  {
    pluginInfo.ClassIDDefined = true;
    pluginInfo.ClassID = *(const GUID *)prop.bstrVal;
  }
  prop.Clear();
  
  if (getPluginProperty(NPlugin::kOptionsClassID, &prop) != S_OK)
    return false;
  if (prop.vt == VT_EMPTY)
    pluginInfo.OptionsClassIDDefined = false;
  else if (prop.vt != VT_BSTR)
    return false;
  else
  {
    pluginInfo.OptionsClassIDDefined = true;
    pluginInfo.OptionsClassID = *(const GUID *)prop.bstrVal;
  }
  prop.Clear();

  if (getPluginProperty(NPlugin::kType, &prop) != S_OK)
    return false;
  if (prop.vt == VT_EMPTY)
    pluginInfo.Type = kPluginTypeFF;
  else if (prop.vt == VT_UI4)
    pluginInfo.Type = (EPluginType)prop.ulVal;
  else
    return false;
  return true;
}
Beispiel #2
0
HRESULT CCodecs::LoadFormats()
{
  const NDLL::CLibrary &lib = Libs.Back().Lib;
  GetHandlerPropertyFunc getProp = 0;
  GetHandlerPropertyFunc2 getProp2 = (GetHandlerPropertyFunc2)
	  lib.GetProcAddress("GetHandlerProperty2");
  if (getProp2 == NULL)
  {
	getProp = (GetHandlerPropertyFunc)
		lib.GetProcAddress("GetHandlerProperty");
	if (getProp == NULL)
	  return S_OK;
  }

  UInt32 numFormats = 1;
  GetNumberOfFormatsFunc getNumberOfFormats = (GetNumberOfFormatsFunc)
	lib.GetProcAddress("GetNumberOfFormats");
  if (getNumberOfFormats != NULL)
  {
	RINOK(getNumberOfFormats(&numFormats));
  }
  if (getProp2 == NULL)
	numFormats = 1;

  for(UInt32 i = 0; i < numFormats; i++)
  {
	CArcInfoEx item;
	item.LibIndex = Libs.Size() - 1;
	item.FormatIndex = i;

	RINOK(ReadStringProp(getProp, getProp2, i, NArchive::kName, item.Name));

	NCOM::CPropVariant prop;
	if (ReadProp(getProp, getProp2, i, NArchive::kClassID, prop) != S_OK)
	  continue;
	if (prop.vt != VT_BSTR)
	  continue;
	item.ClassID = *(const GUID *)prop.bstrVal;
	prop.Clear();

	UString ext, addExt;
	RINOK(ReadStringProp(getProp, getProp2, i, NArchive::kExtension, ext));
	RINOK(ReadStringProp(getProp, getProp2, i, NArchive::kAddExtension, addExt));
	item.AddExts(ext, addExt);

	ReadBoolProp(getProp, getProp2, i, NArchive::kUpdate, item.UpdateEnabled);
	if (item.UpdateEnabled)
	  ReadBoolProp(getProp, getProp2, i, NArchive::kKeepName, item.KeepName);
	
	if (ReadProp(getProp, getProp2, i, NArchive::kStartSignature, prop) == S_OK)
	  if (prop.vt == VT_BSTR)
	  {
		UINT len = ::SysStringByteLen(prop.bstrVal);
		item.StartSignature.SetCapacity(len);
		memmove(item.StartSignature, prop.bstrVal, len);
	  }
	Formats.Add(item);
  }
  return S_OK;
}
Beispiel #3
0
HRESULT CProxyArc::Load(const CArc &arc, IProgress *progress)
{
  // DWORD tickCount = GetTickCount(); for (int ttt = 0; ttt < 1; ttt++) {

  Files.Free();
  Dirs.Clear();

  Dirs.AddNew();
  IInArchive *archive = arc.Archive;

  UInt32 numItems;
  RINOK(archive->GetNumberOfItems(&numItems));
  
  if (progress)
    RINOK(progress->SetTotal(numItems));
  
  Files.Alloc(numItems);

  UString path;
  UString name;
  NCOM::CPropVariant prop;
  
  for (UInt32 i = 0; i < numItems; i++)
  {
    if (progress && (i & 0xFFFF) == 0)
    {
      UInt64 currentItemIndex = i;
      RINOK(progress->SetCompleted(&currentItemIndex));
    }
    
    const wchar_t *s = NULL;
    unsigned len = 0;
    bool isPtrName = false;

    #ifdef MY_CPU_LE
    if (arc.GetRawProps)
    {
      const void *p;
      UInt32 size;
      UInt32 propType;
      if (arc.GetRawProps->GetRawProp(i, kpidPath, &p, &size, &propType) == S_OK
          && propType == NPropDataType::kUtf16z
          && size > 2)
      {
        // is (size <= 2), it's empty name, and we call default arc.GetItemPath();
        len = size / 2 - 1;
        s = (const wchar_t *)p;
        isPtrName = true;
      }
    }
    if (!s)
    #endif
    {
      prop.Clear();
      RINOK(arc.Archive->GetProperty(i, kpidPath, &prop));
      if (prop.vt == VT_BSTR)
      {
        s = prop.bstrVal;
        len = ::SysStringLen(prop.bstrVal);
      }
      else if (prop.vt != VT_EMPTY)
        return E_FAIL;
      if (len == 0)
      {
        RINOK(arc.GetDefaultItemPath(i, path));
        len = path.Len();
        s = path;
      }
      
      /*
      RINOK(arc.GetItemPath(i, path));
      len = path.Len();
      s = path;
      */
    }

    unsigned curItem = 0;

    /*
    if (arc.Ask_Deleted)
    {
      bool isDeleted = false;
      RINOK(Archive_IsItem_Deleted(archive, i, isDeleted));
      if (isDeleted)
        curItem = AddDirSubItem(curItem, (UInt32)(Int32)-1, false, L"[DELETED]");
    }
    */

    unsigned namePos = 0;
    for (unsigned j = 0; j < len; j++)
    {
      wchar_t c = s[j];
      if (c == WCHAR_PATH_SEPARATOR || c == L'/')
      {
        name.SetFrom(s + namePos, j - namePos);
        curItem = AddDir(curItem, -1, name);
        namePos = j + 1;
      }
    }

    /*
    that code must be implemeted to hide alt streams in list.
    if (arc.Ask_AltStreams)
    {
      bool isAltStream;
      RINOK(Archive_IsItem_AltStream(archive, i, isAltStream));
      if (isAltStream)
      {

      }
    }
    */

    bool isDir;
    RINOK(Archive_IsItem_Dir(archive, i, isDir));

    CProxyFile &f = Files[i];

    f.NameLen = len - namePos;
    s += namePos;

    if (isPtrName)
      f.Name = s;
    else
    {
      f.Name = new wchar_t[f.NameLen + 1];
      f.NeedDeleteName = true;
      MyStringCopy((wchar_t *)f.Name, s);
    }

    if (isDir)
    {
      name = s;
      AddDir(curItem, (int)i, name);
    }
    else
      Dirs[curItem].SubFiles.Add(i);
  }
  
  CalculateSizes(0, archive);

  // } char s[128]; sprintf(s, "Load archive: %7d ms", GetTickCount() - tickCount); OutputDebugStringA(s);

  return S_OK;
}