2024-02-18 17:49:32 +01:00
|
|
|
#include "../../../System Abstraction/cdb_system.h"
|
2022-08-28 13:47:31 +02:00
|
|
|
#include "stdio.h"
|
|
|
|
|
|
|
|
void main(){
|
2024-02-18 17:42:05 +01:00
|
|
|
sys_File file = sys_fileOpenInMem("testfile.txt", SYS_FILE_NEW);
|
2022-08-28 13:47:31 +02:00
|
|
|
if(file == NULL){
|
2022-08-29 17:27:24 +02:00
|
|
|
printf("file is null\n");
|
2022-08-28 13:47:31 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-02-18 17:42:05 +01:00
|
|
|
char * memory = sys_fileFileToMemory(file);
|
|
|
|
if(memory == 0){
|
|
|
|
printf("memory was null\n");
|
2022-08-28 13:47:31 +02:00
|
|
|
return;
|
|
|
|
}else{
|
2024-02-18 17:42:05 +01:00
|
|
|
printf("%c\n", memory[0] == 0 ? 'Y' : 'N');
|
2022-08-28 13:47:31 +02:00
|
|
|
}
|
|
|
|
|
2024-02-18 17:42:05 +01:00
|
|
|
sys_fileResize(file, 4);
|
|
|
|
memory = sys_fileFileToMemory(file);
|
|
|
|
memory[0] = 'a';
|
|
|
|
memory[1] = 'b';
|
|
|
|
memory[2] = 'c';
|
|
|
|
memory[3] = 'd';
|
|
|
|
memory[4] = 'e';
|
|
|
|
sys_fileFlush(file);
|
|
|
|
sys_fileClose(file);
|
|
|
|
file = sys_fileOpenInMem("testfile.txt", SYS_FILE_NOTHING);
|
|
|
|
memory = sys_fileFileToMemory(file);
|
|
|
|
memory[0] = 'O';
|
|
|
|
sys_fileFlush(file);
|
|
|
|
sys_fileClose(file);
|
2022-08-28 13:47:31 +02:00
|
|
|
}
|