Пример #1
0
ResultStatus LoadFile(const std::string& filename) {
    FileUtil::IOFile file(filename, "rb");
    if (!file.IsOpen()) {
        LOG_ERROR(Loader, "Failed to load file %s", filename.c_str());
        return ResultStatus::Error;
    }

    std::string filename_filename, filename_extension;
    Common::SplitPath(filename, nullptr, &filename_filename, &filename_extension);

    FileType type = IdentifyFile(file);
    FileType filename_type = GuessFromExtension(filename_extension);

    if (type != filename_type) {
        LOG_WARNING(Loader, "File %s has a different type than its extension.", filename.c_str());
        if (FileType::Unknown == type)
            type = filename_type;
    }

    LOG_INFO(Loader, "Loading file %s as %s...", filename.c_str(), GetFileTypeString(type));

    std::unique_ptr<AppLoader> app_loader = GetLoader(std::move(file), type, filename_filename, filename);

    switch (type) {

    // 3DSX file format...
    // or NCCH/NCSD container formats...
    case FileType::THREEDSX:
    case FileType::CXI:
    case FileType::CCI:
    {
        // Load application and RomFS
        ResultStatus result = app_loader->Load();
        if (ResultStatus::Success == result) {
            Service::FS::RegisterArchiveType(std::make_unique<FileSys::ArchiveFactory_RomFS>(*app_loader), Service::FS::ArchiveIdCode::RomFS);
            return ResultStatus::Success;
        }
        return result;
    }

    // Standard ELF file format...
    case FileType::ELF:
        return app_loader->Load();

    // CIA file format...
    case FileType::CIA:
        return ResultStatus::ErrorNotImplemented;

    // Error occurred durring IdentifyFile...
    case FileType::Error:

    // IdentifyFile could know identify file type...
    case FileType::Unknown:
    {
        LOG_CRITICAL(Loader, "File %s is of unknown type.", filename.c_str());
        return ResultStatus::ErrorInvalidFormat;
    }
    }
    return ResultStatus::Error;
}
Пример #2
0
extern "C" void __declspec(dllexport) initAddin(IDispatch* pDesigner)
{
#ifdef _DEBUG
	MessageBox(0, L"attach debugger and press ok", L"Debug message", MB_OK);
#endif

	InitLibrary(g_CurrentModule);
	if(!PrepareTypeInfo())
	{
		return;
	}

	HRESULT hr;
	VARIANT addins;
	addins.vt = VT_DISPATCH;
	VariantInit(&addins);
	hr = invoke(pDesigner, DISPATCH_PROPERTYGET, &addins, NULL, NULL, L"addins", NULL);
	if(FAILED(hr))
	{
		return;
	}
	
	IDispatch* addinsObj = V_DISPATCH(&addins);

	IUnknown* loader = GetLoader(pDesigner);
	hr = invoke(addinsObj, DISPATCH_METHOD, NULL, NULL, NULL, L"registerLoader", L"U", loader);
}
Пример #3
0
iVideoStream* cVideoManager::CreateVideo(const tString& asName)
{
    BeginLoad(asName);

    tString sPath = mpFileSearcher->GetFilePath(asName);
    if(sPath == "")
        {
            EndLoad();
            Error("Video file '%s' could not be found!\n",asName.c_str());
            return NULL;
        }

    iVideoStreamLoader *pLoader = GetLoader(asName);
    if(pLoader==NULL)
        {
            Error("Could not find a loader for '%s'\n",asName.c_str());
            return NULL;
        }

    iVideoStream *pVideo = pLoader->Create(asName);

    if(pVideo->LoadFromFile(sPath)==false)
        {
            EndLoad();
            hplDelete(pVideo);
            Error("Could not load video '%s'\n",asName.c_str());
            return NULL;
        }

    AddResource(pVideo);

    EndLoad();
    return pVideo;
}
Пример #4
0
OpenUtility::CTexture* OpenUtility::CTexture::LoadTextureFile(const char *file,unsigned long w,unsigned long h,bool nonPowerOf2)
{
	CTextureLoader *texLoader;

	if ((texLoader=GetLoader(file))!=NULL)
	{
		unsigned char *data;
		EPicMode channel;

		if ((data=texLoader->Load(file,w,h,channel))!=NULL)
		{
			CTexture *texObj=LoadTextureMemory(data,w,h,channel,nonPowerOf2);
			texLoader->DestroyData(data);
			return(texObj);
		}
	}
	return(NULL);
}
Пример #5
0
void CGUIWindowBoxeeMediaMain::LoadMediaItems()
{
  Cleanup();

  LoadMediaItems(m_listMediaItems);
  LoadAppItems(m_listApps);
  
  m_listMediaItemsSmall.Append(m_listMediaItems);
  m_listAppsSmall.Append(m_listApps);

  CLog::Log(LOGDEBUG,"%s - loaded %d media items and %d applications", __FUNCTION__, m_listMediaItems.Size(), m_listApps.Size());

  int i;
  for (i=0; i<m_listMediaItems.Size(); i++) 
  {
    CGUIMessage winmsg(GUI_MSG_LABEL_ADD, GetID(), MEDIA_ITEMS_LIST, 0, 0, m_listMediaItems[i]);
    OnMessage(winmsg);
    CGUIMessage winmsg2(GUI_MSG_LABEL_ADD, GetID(), MEDIA_ITEMS_LIST_SMALL, 0, 0, m_listMediaItemsSmall[i]);
    OnMessage(winmsg2);
  }

  for (i=0; i<m_listApps.Size(); i++) 
  {
    CGUIMessage winmsg(GUI_MSG_LABEL_ADD, GetID(), APPS_ITEMS_LIST, 0, 0, m_listApps[i]);
    OnMessage(winmsg);
    CGUIMessage winmsg2(GUI_MSG_LABEL_ADD, GetID(), APPS_ITEMS_LIST_SMALL, 0, 0, m_listAppsSmall[i]);
    OnMessage(winmsg2);
  }
  
  // Load thumbnails for the items
  CLog::Log(LOGDEBUG,"Loading thumbnail for %d items", m_listMediaItems.Size()); 
  m_listMediaItems.FillInDefaultIcons();


  m_Loader = GetLoader();
  CFileItemList *pList = new CFileItemList;
  pList->Append(m_listMediaItems);
  pList->Append(m_listApps);
  m_Loader->SetObserver(this);
  m_Loader->Load(*pList);
}
DynamicCellModelLoaderPtr DynamicModelLoaderRegistry::GetLoader(const FileFinder& rFileFinder)
{
    return GetLoader(rFileFinder.GetAbsolutePath());
}