CringeDB/tests/System Abstraction/3/openTempFiletest.c
2024-02-18 17:42:05 +01:00

35 lines
882 B
C

#include "../../../System Abstraction/cdb_sustem.h"
#include "stdio.h"
void main(){
sys_File file = sys_fileOpenInMem("testfile.txt", SYS_FILE_TEMP);
if(file == NULL){
printf("file is null\n");
return;
}
char * memory = sys_fileFileToMemory(file);
if(memory == 0){
printf("memory was null\n");
return;
}else{
printf("%c\n", memory[0] == 0 ? 'Y' : 'N');
}
sys_fileResize(file, 4);
memory = sys_fileFileToMemory(file);
memory[0] = 'a';
memory[1] = 'b';
memory[2] = 'c';
memory[3] = 'd';
memory[4] = 'e';
sys_fileClose(file);
file = sys_fileOpenInMem("testfile.txt", SYS_FILE_NOTHING);
if(file == NULL) {
printf("Second file is null\n");
}else {
printf("Second file is NOT null\n");
sys_fileClose(file);
}
}