Ejemplo n.º 1
0
 TestArchive()
 {
   {
   Archive* archive = OpenArchive("");
   archive->release();
   }
   {
   Archive* archive = OpenArchive("NONEXISTANTFILE");
   archive->release();
   }
   {
   Archive* archive = OpenArchive("c:/quake/id1/quake101.wad");
   ArchiveFile* file = archive->openFile("textures/sky1.mip");
   if(file != 0)
   {
     unsigned char* buffer = new unsigned char[file->size()];
     file->getInputStream().read((InputStream::byte_type*)buffer, file->size());
     delete[] buffer;
     file->release();
   }
   TestVisitor visitor;
   archive->forEachFile(Archive::VisitorFunc(&visitor, Archive::eFilesAndDirectories, 1), "");
   archive->forEachFile(Archive::VisitorFunc(&visitor, Archive::eFilesAndDirectories, 0), "");
   archive->forEachFile(Archive::VisitorFunc(&visitor, Archive::eFilesAndDirectories, 0), "textures/");
   archive->forEachFile(Archive::VisitorFunc(&visitor, Archive::eFilesAndDirectories, 1), "textures/");
   archive->release();
   }
 }
Ejemplo n.º 2
0
	void RoutingLumpLoader::loadRoutingLump (ArchiveFile& file)
	{
		/* load the file */
		InputStream &stream = file.getInputStream();
		const std::size_t size = file.size();
		byte *buf = (byte*) malloc(size + 1);
		dBspHeader_t *header = (dBspHeader_t *) buf;
		stream.read(buf, size);

		CMod_LoadRouting(_routingLump, file.getName(), &header->lumps[LUMP_ROUTING], (byte *) buf, 0, 0, 0);
		free(buf);
	}
Ejemplo n.º 3
0
// NOTE: when loading a file, you have to allocate one extra byte and set it to \0
std::size_t LoadFile (const char *filename, void **bufferptr, int index)
{
  char fixed[PATH_MAX+1];

  strncpy (fixed, filename, PATH_MAX);
  fixed[PATH_MAX] = '\0';
  FixDOSName (fixed);

  ArchiveFile* file = OpenFile(fixed);
  
  if(file != 0)
  {
    *bufferptr = malloc (file->size()+1);
    // we need to end the buffer with a 0
    ((char*) (*bufferptr))[file->size()] = 0;

    std::size_t length = file->getInputStream().read((InputStream::byte_type*)*bufferptr, file->size());
    file->release();
    return length;
  }

  *bufferptr = 0;
  return 0;
}