예제 #1
0
void cPrefabPiecePool::ApplyBaseMetadataCubesetVer1(
	const AString & a_FileName,
	bool a_LogWarnings
)
{
	// Set the metadata values to defaults:
	m_MinDensity = 100;
	m_MaxDensity = 100;
	m_VillageRoadBlockType = E_BLOCK_GRAVEL;
	m_VillageRoadBlockMeta = 0;
	m_VillageWaterRoadBlockType = E_BLOCK_PLANKS;
	m_VillageWaterRoadBlockMeta = 0;

	// Read the metadata values:
	m_IntendedUse = GetMetadata("IntendedUse");
	GetStringMapInteger(m_Metadata, "MaxDensity",                m_MaxDensity);
	GetStringMapInteger(m_Metadata, "MinDensity",                m_MinDensity);
	GetStringMapInteger(m_Metadata, "VillageRoadBlockType",      m_VillageRoadBlockType);
	GetStringMapInteger(m_Metadata, "VillageRoadBlockMeta",      m_VillageRoadBlockMeta);
	GetStringMapInteger(m_Metadata, "VillageWaterRoadBlockType", m_VillageWaterRoadBlockType);
	GetStringMapInteger(m_Metadata, "VillageWaterRoadBlockMeta", m_VillageWaterRoadBlockMeta);

	// Read the allowed biomes:
	AString allowedBiomes = GetMetadata("AllowedBiomes");
	if (allowedBiomes.empty())
	{
		// All biomes are allowed:
		for (int b = biFirstBiome; b <= biMaxBiome; b++)
		{
			m_AllowedBiomes.insert(static_cast<EMCSBiome>(b));
		}
		for (int b = biFirstVariantBiome; b <= biMaxVariantBiome; b++)
		{
			m_AllowedBiomes.insert(static_cast<EMCSBiome>(b));
		}
	}
	else
	{
		auto biomes = StringSplitAndTrim(allowedBiomes, ",");
		for (const auto & biome: biomes)
		{
			EMCSBiome b = StringToBiome(biome);
			if (b == biInvalidBiome)
			{
				CONDWARNING(a_LogWarnings, "Invalid biome (\"%s\") specified in AllowedBiomes in cubeset file %s. Skipping the biome.",
					biome.c_str(), a_FileName.c_str()
				);
				continue;
			}
			m_AllowedBiomes.insert(b);
		}
	}
}
예제 #2
0
bool IMovable::IsTransp(int x, int y)
{
    if (NODRAW)
        return true;
    if (!GetSprite() || GetSprite()->Fail() || !GetMetadata())
        return true;

    int shift = 0;
    if (GetMetadata()->dirs >= 4)
        shift = helpers::dir_to_byond(dMove);

    return view_.IsTransp(x, y, shift);
}
예제 #3
0
void CMetadataPage::OnChange() {
    // TODO: Add your control notification handler code here
    CChannelMetadata dlgChannelMeta;
    UpdateData();

    TransferMetadata tmMetadata;

    m_stcTitle.GetWindowText(tmMetadata.csTitle);
    m_stcSubtitle.GetWindowText(tmMetadata.csSubtitle);
    m_stcAuthor.GetWindowText(tmMetadata.csAuthor);
    m_stcDescription.GetWindowText(tmMetadata.csDescription);
    m_stcSummary.GetWindowText(tmMetadata.csSummary);
    m_stcLanguage.GetWindowText(tmMetadata.csLanguage);
    m_stcCopyright.GetWindowText(tmMetadata.csCopyright);
    m_stcOwner.GetWindowText(tmMetadata.csOwner);
    m_stcEmail.GetWindowText(tmMetadata.csEmail);
    m_stcLink.GetWindowText(tmMetadata.csLink);
    m_stcWebmaster.GetWindowText(tmMetadata.csWebmaster);
    m_stcExplicit.GetWindowText(tmMetadata.csExplicit);
    m_stcKeywords.GetWindowText(tmMetadata.csKeywords);

    dlgChannelMeta.SetMetadata(tmMetadata);
    dlgChannelMeta.SetTempChannel(m_bTemporaryChannel);


    if (dlgChannelMeta.DoModal() == IDOK) {
        CSetMetadata smd;

        tmMetadata = dlgChannelMeta.GetMetadata();
        smd.SaveMetadata(tmMetadata);

        CGeneralSettings *tab = (CGeneralSettings *)this->GetParent();

        if (m_bTemporaryChannel) {
            CString csTempChannel = pApp->GetTempDirectory() + _T("\\TempChannel.xml");
            GetMetadata(csTempChannel);
            m_tmTempMetadata = dlgChannelMeta.GetTempMetadata();
            tab->SetTemporaryMetadata(m_tmTempMetadata);
        } else {
            CTransferPage *tpag = (CTransferPage *)tab->m_TabControl.m_Dialog[1];

            // use temporary storage
            CString csFile = pApp->GetTempDirectory() + _T("\\mod.xml");
            if(smd.Parse(tpag->GetChannelURL(), csFile) == TRUE) {
                tab->UploadChannel(tpag->GetChannelName(), csFile);
                GetMetadata(tpag->GetChannelURL());
            }
            tab->Refresh();
        }
    }
}
예제 #4
0
static void InitializeDeterministicWiiSaves(FS::FileSystem* session_fs)
{
  const u64 title_id = SConfig::GetInstance().GetTitleID();
  const auto configured_fs = FS::MakeFileSystem(FS::Location::Configured);
  if (Movie::IsRecordingInput())
  {
    if (NetPlay::IsNetPlayRunning() && !SConfig::GetInstance().bCopyWiiSaveNetplay)
    {
      Movie::SetClearSave(true);
    }
    else
    {
      // TODO: Check for the actual save data
      const std::string path = Common::GetTitleDataPath(title_id) + "/banner.bin";
      Movie::SetClearSave(!configured_fs->GetMetadata(IOS::PID_KERNEL, IOS::PID_KERNEL, path));
    }
  }

  if ((NetPlay::IsNetPlayRunning() && SConfig::GetInstance().bCopyWiiSaveNetplay) ||
      (Movie::IsMovieActive() && !Movie::IsStartingFromClearSave()))
  {
    // Copy the current user's save to the Blank NAND
    auto* sync_fs = NetPlay::GetWiiSyncFS();
    const auto user_save =
        WiiSave::MakeNandStorage(sync_fs ? sync_fs : configured_fs.get(), title_id);
    const auto session_save = WiiSave::MakeNandStorage(session_fs, title_id);
    WiiSave::Copy(user_save.get(), session_save.get());
  }
}
/****************************************************************************************************
 * @fn      ParsePacketHeader
 *          Expands bit-packed fields in Host Interface Packet to integral fields in Local Packet.
 ***************************************************************************************************/
static void ParsePacketHeader( LocalPacketTypes_t *pOut, const uint8_t *pSrc, uint8_t isSensorDataPacket )
{
    const uint8_t isPrivateNotAndroid   = GetAndroidOrPrivateField( pSrc );

    /* Copy header fields. Note that we already have Packet ID */
    pOut->Metadata = GetMetadata( pSrc );
    pOut->SType    = (ASensorType_t) GetSensorTypeField( pSrc );
    pOut->SubType  = GetSensorSubType( pSrc );

    if ( isPrivateNotAndroid )
    {
        pOut->SType  = AndroidSensorSetPrivateBase( pOut->SType );
    }

    if (isSensorDataPacket)
    {
        pOut->SCP.SDP.DataFormatSensor  = GetDataFormatSensor(        pSrc );
        pOut->SCP.SDP.TimeStampFormat   = GetTimeFormatSensor(        pSrc );
        pOut->SCP.SDP.Flush             = GetSensorDataFlushStatus(   pSrc );
        pOut->SCP.SDP.DataSize          = GetSensorDataDataSize(      pSrc );
        pOut->SCP.SDP.TimeStampSize     = GetSensorDataTimeStampSize( pSrc );
    }
    else  // Control packet
    {
        pOut->SCP.CRP.DataFormatControl = GetDataFormatControl(     pSrc );
        pOut->SCP.CRP.ParameterID       = GetControlParameterID(    pSrc );
        pOut->SCP.CRP.SequenceNumber    = GetControlSequenceNumber( pSrc );
    }
}
예제 #6
0
void UpdateIndexUtility(storage::DataTable* table,
                        const std::vector<sample_frequency_map_entry>& list) {

  oid_t index_count = table->GetIndexCount();

  for (oid_t index_itr = 0; index_itr < index_count; index_itr++) {

    // Get index
    auto index = table->GetIndex(index_itr);
    auto index_metadata = index->GetMetadata();
    auto index_key_attrs = index_metadata->GetKeyAttrs();

    std::set<oid_t> index_set(index_key_attrs.begin(), index_key_attrs.end());

    // Get current index utility
    auto current_index_utility = GetCurrentIndexUtility(index_set, list);

    auto average_index_utility = index_metadata->GetUtility();

    LOG_TRACE("Average index utility %5.2lf", average_index_utility);
    LOG_TRACE("Current index utility %5.2lf", current_index_utility);

    // alpha (weight for old samples)
    double alpha = 0.2;

    // Update index utility
    auto updated_average_index_utility =
        alpha * current_index_utility + (1 - alpha) * average_index_utility;

    index_metadata->SetUtility(updated_average_index_utility);

    LOG_TRACE("Updated index utility %5.2lf :: %s",
              updated_average_index_utility, index_metadata->GetInfo().c_str());
  }
}
예제 #7
0
파일: property.cpp 프로젝트: lvxejay/USD
std::string
UsdProperty::GetDisplayGroup() const
{
    std::string result;
    GetMetadata(SdfFieldKeys->DisplayGroup, &result);
    return result;
}
예제 #8
0
void CleanUpWiiFileSystemContents()
{
  if (s_temp_wii_root.empty() || !SConfig::GetInstance().bEnableMemcardSdWriting ||
      NetPlay::GetWiiSyncFS())
  {
    return;
  }

  const u64 title_id = SConfig::GetInstance().GetTitleID();

  IOS::HLE::EmulationKernel* ios = IOS::HLE::GetIOS();
  const auto session_save = WiiSave::MakeNandStorage(ios->GetFS().get(), title_id);

  const auto configured_fs = FS::MakeFileSystem(FS::Location::Configured);

  // FS won't write the save if the directory doesn't exist
  const std::string title_path = Common::GetTitleDataPath(title_id);
  if (!configured_fs->GetMetadata(IOS::PID_KERNEL, IOS::PID_KERNEL, title_path))
  {
    configured_fs->CreateDirectory(IOS::PID_KERNEL, IOS::PID_KERNEL, title_path, 0,
                                   {IOS::HLE::FS::Mode::ReadWrite, IOS::HLE::FS::Mode::ReadWrite,
                                    IOS::HLE::FS::Mode::ReadWrite});
  }

  const auto user_save = WiiSave::MakeNandStorage(configured_fs.get(), title_id);

  const std::string backup_path =
      File::GetUserPath(D_BACKUP_IDX) + StringFromFormat("/%016" PRIx64 ".bin", title_id);
  const auto backup_save = WiiSave::MakeDataBinStorage(&ios->GetIOSC(), backup_path, "w+b");

  // Backup the existing save just in case it's still needed.
  WiiSave::Copy(user_save.get(), backup_save.get());
  WiiSave::Copy(session_save.get(), user_save.get());
}
예제 #9
0
파일: prim.cpp 프로젝트: lvxejay/USD
TfTokenVector
UsdPrim::GetPropertyOrder() const
{
    TfTokenVector order;
    GetMetadata(SdfFieldKeys->PropertyOrder, &order);
    return order;
}
예제 #10
0
파일: prim.cpp 프로젝트: lvxejay/USD
TfTokenVector
UsdPrim::GetAppliedSchemas() const
{
    SdfTokenListOp appliedSchemas;
    GetMetadata(UsdTokens->apiSchemas, &appliedSchemas);
    TfTokenVector result;
    appliedSchemas.ApplyOperations(&result);
    return result;
}
예제 #11
0
const char *GDALGeorefPamDataset::GetMetadataItem( const char * pszName,
                                                   const char * pszDomain )
{
    if( pszDomain == NULL || EQUAL(pszDomain, "") || EQUAL(pszDomain, "RPC") )
    {
        return CSLFetchNameValue( GetMetadata(pszDomain), pszName );
    }
    return GDALPamDataset::GetMetadataItem(pszName, pszDomain);
}
예제 #12
0
void test_GetMetadata_normal()
{
    char *pkg = "./fossology-1.2.0-1.el5.i386.rpm";
    struct rpmpkginfo *pi;
    int predictValue = 1;
    int Result = GetMetadata(pkg, pi);
    printf("GetMetadata Result is:%d\n", Result);
    CU_ASSERT_EQUAL(Result, predictValue);
}
예제 #13
0
CPLErr GDALGeorefPamDataset::SetMetadataItem( const char * pszName,
                                            const char * pszValue,
                                            const char * pszDomain )
{
    if( m_bPAMLoaded && (pszDomain == NULL || EQUAL(pszDomain, "")) )
    {
        m_papszMainMD = CSLSetNameValue( GetMetadata(), pszName, pszValue );
    }
    return GDALPamDataset::SetMetadataItem(pszName, pszValue, pszDomain);
}
예제 #14
0
boost::optional<int> Info::GetRawApproximatePricing() const
{
  if (!IsSponsored())
    return {};

  int pricing;
  if (strings::to_int(GetMetadata().Get(feature::Metadata::FMD_PRICE_RATE), pricing))
    return pricing;

  return {};
}
예제 #15
0
/*----------------------------------------------------------------------
|   CUPnPRenderer::Announce
+---------------------------------------------------------------------*/
void
CUPnPRenderer::Announce(AnnouncementFlag flag, const char *sender, const char *message, const std::string& json_data)
{
    if (strcmp(sender, "xbmc") != 0)
      return;

    NPT_AutoLock lock(m_state);
    //PLT_Service *avt, *rct;
#if 1
#else
    if (flag == Player) {
        if (NPT_FAILED(FindServiceByType("urn:schemas-upnp-org:service:AVTransport:1", avt)))
            return;
        if (strcmp(message, "OnPlay") == 0) {
          avt->SetStateVariable("AVTransportURI", CApplication::getInstance().CurrentFile().c_str());
            avt->SetStateVariable("CurrentTrackURI", g_application.CurrentFile().c_str());

            NPT_String meta;
            if (NPT_SUCCEEDED(GetMetadata(meta))) {
                avt->SetStateVariable("CurrentTrackMetadata", meta);
                avt->SetStateVariable("AVTransportURIMetaData", meta);
            }

            avt->SetStateVariable("TransportPlaySpeed", NPT_String::FromInteger(data["speed"].asInteger()));
            avt->SetStateVariable("TransportState", "PLAYING");

            /* this could be a transition to next track, so clear next */
            avt->SetStateVariable("NextAVTransportURI", "");
            avt->SetStateVariable("NextAVTransportURIMetaData", "");
        }
        else if (strcmp(message, "OnPause") == 0) {
            avt->SetStateVariable("TransportPlaySpeed", NPT_String::FromInteger(data["speed"].asInteger()));
            avt->SetStateVariable("TransportState", "PAUSED_PLAYBACK");
        }
        else if (strcmp(message, "OnSpeedChanged") == 0) {
            avt->SetStateVariable("TransportPlaySpeed", NPT_String::FromInteger(data["speed"].asInteger()));
        }
    }
    else if (flag == Application && strcmp(message, "OnVolumeChanged") == 0) {
        if (NPT_FAILED(FindServiceByType("urn:schemas-upnp-org:service:RenderingControl:1", rct)))
            return;

        CStdString buffer;

        buffer.Format("%ld", data["volume"].asInteger());
        rct->SetStateVariable("Volume", buffer.c_str());

        buffer.Format("%ld", 256 * (data["volume"].asInteger() * 60 - 60) / 100);
        rct->SetStateVariable("VolumeDb", buffer.c_str());

        rct->SetStateVariable("Mute", data["muted"].asBoolean() ? "1" : "0");
    }
#endif
}
예제 #16
0
void IMovable::processImage(DrawType type)
{
    if (NODRAW)
        return;
    if (!GetSprite() || GetSprite()->Fail() || !GetMetadata())
        return;

    if (GetMetadata()->dirs >= 4)
    {
        DrawMain(helpers::dir_to_byond(dMove),            
            GetDrawX() + mob_position::get_shift_x(),
            GetDrawY() + mob_position::get_shift_y());
    }
    else
    {
        DrawMain(0,            
            GetDrawX() + mob_position::get_shift_x(),
            GetDrawY() + mob_position::get_shift_y());
    }
}
예제 #17
0
float Info::GetRatingRawValue() const
{
  if (!IsSponsored() && !ShouldShowUGC())
    return kIncorrectRating;

  // Only sponsored rating is stored in metadata. UGC rating will be stored in special section and will be ready soon.
  auto const rating = GetMetadata().Get(feature::Metadata::FMD_RATING);
  float raw;
  if (!strings::to_float(rating, raw))
    return kIncorrectRating;

  return raw;
}
예제 #18
0
bool compress_and_save(const std::shared_ptr<Spec> spec)
{
    HRESULT hr;

    hr = ::CoInitializeEx(NULL, COINIT_MULTITHREADED);
    if (FAILED(hr)) {
        printf(_T("  CoInitializeEx failed. ret = 0x%x\n"), hr);
        return false;
    }

    auto image = load_image_from_file(spec->input_name);
    if (!image) {
        return false;
    }

    bool with_ispc_texcomp = true;
    auto& meta = image->GetMetadata();
    if (!ISALIGN(meta.width, 4) || !ISALIGN(meta.height, 4) || is_dither_compression(spec)) {
        with_ispc_texcomp = false;
    }

    image = with_ispc_texcomp ? compress_with_ispc(std::move(image), spec) :
                                compress_with_dxtex(std::move(image), spec);

    int res = S_FALSE;
    if (image) {
        hr = DirectX::SaveToDDSFile(image->GetImages(), image->GetImageCount(), image->GetMetadata(),
                                    DirectX::DDS_FLAGS_NONE, spec->output_name.c_str());
        if (FAILED(hr)) {
            printf(_T("  DirectX::SaveToDDSFile failed. ret = 0x%x\n"), hr);
        }
        else {
            printf(_T("done.\n"));
            res = S_OK;
        }
    }
    ::CoUninitialize();
    return res == S_OK ? true : false;
}
예제 #19
0
string Info::GetApproximatePricing() const
{
  if (!IsSponsored())
    return string();

  int pricing;
  strings::to_int(GetMetadata().Get(feature::Metadata::FMD_PRICE_RATE), pricing);
  string result;
  for (auto i = 0; i < pricing; i++)
    result.append(kPricingSymbol);

  return result;
}
예제 #20
0
void FFmpegImportFileHandle::WriteMetadata(Tags *tags)
{
   tags->Clear();

   GetMetadata(tags, TAG_TITLE, "title");
   GetMetadata(tags, TAG_ARTIST, "author");
//   GetMetadata(tags, TAG_COPYRIGHT, "copyright");
   GetMetadata(tags, TAG_COMMENTS, "comment");
   GetMetadata(tags, TAG_ALBUM, "album");
   GetMetadata(tags, TAG_YEAR, "year");
   GetMetadata(tags, TAG_TRACK, "track");
   GetMetadata(tags, TAG_GENRE, "genre");
}
예제 #21
0
TfTokenVector
UsdMayaAdaptor::GetAppliedSchemas() const
{
    if (!*this) {
        return TfTokenVector();
    }

    VtValue appliedSchemas;
    if (GetMetadata(UsdTokens->apiSchemas, &appliedSchemas)) {
        TfTokenVector result;
        appliedSchemas.Get<SdfTokenListOp>().ApplyOperations(&result);
        return result;
    }

    return TfTokenVector();
}
예제 #22
0
string Info::GetRatingFormatted() const
{
  if (!IsSponsored())
    return string();

  auto const r = GetMetadata().Get(feature::Metadata::FMD_RATING);
  char const * rating = r.empty() ? kEmptyRatingSymbol : r.c_str();
  int const size = snprintf(nullptr, 0, m_localizedRatingString.c_str(), rating);
  if (size < 0)
  {
    LOG(LERROR, ("Incorrect size for string:", m_localizedRatingString, ", rating:", rating));
    return string();
  }

  vector<char> buf(size + 1);
  snprintf(buf.data(), buf.size(), m_localizedRatingString.c_str(), rating);
  return string(buf.begin(), buf.end());
}
예제 #23
0
const char *GDALOverviewDataset::GetMetadataItem( const char * pszName,
        const char * pszDomain )
{
    if (poOvrDS != NULL)
    {
        const char* pszValue = poOvrDS->GetMetadataItem(pszName, pszDomain);
        if( pszValue != NULL )
            return pszValue;
    }

    if( pszDomain != NULL && (EQUAL(pszDomain, "RPC") ||
                              EQUAL(pszDomain, "GEOLOCATION")) )
    {
        char** papszMD = GetMetadata(pszDomain);
        return CSLFetchNameValue(papszMD, pszName);
    }

    return poMainDS->GetMetadataItem(pszName, pszDomain);
}
void BlockCompilerFirstPass::Perform(State* s, Address startFromAddress, Decoder& decoder, std::unordered_map<Address, std::shared_ptr<SimulationUnit>>* simulationUnitTable, BlockCompilerSimulatorEngine& simulatorEngine)
{
	s_ = s;
	simulationUnitTable_ = simulationUnitTable;

	discoveredStartAddresses_.clear();
	while (toProcessStartAddresses_.empty() == false)
		toProcessStartAddresses_.pop();

	AddToDiscoveredQueue_(startFromAddress);

	while (toProcessStartAddresses_.empty() == false)
	{
		address_ = toProcessStartAddresses_.front();
		toProcessStartAddresses_.pop();

		simulatorEngine.CreateInterpretedBlockStart(address_);
		
		isEndOfBasicBlockFound_ = false;
		while (isEndOfBasicBlockFound_ == false)
		{
			auto operation = decoder.Decode(address_);
			if (operation == nullptr)
			{
				isEndOfBasicBlockFound_ = true;
			}
			else
			{
				int length = operation->GetMetadata().GetLengthInBytes();
				for (int i = 0; i < length; ++i)
					s_->m[address_ + (Address)i].isCode = true;

				auto outgoingEdges = operation->GetOutgoingEdges();
				outgoingEdges->Accept(*this);
			}
		}
	}
}
예제 #25
0
void IndexTuner::DropIndexes(storage::DataTable* table) {

  oid_t index_count = table->GetIndexCount();

  // Go over indices
  oid_t index_itr;
  for (index_itr = 0; index_itr < index_count; index_itr++) {

    auto index = table->GetIndex(index_itr);
    auto index_metadata = index->GetMetadata();
    auto average_index_utility = index_metadata->GetUtility();
    auto index_oid = index->GetOid();

    // Check if index utility below threshold and drop if needed
    if (average_index_utility < index_utility_threshold) {
      LOG_TRACE("Dropping index : %s", index_metadata->GetInfo().c_str());
      table->DropIndexWithOid(index_oid);

      // Update index count
      index_count = table->GetIndexCount();
    }
  }
}
예제 #26
0
void PrintIndexInformation(storage::DataTable* table) {

  oid_t index_count = table->GetIndexCount();
  auto table_tilegroup_count = table->GetTileGroupCount();

  for (oid_t index_itr = 0; index_itr < index_count; index_itr++) {

    // Get index
    auto index = table->GetIndex(index_itr);
    UNUSED_ATTRIBUTE auto index_metadata = index->GetMetadata();

    auto indexed_tile_group_offset = index->GetIndexedTileGroupOff();

    // Get percentage completion
    auto fraction = 0.0;
    if (table_tilegroup_count != 0) {
      fraction = indexed_tile_group_offset / table_tilegroup_count;
      fraction *= 100;
    }

    LOG_INFO("%s %.1f%%", index_metadata->GetInfo().c_str(), fraction);
  }
}
예제 #27
0
void GameHandler::UpdateGameDB(GameHandler *handler)
{
    int counter = 0;
    MSqlQuery query(MSqlQuery::InitCon());

    QString message = QObject::tr("Updating %1(%2) ROM database")
                                    .arg(handler->SystemName())
                                    .arg(handler->GameType());

    CreateProgress(message);

    if (m_progressDlg)
        m_progressDlg->SetTotal(m_GameMap.size());

    GameScanMap::Iterator iter;

    QString GameName, Genre, Country, CRC32, Year, Plot;
    QString Publisher, Version, Fanart, Boxart, ScreenShot;
    QString thequery, queryvalues;

    int removalprompt = gCoreContext->GetSetting("GameRemovalPrompt").toInt();
    int indepth = gCoreContext->GetSetting("GameDeepScan").toInt();
    QString screenShotPath = gCoreContext->GetSetting("mythgame.screenshotdir");

    for (iter = m_GameMap.begin(); iter != m_GameMap.end(); ++iter)
    {

        if (iter.value().FoundLoc() == inFileSystem)
        {
            if (indepth)
            {
                GetMetadata(handler, iter.value().RomFullPath(), &Genre, &Year, &Country, &CRC32, &GameName,
                            &Plot, &Publisher, &Version, &Fanart, &Boxart);
            }
            else
            {
                Genre = QObject::tr("Unknown") + handler->GameType();
                Country = QObject::tr("Unknown");
                CRC32.clear();
                Year = QObject::tr("19xx");
                GameName = QObject::tr("Unknown");
                Plot = QObject::tr("Unknown");
                Publisher = QObject::tr("Unknown");
                Version = QObject::tr("0");
                Fanart.clear();
                Boxart.clear();
            }

            if (GameName == QObject::tr("Unknown"))
                GameName = iter.value().GameName();

            int suffixPos = iter.value().Rom().lastIndexOf(QChar('.'));
            QString baseName = iter.value().Rom();

            if (suffixPos > 0)
                baseName = iter.value().Rom().left(suffixPos);

            baseName = screenShotPath + "/" + baseName;

            if (QFile(baseName + ".png").exists())
                ScreenShot = baseName + ".png";
            else if (QFile(baseName + ".jpg").exists())
                ScreenShot = baseName + ".jpg";
            else if (QFile(baseName + ".gif").exists())
                ScreenShot = baseName + ".gif";
            else
                ScreenShot.clear();

#if 0
            LOG(VB_GENERAL, LOG_INFO, QString("file %1 - genre %2 ")
                    .arg(iter.data().Rom()).arg(Genre));
            LOG(VB_GENERAL, LOG_INFO, QString("screenshot %1").arg(ScreenShot));
#endif

            query.prepare("INSERT INTO gamemetadata "
                          "(system, romname, gamename, genre, year, gametype, "
                          "rompath, country, crc_value, diskcount, display, plot, "
                          "publisher, version, fanart, boxart, screenshot) "
                          "VALUES (:SYSTEM, :ROMNAME, :GAMENAME, :GENRE, :YEAR, "
                          ":GAMETYPE, :ROMPATH, :COUNTRY, :CRC32, '1', '1', :PLOT, :PUBLISHER, :VERSION, "
                          ":FANART, :BOXART, :SCREENSHOT)");

            query.bindValue(":SYSTEM",handler->SystemName());
            query.bindValue(":ROMNAME",iter.value().Rom());
            query.bindValue(":GAMENAME",GameName);
            query.bindValue(":GENRE",Genre);
            query.bindValue(":YEAR",Year);
            query.bindValue(":GAMETYPE",handler->GameType());
            query.bindValue(":ROMPATH",iter.value().RomPath());
            query.bindValue(":COUNTRY",Country);
            query.bindValue(":CRC32", CRC32);
            query.bindValue(":PLOT", Plot);
            query.bindValue(":PUBLISHER", Publisher);
            query.bindValue(":VERSION", Version);
            query.bindValue(":FANART", Fanart);
            query.bindValue(":BOXART", Boxart);
            query.bindValue(":SCREENSHOT", ScreenShot);

            if (!query.exec())
                MythDB::DBError("GameHandler::UpdateGameDB - "
                                "insert gamemetadata", query);
        }
        else if ((iter.value().FoundLoc() == inDatabase) && (removalprompt))
        {

            promptForRemoval( iter.value() );
        }

        if (m_progressDlg)
            m_progressDlg->SetProgress(++counter);
    }

    if (m_progressDlg)
    {
        m_progressDlg->Close();
        m_progressDlg = NULL;
}
}
예제 #28
0
void InitializeLibrary ()
{
    char *p;
    gchar **dirs;
    GDir *dir;
    gchar *fname, *path, *docname, *dirname, *homedir;
    int i, fp;
    DocInfo *docinfo;

    if (PluckerDocs != NULL)
        return;

    homedir = (char *) g_getenv ("HOME");

    PluckerDocs = g_tree_new ((GCompareFunc) strcmp);

    p = (char *) g_getenv ("PLUCKERPATH");
    if (p == NULL)
        p = plkr_GetConfigString (NULL, "pluckerpath", NULL);
    if (p == NULL)
        p = ".";

    if (p != NULL) {

        dirs = g_strsplit (p, ":", 0);

        for (i = 0; dirs[i] != NULL; i++) {

            dirname = dirs[i];

            /* handle ~ characters */
            if (dirname[0] == '~' && dirname[1] == G_DIR_SEPARATOR
                && homedir) {
                dirname =
                    g_strjoin (G_DIR_SEPARATOR_S, homedir, dirs[i] + 2,
                               NULL);
            }

            if (!g_file_test (dirname, G_FILE_TEST_EXISTS)) {
                fprintf (stderr,
                         "Non-existent path/file on PLUCKERPATH:  %s\n",
                         dirname);
                continue;
            }
            else if (g_file_test (dirname, G_FILE_TEST_IS_DIR)) {

                if (dir = g_dir_open (dirname, 0, NULL)) {

                    /* fprintf (stderr, "Looking in directory %s...\n", dirname); */

                    while ((fname =
                            (char *) g_dir_read_name (dir)) != NULL) {

                        if (HasSuffix (fname, ".plkr") ||
                            HasSuffix (fname, ".pdb")) {

                            path =
                                g_strjoin (G_DIR_SEPARATOR_S, dirname,
                                           fname, NULL);
                            fp = open (path, O_RDONLY);
                            if ((docname = IsPlucker (fp)) != NULL) {
                                /* OK, it's a plucker document, index it by document name */
                                /* fprintf (stderr, "    adding '%s' (%s)\n", filebuf, fname); */
                                docinfo =
                                    (DocInfo *) malloc (sizeof (DocInfo));
                                docinfo->name = docname;
                                docinfo->path = path;
                                GetMetadata (fp, &docinfo->nrecords,
                                              &docinfo->categories,
                                              &docinfo->charset,
                                              &docinfo->title,
                                              &docinfo->author,
                                              &docinfo->pubtime);
                                g_tree_insert (PluckerDocs, docinfo->name,
                                               docinfo);
                                path = NULL;
                            }
                            close (fp);
                            if (path)
                                free (path);
                        }
                    }

                    g_dir_close (dir);
                }
            }
            else if (g_file_test (dirname, G_FILE_TEST_EXISTS)) {
                fp = open (dirname, O_RDONLY);
                if ((docname = IsPlucker (fp)) != NULL) {
                    /* OK, it's a plucker document, index it by document name */
                    /* fprintf (stderr, "    adding '%s' (%s)\n", filebuf, fname); */
                    docinfo = (DocInfo *) malloc (sizeof (DocInfo));
                    docinfo->name = docname;
                    docinfo->path = g_strdup (dirname);
                    GetMetadata (fp, &docinfo->nrecords,
                                  &docinfo->categories,
                                  &docinfo->charset,
                                  &docinfo->title,
                                  &docinfo->author, &docinfo->pubtime);
                    g_tree_insert (PluckerDocs, docinfo->name, docinfo);
                }
                close (fp);
            }
            else {
                fprintf (stderr,
                         "Non-Plucker, non-directory element on PLUCKERPATH:  %s\n",
                         dirname);
            }

            if (dirname != dirs[i])
                free (dirname);
        }

        g_strfreev (dirs);
    }
}
예제 #29
0
int ExportFLAC::Export(AudacityProject *project,
                        int numChannels,
                        const wxString &fName,
                        bool selectionOnly,
                        double t0,
                        double t1,
                        MixerSpec *mixerSpec,
                        const Tags *metadata,
                        int WXUNUSED(subformat))
{
   double    rate    = project->GetRate();
   TrackList *tracks = project->GetTracks();

   wxLogNull logNo;            // temporarily disable wxWidgets error messages
   int updateResult = eProgressSuccess;

   int levelPref;
   gPrefs->Read(wxT("/FileFormats/FLACLevel"), &levelPref, 5);

   wxString bitDepthPref =
      gPrefs->Read(wxT("/FileFormats/FLACBitDepth"), wxT("16"));

   FLAC::Encoder::File encoder;

#ifdef LEGACY_FLAC
   encoder.set_filename(OSOUTPUT(fName));
#endif
   encoder.set_channels(numChannels);
   encoder.set_sample_rate(lrint(rate));

   // See note in GetMetadata() about a bug in libflac++ 1.1.2
   if (!GetMetadata(project, metadata)) {
      return false;
   }

   if (mMetadata) {
      encoder.set_metadata(&mMetadata, 1);
   }

   sampleFormat format;
   if (bitDepthPref == wxT("24")) {
      format = int24Sample;
      encoder.set_bits_per_sample(24);
   } else { //convert float to 16 bits
      format = int16Sample;
      encoder.set_bits_per_sample(16);
   }

   // Duplicate the flac command line compression levels
   if (levelPref < 0 || levelPref > 8) {
      levelPref = 5;
   }
   encoder.set_do_exhaustive_model_search(flacLevels[levelPref].do_exhaustive_model_search);
   encoder.set_do_escape_coding(flacLevels[levelPref].do_escape_coding);
   if (numChannels != 2) {
      encoder.set_do_mid_side_stereo(false);
      encoder.set_loose_mid_side_stereo(false);
   }
   else {
      encoder.set_do_mid_side_stereo(flacLevels[levelPref].do_mid_side_stereo);
      encoder.set_loose_mid_side_stereo(flacLevels[levelPref].loose_mid_side_stereo);
   }
   encoder.set_qlp_coeff_precision(flacLevels[levelPref].qlp_coeff_precision);
   encoder.set_min_residual_partition_order(flacLevels[levelPref].min_residual_partition_order);
   encoder.set_max_residual_partition_order(flacLevels[levelPref].max_residual_partition_order);
   encoder.set_rice_parameter_search_dist(flacLevels[levelPref].rice_parameter_search_dist);
   encoder.set_max_lpc_order(flacLevels[levelPref].max_lpc_order);

#ifdef LEGACY_FLAC
   encoder.init();
#else
   wxFFile f;     // will be closed when it goes out of scope
   if (!f.Open(fName, wxT("w+b"))) {
      wxMessageBox(wxString::Format(_("FLAC export couldn't open %s"), fName.c_str()));
      return false;
   }

   // Even though there is an init() method that takes a filename, use the one that
   // takes a file handle because wxWidgets can open a file with a Unicode name and
   // libflac can't (under Windows).
   int status = encoder.init(f.fp());
   if (status != FLAC__STREAM_ENCODER_INIT_STATUS_OK) {
      wxMessageBox(wxString::Format(_("FLAC encoder failed to initialize\nStatus: %d"), status));
      return false;
   }
#endif

   if (mMetadata) {
      ::FLAC__metadata_object_delete(mMetadata);
   }

   int numWaveTracks;
   WaveTrack **waveTracks;
   tracks->GetWaveTracks(selectionOnly, &numWaveTracks, &waveTracks);
   Mixer *mixer = CreateMixer(numWaveTracks, waveTracks,
                            tracks->GetTimeTrack(),
                            t0, t1,
                            numChannels, SAMPLES_PER_RUN, false,
                            rate, format, true, mixerSpec);
   delete [] waveTracks;

   int i, j;
   FLAC__int32 **tmpsmplbuf = new FLAC__int32*[numChannels];
   for (i = 0; i < numChannels; i++) {
      tmpsmplbuf[i] = (FLAC__int32 *) calloc(SAMPLES_PER_RUN, sizeof(FLAC__int32));
   }

   {
      ProgressDialog progress(wxFileName(fName).GetName(),
         selectionOnly ?
         _("Exporting the selected audio as FLAC") :
         _("Exporting the entire project as FLAC"));

      while (updateResult == eProgressSuccess) {
         sampleCount samplesThisRun = mixer->Process(SAMPLES_PER_RUN);
         if (samplesThisRun == 0) { //stop encoding
            break;
         }
         else {
            for (i = 0; i < numChannels; i++) {
               samplePtr mixed = mixer->GetBuffer(i);
               if (format == int24Sample) {
                  for (j = 0; j < samplesThisRun; j++) {
                     tmpsmplbuf[i][j] = ((int *)mixed)[j];
                  }
               }
               else {
                  for (j = 0; j < samplesThisRun; j++) {
                     tmpsmplbuf[i][j] = ((short *)mixed)[j];
                  }
               }
            }
            encoder.process(tmpsmplbuf, samplesThisRun);
         }
         updateResult = progress.Update(mixer->MixGetCurrentTime() - t0, t1 - t0);
      }
      f.Detach(); // libflac closes the file
      encoder.finish();
   }

   for (i = 0; i < numChannels; i++) {
      free(tmpsmplbuf[i]);
   }
   delete mixer;

   delete[] tmpsmplbuf;

   return updateResult;
}
예제 #30
0
CPLErr GDALPamRasterBand::CloneInfo( GDALRasterBand *poSrcBand, 
                                     int nCloneFlags )

{
    int bOnlyIfMissing = nCloneFlags & GCIF_ONLY_IF_MISSING;
    int bSuccess;
    int nSavedMOFlags = GetMOFlags();

    PamInitialize();

/* -------------------------------------------------------------------- */
/*      Supress NotImplemented error messages - mainly needed if PAM    */
/*      disabled.                                                       */
/* -------------------------------------------------------------------- */
    SetMOFlags( nSavedMOFlags | GMO_IGNORE_UNIMPLEMENTED );

/* -------------------------------------------------------------------- */
/*      Metadata                                                        */
/* -------------------------------------------------------------------- */
    if( nCloneFlags & GCIF_BAND_METADATA )
    {
        if( poSrcBand->GetMetadata() != NULL )
        {
            if( !bOnlyIfMissing 
             || CSLCount(GetMetadata()) != CSLCount(poSrcBand->GetMetadata()) )
            {
                SetMetadata( poSrcBand->GetMetadata() );
            }
        }
    }

/* -------------------------------------------------------------------- */
/*      Band description.                                               */
/* -------------------------------------------------------------------- */
    if( nCloneFlags & GCIF_BAND_DESCRIPTION )
    {
        if( strlen(poSrcBand->GetDescription()) > 0 )
        {
            if( !bOnlyIfMissing || strlen(GetDescription()) == 0 )
                GDALPamRasterBand::SetDescription( poSrcBand->GetDescription());
        }
    }

/* -------------------------------------------------------------------- */
/*      NODATA                                                          */
/* -------------------------------------------------------------------- */
    if( nCloneFlags & GCIF_NODATA )
    {
        double dfNoData = poSrcBand->GetNoDataValue( &bSuccess );
        
        if( bSuccess )
        {
            if( !bOnlyIfMissing 
                || GetNoDataValue( &bSuccess ) != dfNoData 
                || !bSuccess )
                GDALPamRasterBand::SetNoDataValue( dfNoData );
        }
    }

/* -------------------------------------------------------------------- */
/*      Offset/scale                                                    */
/* -------------------------------------------------------------------- */
    if( nCloneFlags & GCIF_SCALEOFFSET )
    {
        double dfOffset = poSrcBand->GetOffset( &bSuccess );
        
        if( bSuccess )
        {
            if( !bOnlyIfMissing || GetOffset() != dfOffset )
                GDALPamRasterBand::SetOffset( dfOffset );
        }

        double dfScale = poSrcBand->GetScale( &bSuccess );
        
        if( bSuccess )
        {
            if( !bOnlyIfMissing || GetScale() != dfScale )
                GDALPamRasterBand::SetScale( dfScale );
        }
    }

/* -------------------------------------------------------------------- */
/*      Unittype.                                                       */
/* -------------------------------------------------------------------- */
    if( nCloneFlags & GCIF_UNITTYPE )
    {
        if( strlen(poSrcBand->GetUnitType()) > 0 )
        {
            if( !bOnlyIfMissing 
                || !EQUAL(GetUnitType(),poSrcBand->GetUnitType()) )
            {
                GDALPamRasterBand::SetUnitType( poSrcBand->GetUnitType() );
            }
        }
    }

/* -------------------------------------------------------------------- */
/*      ColorInterp                                                     */
/* -------------------------------------------------------------------- */
    if( nCloneFlags & GCIF_COLORINTERP )
    {
        if( poSrcBand->GetColorInterpretation() != GCI_Undefined )
        {
            if( !bOnlyIfMissing
                || poSrcBand->GetColorInterpretation() 
                != GetColorInterpretation() )
                GDALPamRasterBand::SetColorInterpretation( 
                    poSrcBand->GetColorInterpretation() );
        }
    }

/* -------------------------------------------------------------------- */
/*      color table.                                                    */
/* -------------------------------------------------------------------- */
    if( nCloneFlags & GCIF_COLORTABLE )
    {
        if( poSrcBand->GetColorTable() != NULL )
        {
            if( !bOnlyIfMissing || GetColorTable() == NULL )
            {
                GDALPamRasterBand::SetColorTable( 
                    poSrcBand->GetColorTable() );
            }
        }
    }

/* -------------------------------------------------------------------- */
/*      Raster Attribute Table.                                         */
/* -------------------------------------------------------------------- */
    if( nCloneFlags & GCIF_RAT )
    {
        const GDALRasterAttributeTable *poRAT = poSrcBand->GetDefaultRAT();

        if( poRAT != NULL )
        {
            if( !bOnlyIfMissing || GetDefaultRAT() == NULL )
            {
                GDALPamRasterBand::SetDefaultRAT( poRAT );
            }
        }
    }

/* -------------------------------------------------------------------- */
/*      Restore MO flags.                                               */
/* -------------------------------------------------------------------- */
    SetMOFlags( nSavedMOFlags );

    return CE_None;
}