diff --git a/trunk/ConsoleDataMigration/sources/ConsoleRestore/TitleDownloader.cpp b/trunk/ConsoleDataMigration/sources/ConsoleRestore/TitleDownloader.cpp index 599135d..148e326 100644 --- a/trunk/ConsoleDataMigration/sources/ConsoleRestore/TitleDownloader.cpp +++ b/trunk/ConsoleDataMigration/sources/ConsoleRestore/TitleDownloader.cpp @@ -18,10 +18,12 @@ #include #include +#include "FileName.h" #include "CommonLogger.h" #include "HeapManager.h" #include "TitleDownloader.h" #include "Shop.h" +#include "SdReaderWriter.h" namespace @@ -193,37 +195,44 @@ void TitleDownloader::Start() nn::Result TitleDownloader::ListUp() { - // TODO: ファイルリストを読み出してリスト生成 - const u32 AM_TICKET_MAX = 7168; + COMMON_LOGGER("Export TwlTitle List.\n"); - s32 personalizedTicketNum; + nn::Result result; + size_t heapSize = common::HeapManager::GetHeap()->GetAllocatableSize(); + char* titleListBuf = reinterpret_cast (common::HeapManager::GetHeap()->Allocate(heapSize)); - nn::am::TicketInfo *ticketInfoBuffer = - reinterpret_cast (common::HeapManager::GetHeap()->Allocate( - sizeof(nn::am::TicketInfo) * AM_TICKET_MAX)); - if(ticketInfoBuffer == NULL) + size_t readSize = 0; + if (titleListBuf != NULL) + { + common::SdReaderWriter sdReader; + m_Result = sdReader.ReadBufWithCmac(common::TWL_TITLELIST_PATHNAME, titleListBuf, heapSize, &readSize); + COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(m_Result); + + u32 listHead = 0; + for (u32 i = 0; i < readSize; i++) + { + if (titleListBuf[i] == '\n') + { + char ProgramIdStr[32]; + char *error; + std::memcpy(ProgramIdStr, &titleListBuf[listHead], i - listHead); + m_ProgramIdList[m_TwlTiteNum] = std::strtoull(ProgramIdStr, &error, 16); + m_TwlTiteNum++; + NN_LOG("%016llx\n", m_ProgramIdList[m_TwlTiteNum - 1]); + + listHead = i + 1; + } + } + + common::HeapManager::GetHeap()->Free(titleListBuf); + } + else { - COMMON_LOGGER("Failed Allocate Heap!!\n"); m_Result = nn::Result(nn::Result::LEVEL_FATAL, nn::Result::SUMMARY_OUT_OF_RESOURCE, nn::Result::MODULE_COMMON, nn::Result::DESCRIPTION_OUT_OF_MEMORY); - return m_Result; - } - - m_Result=nn::am::GetPersonalizedTicketInfoList(&personalizedTicketNum, ticketInfoBuffer, AM_TICKET_MAX); // 全部 - COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(m_Result); - - for (u32 i = 0; i < personalizedTicketNum; i++) - { - if (nn::CTR::IsTwlApp(ticketInfoBuffer[i].titleId)) - { - m_ProgramIdList[m_TwlTiteNum] = ticketInfoBuffer[i].titleId; - m_TwlTiteNum++; - NN_LOG("%016llx\n", m_ProgramIdList[m_TwlTiteNum - 1]); - } } return m_Result; } - } diff --git a/trunk/ConsoleDataMigration/sources/tests/ConsoleRestore/OMakefile b/trunk/ConsoleDataMigration/sources/tests/ConsoleRestore/OMakefile new file mode 100644 index 0000000..19fef5c --- /dev/null +++ b/trunk/ConsoleDataMigration/sources/tests/ConsoleRestore/OMakefile @@ -0,0 +1,20 @@ +#!/usr/bin/env omake +#---------------------------------------------------------------------------- +# Project: Horizon +# File: OMakefile +# +# Copyright (C)2009 Nintendo Co., Ltd. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Rev$ +#---------------------------------------------------------------------------- + +if $(IsTestBuild) + .SUBDIRS: TitleDownloader + +DefineDefaultRules() diff --git a/trunk/ConsoleDataMigration/sources/tests/ConsoleRestore/TitleDownloader/OMakefile b/trunk/ConsoleDataMigration/sources/tests/ConsoleRestore/TitleDownloader/OMakefile new file mode 100644 index 0000000..30f3b2d --- /dev/null +++ b/trunk/ConsoleDataMigration/sources/tests/ConsoleRestore/TitleDownloader/OMakefile @@ -0,0 +1,65 @@ +#!/usr/bin/env omake +#---------------------------------------------------------------------------- +# Project: Horizon +# File: OMakefile +# +# Copyright (C)2009 Nintendo Co., Ltd. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Rev$ +#---------------------------------------------------------------------------- +SUPPORTED_TARGETS = CTR-*.Process.MPCore.* + +include $(makePlatformDefsPath tests) + +SAMPLED_DEMOS_COMMON_INCLUDE_DIR = $(dir $(HORIZON_ROOT)/../CTR/SampleDemos/common/include) +INCLUDES += $(SAMPLED_DEMOS_COMMON_INCLUDE_DIR) \ + ../../../common \ + ../../../ConsoleRestore \ + + + +TEST_COMMON_SOURCES[] = + ../../../ConsoleRestore/TitleDownloader.cpp + ../../../ConsoleRestore/Shop.cpp + ../../../common/Util.cpp + ../../../common/HeapManager.cpp + ../../../common/SdLogger.cpp + ../../../common/LogConsole.cpp + ../../../common/CommonLogger.cpp + ../../../common/SdMountManager.cpp + ../../../common/PlayHistoryManager.cpp + ../../../common/VersionDetect.cpp + ../../../common/HardwareStateManager.cpp + ../../../common/FileTransfer.cpp + ../../../common/SdReaderWriter.cpp + + +SOURCES_TEST[] = test_TitleDownloader.cpp + +ROMFS_ROOT = ../../../common/romfiles + +TEST_ENVIRONMENT_PROCESSLIST = true +TEST_ENVIRONMENT_EMUMEM = true + +LIBS += libnn_test \ + libnn_mcu \ + libnn_ps \ + libnn_am \ + lib_demo \ + libnn_nim \ + + +ROM_SPEC_FILE = ../../../ConsoleRestore/ConsoleRestore.rsf +DESCRIPTOR = $(HORIZON_ROOT)/resources/specfiles/_private/RepairTool.desc + + +include $(makePlatformDefsPath build.tests) + + +tests: $(TEST_TARGETS) diff --git a/trunk/ConsoleDataMigration/sources/tests/OMakefile b/trunk/ConsoleDataMigration/sources/tests/OMakefile index d25ecc9..970e68a 100644 --- a/trunk/ConsoleDataMigration/sources/tests/OMakefile +++ b/trunk/ConsoleDataMigration/sources/tests/OMakefile @@ -15,6 +15,6 @@ #---------------------------------------------------------------------------- if $(IsTestBuild) - .SUBDIRS: common ConsoleBackup + .SUBDIRS: common ConsoleBackup ConsoleRestore DefineDefaultRules()