TestResourceManager.h
Go to the documentation of this file.
1 #pragma once
2 #include <stddef.h>
3 #include <stdint.h>
4 #include <stdio.h>
5 #include <memory.h>
6 
7 #ifdef __cplusplus
8 extern "C" {
9 #endif
10 
106 {
117 };
118 
120 
124 {
128 };
129 
130 typedef struct tagTRMFileHandle *TRMFileHandle;
131 typedef struct tagTRMReadBurstHandle *TRMReadBurstHandle;
132 typedef struct tagTRMWriteBurstHandle *TRMWriteBurstHandle;
133 
135 
138 uint64_t TRMGetHostSystemTime();
139 
141 
147 TRMFileHandle TRMCreateFile(const char *pFileName, SemihostingFileMode mode); //Returns 0 on failure.
148 
150 void TRMCloseFile(TRMFileHandle hFile);
151 
153 
162 ssize_t TRMReadFile(TRMFileHandle hFile, void *pBuffer, size_t size);
163 
165 
174 ssize_t TRMWriteFile(TRMFileHandle hFile, const void *pBuffer, size_t size);
175 
177 
179 uint64_t TRMGetFileSize(TRMFileHandle hFile);
180 
182 
189 uint64_t TRMSeekFile(TRMFileHandle hFile, int mode, int64_t distance);
190 
192 
195 void TRMTruncateFile(TRMFileHandle hFile);
196 
198 
200 TRMErrorCode TRMDeleteFile(const char *pFileName);
201 
203 
205 TRMErrorCode TRMCreateDirectory(const char *pDirName);
206 
208 
213 TRMErrorCode TRMDeleteDirectory(const char *pDirName, int recursively);
214 
216 
226 TRMReadBurstHandle TRMBeginReadBurst(TRMFileHandle hFile, void *pWorkArea, size_t workAreaSize);
227 
229 
230 TRMErrorCode TRMEndReadBurst(TRMReadBurstHandle hBurst);
231 
233 
257 void *TRMBeginReadFileCached(TRMReadBurstHandle hBurst, size_t *pSize, int waitForData);
258 
260 
266 TRMErrorCode TRMEndReadFileCached(TRMReadBurstHandle hBurst, void *pBuffer, size_t size);
267 
269 
281 ssize_t TRMReadFileCached(TRMReadBurstHandle hBurst, void *pBuffer, size_t size, int allowPartialReads);
282 
284 
291 TRMWriteBurstHandle TRMBeginWriteBurst(TRMFileHandle hFile);
292 
294 
295 TRMErrorCode TRMEndWriteBurst(TRMWriteBurstHandle hBurst);
296 
298 
304 ssize_t TRMWriteFileCached(TRMWriteBurstHandle hBurst, const void *pData, size_t size);
305 
306 #ifdef __cplusplus
307 }
308 #endif
TRMErrorCode TRMDeleteDirectory(const char *pDirName, int recursively)
Deletes a file.
Definition: TestResourceManager.cpp:123
ssize_t TRMWriteFile(TRMFileHandle hFile, const void *pBuffer, size_t size)
Write the data to a file on the host machine.
Definition: TestResourceManager.cpp:88
Definition: TestResourceManager.h:127
TRMFileHandle TRMCreateFile(const char *pFileName, SemihostingFileMode mode)
Creates or opens a file on the host.
Definition: TestResourceManager.cpp:71
SemihostingFileMode
Lists the supported file open modes.
Definition: TestResourceManager.h:105
TRMErrorCode TRMDeleteFile(const char *pFileName)
Deletes a file.
Definition: TestResourceManager.cpp:111
Create an empty file if it doesn't exist. Otherwise, truncate an existing file. Allow writing to the ...
Definition: TestResourceManager.h:108
TRMErrorCode TRMCreateDirectory(const char *pDirName)
Creates a subdirectory.
Definition: TestResourceManager.cpp:117
Open an existing file and allow reading/writing it. If the file doesn't exist, create it...
Definition: TestResourceManager.h:114
uint64_t TRMGetFileSize(TRMFileHandle hFile)
Returns the size of the file.
Definition: TestResourceManager.cpp:94
uint64_t TRMSeekFile(TRMFileHandle hFile, int mode, int64_t distance)
Moves the file pointer.
Definition: TestResourceManager.cpp:100
TRMErrorCode TRMEndWriteBurst(TRMWriteBurstHandle hBurst)
Ends a write burst.
Definition: TestResourceManager.cpp:272
ssize_t TRMReadFileCached(TRMReadBurstHandle hBurst, void *pBuffer, size_t size, int allowPartialReads)
Reads data within a read burst.
Definition: TestResourceManager.cpp:236
TRMWriteBurstHandle TRMBeginWriteBurst(TRMFileHandle hFile)
Starts a read burst.
Definition: TestResourceManager.cpp:266
uint64_t TRMGetHostSystemTime()
Returns system time on host in Windows FILETIME format.
Definition: TestResourceManager.cpp:65
struct tagTRMFileHandle * TRMFileHandle
Definition: TestResourceManager.h:130
TRMErrorCode TRMEndReadFileCached(TRMReadBurstHandle hBurst, void *pBuffer, size_t size)
Releases the buffer returned by TRMBeginReadFileCached.
Definition: TestResourceManager.cpp:208
void * TRMBeginReadFileCached(TRMReadBurstHandle hBurst, size_t *pSize, int waitForData)
Returns the pointer to a block of data that has been prefetched into the read burst buffer...
Definition: TestResourceManager.cpp:170
Definition: TestResourceManager.h:125
struct tagTRMReadBurstHandle * TRMReadBurstHandle
Definition: TestResourceManager.h:131
Create an empty file if it doesn't exist. Otherwise, truncate an existing file. Allow reading to the ...
Definition: TestResourceManager.h:116
TRMErrorCode
Specifies the error code returned by common Test Resource Manager functions.
Definition: TestResourceManager.h:123
Definition: TestResourceManager.h:126
ssize_t TRMWriteFileCached(TRMWriteBurstHandle hBurst, const void *pData, size_t size)
Writes data within a write burst.
Definition: TestResourceManager.cpp:278
void TRMCloseFile(TRMFileHandle hFile)
Closes a handle returned by TRMCreateFile.
Definition: TestResourceManager.cpp:77
Create an empty file if it doesn't exist. Otherwise, open the existing file and immediately seek to t...
Definition: TestResourceManager.h:110
struct tagTRMWriteBurstHandle * TRMWriteBurstHandle
Definition: TestResourceManager.h:132
Open an existing file in read-only mode. If the file doesn't exist, TRMCreateFile will return 0...
Definition: TestResourceManager.h:112
ssize_t TRMReadFile(TRMFileHandle hFile, void *pBuffer, size_t size)
Reads the data from a file on the host machine.
Definition: TestResourceManager.cpp:82
TRMErrorCode TRMEndReadBurst(TRMReadBurstHandle hBurst)
Ends a read burst.
Definition: TestResourceManager.cpp:157
void TRMTruncateFile(TRMFileHandle hFile)
Truncates the file.
Definition: TestResourceManager.cpp:106
TRMReadBurstHandle TRMBeginReadBurst(TRMFileHandle hFile, void *pWorkArea, size_t workAreaSize)
Starts a read burst.
Definition: TestResourceManager.cpp:136