/usr/bin/avos:AOS check file()

From ArchosDocs

Jump to: navigation, search

Description

This function is responsible for validating an .aos file. It returns zero if the file is valid, -1 otherwise.

References To

The Code

uint64_t AOS_file_length; // global variable
 
int AOS_check_file(char *pathname) {
int fd;
int unk_1;
 
AOS_file_offset = 0;
 
fd = fopen(pathname, O_RDONLY, 0);
if(fd != 0) {
 
AOS_file_length = fseek(fd, SEEK_END, 0);
fseek(fd, SEEK_SET, 0);
 
if(AOS_verify_magic(fd) == 0
&& AOS_compare_SIGx_checksum(fd) == 0) {
fclose(fd);
return 0; // success
}
 
fclose(fd);
}
 
return -1; // failure
}
Personal tools