Revert "eet: do not load data when the file is open in read/write mode."
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>
Tue, 21 Jan 2014 00:18:52 +0000 (09:18 +0900)
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>
Tue, 21 Jan 2014 00:18:52 +0000 (09:18 +0900)
This reverts commit f8b0322704a4d74e4a5545727c18dc8385318657.

this breaks efreets icon cache. i have been noticing this since
yesterday across all my machines once i update just efl. i tracked it
down to this commit.

src/lib/eet/eet_lib.c

index 63f8e4f..6ff2a3c 100644 (file)
@@ -482,12 +482,7 @@ eet_flush2(Eet_File *ef)
      {
         for (efn = ef->header->directory->nodes[i]; efn; efn = efn->next)
           {
-             if (efn->data)
-               {
-                  if (fwrite(efn->data, efn->size, 1, fp) != 1)
-                    goto write_error;
-               }
-             else if (fwrite(ef->data + efn->offset, efn->size, 1, fp) != 1)
+             if (fwrite(efn->data, efn->size, 1, fp) != 1)
                goto write_error;
           }
      }
@@ -909,8 +904,15 @@ eet_internal_read2(Eet_File *ef)
         efn->next = ef->header->directory->nodes[hash];
         ef->header->directory->nodes[hash] = efn;
 
-        /* There is no need to load data at this stage */
-        efn->data = NULL;
+        /* read-only mode, so currently we have no data loaded */
+        if (ef->mode == EET_FILE_MODE_READ)
+          efn->data = NULL;  /* read-write mode - read everything into ram */
+        else
+          {
+             efn->data = malloc(efn->size);
+             if (efn->data)
+               memcpy(efn->data, ef->data + efn->offset, efn->size);
+          }
 
         /* compute the possible position of a signature */
         if (signature_base_offset < efn->offset + efn->size)