Previous 15994 Revisions Next

r14497 Friday 17th February, 2012 at 14:53:11 UTC by Miodrag Milanović
Sync with MAME r15415 (no whatsnew)
[src/emu]clifront.c

src/emu/clifront.c
r14496r14497
4444#include "audit.h"
4545#include "info.h"
4646#include "unzip.h"
47#include "un7z.h"
4748#include "validity.h"
4849#include "sound/samples.h"
4950#include "clifront.h"
r14496r14497
14381439   }
14391440
14401441   // if that failed, and the filename ends with .zip, identify as a ZIP file
1442   if (core_filename_ends_with(filename, ".7z"))
1443   {
1444      // first attempt to examine it as a valid _7Z file
1445      _7z_file *_7z = NULL;
1446      _7z_error _7zerr = _7z_file_open(filename, &_7z);
1447      if (_7zerr == _7ZERR_NONE && _7z != NULL)
1448      {
1449         // loop over entries in the .7z, skipping empty files and directories
1450         for (int i = 0; i < _7z->db.db.NumFiles; i++)
1451         {
1452            const CSzFileItem *f = _7z->db.db.Files + i;
1453            _7z->curr_file_idx = i;
1454            int namelen = SzArEx_GetFileNameUtf16(&_7z->db, i, NULL);
1455            UINT16* temp = (UINT16 *)malloc(namelen * sizeof(UINT16));
1456            void* temp2 = malloc((namelen+1) * sizeof(UINT8));
1457            UINT8* temp3 = (UINT8*)temp2;
1458            memset(temp3, 0x00, namelen);
1459            SzArEx_GetFileNameUtf16(&_7z->db, i, temp);
1460            // crude, need real UTF16->UTF8 conversion ideally
1461            for (int j=0;j<namelen;j++)
1462            {
1463               temp3[j] = (UINT8)temp[j];           
1464            }
1465                 
1466            if (!(f->IsDir) && (f->Size != 0))
1467            {
1468               UINT8 *data = global_alloc_array(UINT8, f->Size);
1469               if (data != NULL)
1470               {
1471                  // decompress data into RAM and identify it
1472                  _7zerr = _7z_file_decompress(_7z, data, f->Size);
1473                  if (_7zerr == _7ZERR_NONE)
1474                     identify_data((const char*)temp2, data, f->Size);
1475                  global_free(data);
1476               }
1477            }
1478
1479            free(temp);
1480            free(temp2);
1481         }
1482
1483         // close up
1484         _7z_file_close(_7z);
1485      }
1486
1487      // clear out any cached files
1488      _7z_file_cache_clear();
1489   }
14411490   else if (core_filename_ends_with(filename, ".zip"))
14421491   {
14431492      // first attempt to examine it as a valid ZIP file

Previous 15994 Revisions Next


© 1998-2018 The MESS Team