| 1 | #pragma once |
| 2 | |
| 3 | #include <nn/fs/fs_types.h> |
| 4 | |
| 5 | namespace nn::fs { |
| 6 | |
| 7 | struct FileTimeStamp { |
| 8 | u64 mTime1; // date created |
| 9 | u64 mTime2; // sometimes is identical to above |
| 10 | u64 mTime3; // looks like the date the file was created without exact time? |
| 11 | bool unkBool; |
| 12 | }; |
| 13 | |
| 14 | /* |
| 15 | Create a file. |
| 16 | path: Path where to create the path. |
| 17 | size: Size of the file to create. |
| 18 | */ |
| 19 | Result CreateFile(const char* path, s64 size); |
| 20 | |
| 21 | /* |
| 22 | Open a file. |
| 23 | handleOut: Output for handle representing opened file. |
| 24 | path: File path to open. |
| 25 | mode: Mode to open file. See OpenMode. |
| 26 | */ |
| 27 | Result OpenFile(FileHandle* handleOut, const char* path, int mode); |
| 28 | |
| 29 | /* |
| 30 | Close a file. |
| 31 | handle: Handle to file to be closed. |
| 32 | */ |
| 33 | void CloseFile(FileHandle handle); |
| 34 | |
| 35 | /* |
| 36 | Read file at a location. |
| 37 | handle: Handle representing file to be read. |
| 38 | position: Position within the file to be read. |
| 39 | size: How many bytes to read from file. |
| 40 | */ |
| 41 | Result ReadFile(FileHandle handle, long position, void* buffer, ulong size); |
| 42 | |
| 43 | /* |
| 44 | Read file at a location, with additional options. |
| 45 | handle: Handle representing file to be read. |
| 46 | position: Position within the file to be read. |
| 47 | size: How many bytes to read from file. |
| 48 | option: Additional options for reading, see ReadOption. |
| 49 | */ |
| 50 | Result ReadFile(FileHandle handle, long position, void* buffer, const ReadOption& option); |
| 51 | |
| 52 | /* |
| 53 | Read file at a location, with an output amount of bytes read. |
| 54 | bytesRead: How many bytes were actually read. |
| 55 | handle: Handle representing file to be read. |
| 56 | position: Position within the file to be read. |
| 57 | size: How many bytes to read from file. |
| 58 | */ |
| 59 | Result ReadFile(ulong* bytesRead, FileHandle handle, long position, void* buffer); |
| 60 | |
| 61 | /* |
| 62 | Read file at a location, with an output amount of bytes read, and additional options. |
| 63 | bytesRead: How many bytes were actually read. |
| 64 | handle: Handle representing file to be read. |
| 65 | position: Position within the file to be read. |
| 66 | size: How many bytes to read from file. |
| 67 | option: Additional options for reading, see ReadOption. |
| 68 | */ |
| 69 | Result ReadFile(ulong* bytesRead, FileHandle handle, long position, void* buffer, |
| 70 | const ReadOption& option); |
| 71 | |
| 72 | Result ReadFile(u64* outSize, FileHandle handle, s64 offset, void* buffer, u64 bufferSize, |
| 73 | const ReadOption& option); |
| 74 | Result ReadFile(u64* outSize, FileHandle handle, s64 offset, void* buffer, u64 bufferSize); |
| 75 | Result ReadFile(FileHandle handle, s64 offset, void* buffer, u64 bufferSize, |
| 76 | const ReadOption& option); |
| 77 | |
| 78 | /* |
| 79 | Gets the size of the file. |
| 80 | size: File size. |
| 81 | handle: Handle representing file to check. |
| 82 | */ |
| 83 | Result GetFileSize(long* size, nn::fs::FileHandle handle); |
| 84 | |
| 85 | /* |
| 86 | Writes to a file. |
| 87 | handle: Handle representing file to write to. |
| 88 | position: Position within the file to write to. |
| 89 | buffer: Pointer to the data to be written. |
| 90 | size: Amount of data to write, from the pointer. |
| 91 | option: Additional options for writing, like flushing. |
| 92 | */ |
| 93 | Result WriteFile(FileHandle handle, s64 position, void const* buffer, u64 size, |
| 94 | WriteOption const& option); |
| 95 | |
| 96 | /* |
| 97 | Flush file. |
| 98 | handle: Handle representing file to flush. |
| 99 | */ |
| 100 | Result FlushFile(FileHandle handle); |
| 101 | |
| 102 | // Result GetSaveDataTimeStamp(nn::time::PosixTime *,ulong); |
| 103 | // Result GetSaveDataTimeStamp(nn::time::PosixTime*, nn::fs::SaveDataSpaceId, ulong); |
| 104 | Result GetFileTimeStampForDebug(nn::fs::FileTimeStamp*, const char*); |
| 105 | |
| 106 | Result DeleteFile(const char* path); |
| 107 | |
| 108 | Result SetFileSize(FileHandle fileHandle, s64 filesize); |
| 109 | Result RenameFile(const char* filepath, const char* newPath); |
| 110 | |
| 111 | } // namespace nn::fs |
| 112 | |