Changes between Version 1 and Version 2 of Develop/LoadSaveSystem


Ignore:
Timestamp:
19/11/2018 09:55:05 (18 months ago)
Author:
Thomas Bernard
Comment:

update regarding Open_file_read() and File_length_file()

Legend:

Unmodified
Added
Removed
Modified
  • Develop/LoadSaveSystem

    v1 v2  
    3131
    3232== Test function ==
    33 Use Get_full_filename to get the filename we are asking you to test.
     33Use File_length_file() to get the size of the file we are asking you to test.
    3434Load your file, do some reading on it to check it is coherent (checking the
    3535header is enough). Set the global var File_error to 0 if you think you can load
    3636the file, or 1 else.
    37 Don't forget to close your file and free things you allocated (if you did. is
     37Don't forget to free things you allocated (if you did. is
    3838your format so difficult to identify ?)
    3939
    4040{{{#!c
    41 void Test_EXT(void)
     41void Test_EXT(FILE * file)
    4242{
    43         FILE* file;
    44         char filename[MAX_PATH_CHARACTERS];
    4543        long file_size;
    4644
    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;
    6049        else
    6150                File_error = 1;
     
    6554== Load function ==
    6655This 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.
     56window. 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.
    6857You have to set some variables and call some functions, of course.
    6958
     
    7261{
    7362        FILE* file;
    74         char filename[MAX_PATH_CHARACTERS];
    7563        long file_size;
    7664
    77         Get_full_filename(filename,0);
    78 
    79         file = fopen(filename,"rb");
     65        file = Open_file_read(context);
    8066
    8167        if(file)