Exemplo n.º 1
0
Stream * ZipArchive::openFile(const char *filename, ZipEntry* ze, AccessMode mode /* = Read */)
{
   if(mode == Read)
   {
      if(ze == NULL)
         return NULL;

      return openFileForRead(&ze->mCD);
   }

   if(mode == Write)
   {
      if(ze)
      {
         if(ze->mCD.mInternalFlags & CDFileOpen)
         {
            if(isVerbose())
               Con::errorf("ZipArchive::openFile - File %s is already open", filename);
            return NULL;
         }
         
         // Remove the old entry so we can create a new one
         removeEntry(ze);
         ze = NULL;
      }

      return createNewFile(filename, Compressor::findCompressor(Deflated));
   }

   if(isVerbose())
      Con::errorf("ZipArchive::openFile - Files within zips can only be opened as read or write, but not both at the same time.");

   return NULL;
}
Exemplo n.º 2
0
int filesize(char* name)
{
	FILE* f = openFileForRead(name);
	fseek(f, 0, SEEK_END);
	return(ftell(f));
	fclose(f);
}