mirror of
https://github.com/intrepidcs/libicsneo.git
synced 2026-08-05 01:18:36 +02:00
Optional: nonstd to std
This commit is contained in:
+4
-4
@@ -8,7 +8,7 @@ using namespace icsneo;
|
||||
|
||||
// The FAT driver can only be accessed by one caller at a time, since it relies on globals
|
||||
static std::mutex fatDriverMutex;
|
||||
static std::function< optional<uint64_t>(uint64_t pos, uint8_t* into, uint64_t amount) > diskReadFn;
|
||||
static std::function< std::optional<uint64_t>(uint64_t pos, uint8_t* into, uint64_t amount) > diskReadFn;
|
||||
|
||||
extern "C" DRESULT disk_read(BYTE, BYTE* buff, LBA_t sector, UINT count) {
|
||||
static_assert(Disk::SectorSize == 512, "FatFs expects 512 byte sectors");
|
||||
@@ -32,17 +32,17 @@ static uint64_t ClusterToSector(const FATFS& fs, DWORD cluster) {
|
||||
return fs.database + (LBA_t)fs.csize * (cluster - 2);
|
||||
}
|
||||
|
||||
optional<uint64_t> Disk::FindVSAInFAT(std::function< optional<uint64_t>(uint64_t pos, uint8_t* into, uint64_t amount) > diskRead) {
|
||||
std::optional<uint64_t> Disk::FindVSAInFAT(std::function< std::optional<uint64_t>(uint64_t pos, uint8_t* into, uint64_t amount) > diskRead) {
|
||||
std::lock_guard<std::mutex> lk(fatDriverMutex);
|
||||
diskReadFn = diskRead;
|
||||
|
||||
FATFS fs = {};
|
||||
if (f_mount(&fs, (const TCHAR*)_TEXT(""), 0) != FR_OK)
|
||||
return nullopt;
|
||||
return std::nullopt;
|
||||
|
||||
FIL logData = {};
|
||||
if (f_open(&logData, (const TCHAR*)_TEXT("0:\\LOG_DATA.VSA"), FA_READ) != FR_OK)
|
||||
return nullopt;
|
||||
return std::nullopt;
|
||||
|
||||
return ClusterToSector(fs, logData.obj.sclust) * uint64_t(Disk::SectorSize);
|
||||
}
|
||||
Reference in New Issue
Block a user