sprint 1-alpha
|
00001 /****************************************************************************** 00002 * sprint::xtar 00003 * 00004 * Copyright (C) 2005-2011 Paolo Medici <www.pmx.it> 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2.1 of the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License along with this library; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00019 * 00020 *******************************************************************************/ 00021 00022 #ifndef _XTAR_H 00023 #define _XTAR_H 00024 00025 #include <string> 00026 #include <sprint/io/xstream/xfolder.h> 00027 #include <sprint/io/tar.h> 00028 00033 namespace sprint { 00034 namespace io { 00035 00037 class xtar: public xfolder { 00038 tar m_tar; 00039 bool m_good; 00040 int m_open_mode; 00041 bool m_buffer_mode; 00042 std::string fl; 00043 00044 private: 00046 void flush(void); 00047 00048 public: 00049 xtar(const char *filename, flag_t open_mode, bool full_buffer = false); 00050 ~xtar(); 00051 00052 bool open(const std::string & filename); 00053 bool close(); 00054 unsigned int capabilities() const; 00055 unsigned long long seek(unsigned long long); 00056 unsigned long long size(); 00057 00058 inline bool is_good() const { return m_good; } 00060 inline std::string filename() const { return fl; } 00061 00062 unsigned int write(const unsigned char *data, unsigned int size); 00063 unsigned int read(unsigned char *data, unsigned int size); 00064 }; 00065 00067 class xtarf: public xstream { 00068 public: 00069 xtarf(xstream & stream); 00070 ~xtarf(); 00071 xtarf *clone(void); 00072 bool open(const char *filename, int flags); 00073 bool close(); 00074 unsigned int write(const unsigned char *data, unsigned int size); 00075 unsigned int read(unsigned char *data, unsigned int size); 00076 }; 00077 00078 } 00079 00080 } 00081 00082 #endif