Flat.cc

Go to the documentation of this file.
00001 /*
00002 Copyright (C) 2000  Dancer A.L Vesperman
00003 
00004 This program is free software; you can redistribute it and/or
00005 modify it under the terms of the GNU General Public License
00006 as published by the Free Software Foundation; either version 2
00007 of the License, or (at your option) any later version.
00008 
00009 This program is distributed in the hope that it will be useful,
00010 but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 GNU General Public License for more details.
00013 
00014 You should have received a copy of the GNU General Public License
00015 along with this program; if not, write to the Free Software
00016 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017 */
00018 
00019 #ifdef HAVE_CONFIG_H
00020 #  include <config.h>
00021 #endif
00022 
00023 
00024 #include "Flat.h"
00025 
00026 #ifndef ALPHA_LINUX_CXX
00027 #  include <cstdio>
00028 #endif
00029 #include <iostream>
00030 #include "exceptions.h"
00031 #include "utils.h"
00032 
00033 using std::string;
00034 // using std::vector;
00035 
00036 using std::cout;
00037 using std::cerr;
00038 using std::endl;
00039 using std::FILE;
00040 using std::size_t;
00041 
00042 
00043 Flat::Flat(const string &n) : U7file(n)
00044 {
00045   // Make sure the file exists and is readable
00046   FILE *fp;
00047   fp=U7open(filename.c_str(),"rb");
00048   fclose(fp);
00049 }
00050 
00051 
00052 char *  Flat::retrieve(uint32 objnum, size_t &len)
00053 { 
00054   FILE  *fp;
00055   char  *buffer;
00056   fp=U7open(filename.c_str(),"rb");
00057 
00058   fseek(fp,0,SEEK_END);
00059   len = ftell(fp);
00060   buffer = new char[len];
00061   fseek(fp,0,SEEK_SET);
00062   fread(buffer,len,1,fp);
00063   fclose(fp);
00064   
00065   return buffer;
00066 }

Generated on Mon Jul 9 14:42:45 2007 for ExultEngine by  doxygen 1.5.1