You've already forked pico-loader
mirror of
https://github.com/LNH-team/pico-loader.git
synced 2026-01-09 16:28:35 -08:00
Initial commit
This commit is contained in:
24
arm7/source/loader/ApListFactory.cpp
Normal file
24
arm7/source/loader/ApListFactory.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
#include "common.h"
|
||||
#include "ApListFactory.h"
|
||||
|
||||
ApList* ApListFactory::CreateFromFile(const TCHAR *path)
|
||||
{
|
||||
FIL file;
|
||||
if (f_open(&file, path, FA_OPEN_EXISTING | FA_READ) != FR_OK)
|
||||
{
|
||||
LOG_FATAL("Failed to open ap list file\n");
|
||||
return nullptr;
|
||||
}
|
||||
const u32 entryCount = f_size(&file) / sizeof(ApListEntry);
|
||||
auto entries = std::make_unique_for_overwrite<ApListEntry[]>(entryCount);
|
||||
UINT bytesRead = 0;
|
||||
FRESULT result = f_read(&file, entries.get(), entryCount * sizeof(ApListEntry), &bytesRead);
|
||||
if (result != FR_OK || bytesRead != entryCount * sizeof(ApListEntry))
|
||||
{
|
||||
LOG_FATAL("Failed to read ap list file\n");
|
||||
return nullptr;
|
||||
}
|
||||
f_close(&file);
|
||||
|
||||
return new ApList(std::move(entries), entryCount);
|
||||
}
|
||||
Reference in New Issue
Block a user