You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"I've replicated the FAT32 behavior (at least the one from fasttracker2-clone) with a simple code, the code is a lot similar to code used used in ft2-clone.
The program will:
First run
Verify if the new file exist, if not, create new file and exit <= file created successful
Second run
file exist, try to overwrite file <= file become 0KB (should be 1736)
Third run
file exist, wrong size trow error, try to overwrite file <=file is ok again (1736 byte)
Forth run
Same as second (0KCool and so >"
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include "unicode/utypes.h"
int main() {
const char* filename = "FT2.cfg";
const size_t requiredSize = 1736;
// Try to open the file in binary read mode
FILE* file = fopen(filename, "rb");
if (file == NULL) {
// File does not exist, create it
printf("The file does not exist, creating...\n");
file = fopen(filename, "wb");
if (file == NULL) {
printf("Error creating the file!\n");
return 1;
}
// Create a buffer of 1736 bytes and write it to the file
char buffer[1736] = {0}; // Initialize buffer to zero
fwrite(buffer, sizeof(char), requiredSize, file);
fclose(file);
// Pause and wait for user input
printf("File created exiting, press any key to continue...\n");
getchar(); // Wait for user to press any key
return 0;
} else {
// File exists, check its size
fseek(file, 0, SEEK_END);
long fileSize = ftell(file);
fclose(file);
if (fileSize == requiredSize) {
printf("The file exists, all good.\n");
} else {
printf("The file exists, wrong size!\n");
}
}
// Pause and wait for user input
printf("Trying to overwrite the file, press any key to continue...\n");
getchar(); // Wait for user to press any key
// Overwrite the file with 1736 bytes
file = fopen(filename, "wb");
if (file == NULL) {
printf("Error opening the file for writing!\n");
return 1;
}
char buffer[1736] = {0}; // Initialize buffer to zero
fwrite(buffer, sizeof(char), requiredSize, file);
fclose(file);
printf("The file has been overwritten.\n");
return 0;
}
The text was updated successfully, but these errors were encountered:
"I've replicated the FAT32 behavior (at least the one from fasttracker2-clone) with a simple code, the code is a lot similar to code used used in ft2-clone.
The program will:
First run
Verify if the new file exist, if not, create new file and exit <= file created successful
Second run
file exist, try to overwrite file <= file become 0KB (should be 1736)
Third run
file exist, wrong size trow error, try to overwrite file <=file is ok again (1736 byte)
Forth run
Same as second (0KCool and so >"
The text was updated successfully, but these errors were encountered: