CringeDB/tests/System Abstraction/3/openTempFiletest.c

35 lines
882 B
C
Raw Normal View History

2022-08-29 15:41:40 +02:00
#include "../../../System Abstraction/cdb_sustem.h"
#include "stdio.h"
void main(){
2024-02-18 17:42:05 +01:00
sys_File file = sys_fileOpenInMem("testfile.txt", SYS_FILE_TEMP);
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_fileClose(file);
2022-08-29 17:27:24 +02:00
2024-02-18 17:42:05 +01:00
file = sys_fileOpenInMem("testfile.txt", SYS_FILE_NOTHING);
2022-08-29 17:27:24 +02:00
if(file == NULL) {
printf("Second file is null\n");
}else {
printf("Second file is NOT null\n");
2024-02-18 17:42:05 +01:00
sys_fileClose(file);
2022-08-29 17:27:24 +02:00
}
}