CringeDB/tests/System Abstraction/2/openNewFiletest.c

33 lines
859 B
C
Raw Normal View History

2024-02-18 17:49:32 +01:00
#include "../../../System Abstraction/cdb_system.h"
#include "stdio.h"
void main(){
2024-02-18 17:42:05 +01:00
sys_File file = sys_fileOpenInMem("testfile.txt", SYS_FILE_NEW);
if(file == NULL){
2022-08-29 17:27:24 +02:00
printf("file is null\n");
return;
}
2024-02-18 17:42:05 +01:00
char * memory = sys_fileFileToMemory(file);
if(memory == 0){
printf("memory was null\n");
return;
}else{
2024-02-18 17:42:05 +01:00
printf("%c\n", memory[0] == 0 ? 'Y' : 'N');
}
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);
}