Changes between Version 1 and Version 2 of Develop/LoadSaveSystem
- Timestamp:
- Nov 19, 2018, 9:55:05 AM (4 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Develop/LoadSaveSystem
v1 v2 31 31 32 32 == Test function == 33 Use Get_full_filename to get the filename we are asking you to test.33 Use File_length_file() to get the size of the file we are asking you to test. 34 34 Load your file, do some reading on it to check it is coherent (checking the 35 35 header is enough). Set the global var File_error to 0 if you think you can load 36 36 the file, or 1 else. 37 Don't forget to close your file andfree things you allocated (if you did. is37 Don't forget to free things you allocated (if you did. is 38 38 your format so difficult to identify ?) 39 39 40 40 {{{#!c 41 void Test_EXT( void)41 void Test_EXT(FILE * file) 42 42 { 43 FILE* file;44 char filename[MAX_PATH_CHARACTERS];45 43 long file_size; 46 44 47 Get_full_filename(filename,0); 48 49 file = fopen(filename,"rb"); 50 51 if(file) 52 { 53 // Do some more tests to see if everything is ok 54 if((/*...*/) 55 File_error = 0; 56 else 57 File_error = 1; 58 fclose(file) 59 } 45 file_size = File_length_file(file); 46 // Do some more tests to see if everything is ok 47 if((/*...*/) 48 File_error = 0; 60 49 else 61 50 File_error = 1; … … 65 54 == Load function == 66 55 This one is a bit more tricky. You have to handle some things for our preview 67 window. You can still set File_error while loading the file if something goes wrong, that's why you don't have to go too far in the Test function. Get the filename the same way with Get_full_filename, read the data.56 window. You can still set File_error while loading the file if something goes wrong, that's why you don't have to go too far in the Test function. Open the file with Open_file_read(), read the data. 68 57 You have to set some variables and call some functions, of course. 69 58 … … 72 61 { 73 62 FILE* file; 74 char filename[MAX_PATH_CHARACTERS];75 63 long file_size; 76 64 77 Get_full_filename(filename,0); 78 79 file = fopen(filename,"rb"); 65 file = Open_file_read(context); 80 66 81 67 if(file)