[FS] Implement GetFileSize [PTM] Stub step functions

This commit is contained in:
wheremyfoodat 2023-01-23 03:24:13 +02:00
parent 49dcc25795
commit e052c16a36
5 changed files with 76 additions and 7 deletions

View file

@ -75,17 +75,17 @@ public:
return write(data, count, sizeof(std::uint8_t));
}
std::uint64_t size() {
if (!isOpen()) return 0;
std::optional<std::uint64_t> size() {
if (!isOpen()) return {};
std::uint64_t pos = ftello(handle);
if (fseeko(handle, 0, SEEK_END) != 0) {
return 0;
return {};
}
std::uint64_t size = ftello(handle);
if ((size != pos) && (fseeko(handle, pos, SEEK_SET) != 0)) {
return 0;
return {};
}
return size;

View file

@ -120,6 +120,7 @@ private:
void handleFileOperation(u32 messagePointer, Handle file);
void closeFile(u32 messagePointer, Handle file);
void readFile(u32 messagePointer, Handle file);
void writeFile(u32 messagePointer, Handle file);
void getFileSize(u32 messagePointer, Handle file);
public:

View file

@ -10,6 +10,8 @@ class PTMService {
MAKE_LOG_FUNCTION(log, ptmLogger)
// Service commands
void getStepHistory(u32 messagePointer);
void getTotalStepCount(u32 messagePointer);
public:
PTMService(Memory& mem) : mem(mem) {}