initial code and README

This commit is contained in:
IniKiwi 2021-08-26 17:53:40 +02:00
parent 8d424ed4b8
commit 79ba865d15
2 changed files with 56 additions and 0 deletions

View File

@ -1,2 +1,6 @@
# G35EIIcompatibility-tool
##build
`gcc main.c -o G35EIIcompatibility-tool.elf`
##use
`./G35EIIcompatibility-tool.elf input output`

52
main.c Normal file
View File

@ -0,0 +1,52 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main(int argc, char **argv){
if(argc == 1){
printf("\033[1;31m"); //red
printf("error: ");
printf("\033[0;37m"); //white
printf("no input and output file!\n");
return -1;
}
if(argc == 2){
printf("\033[1;31m"); //red
printf("error: ");
printf("\033[0;37m"); //white
printf("no output file!\n");
return -1;
}
if(access(argv[1], F_OK ) == 0) {
//none
} else {
printf("\033[1;31m"); //red
printf("error: ");
printf("\033[0;37m"); //white
printf("cannot open file!\n");
return -1;
}
printf("\033[0;37m"); //white text
FILE * file; //file pointer
file = fopen(argv[1], "rb"); //open file
fseek(file, 0L, SEEK_END); //seek file size
size_t filesize = ftell(file); //get file size
unsigned int filedata[filesize]; //make file data table
fread(filedata, filesize, 1, file); //set file data in filedata table
fclose(file); //close input file
//put here data manipulation
file = fopen(argv[2], "wb"); //open output file
//write final data in output file
fwrite(filedata , sizeof(char) , filesize , file);
fclose(file); //close output file
return 1;
}