2
#include "zipios++/zipios-config.h"
6
#include "zipios++/meta-iostreams.h"
9
#include "zipios_common.h"
10
#include "zipios++/basicentry.h"
11
#include "zipios++/zipios_defs.h"
13
#include "outputstringstream.h"
24
BasicEntry::BasicEntry( const string &filename, const string &comment,
25
const FilePath &basepath )
26
: _filename ( filename ),
28
_basepath ( basepath )
30
string full_path = _basepath + _filename ;
31
ifstream is( full_path.c_str(), ios::in | ios::binary ) ;
35
is.seekg( 0, ios::end ) ;
42
string BasicEntry::getComment() const {
46
uint32 BasicEntry::getCompressedSize() const {
50
uint32 BasicEntry::getCrc() const {
54
vector< unsigned char > BasicEntry::getExtra() const {
55
return vector< unsigned char > () ;
58
StorageMethod BasicEntry::getMethod() const {
62
string BasicEntry::getName() const {
66
string BasicEntry::getFileName() const {
69
string::size_type pos ;
70
pos = _filename.find_last_of( separator ) ;
71
if ( pos != string::npos ) { // separator found!
72
// isDirectory() check means pos should not be last, so pos+1 is ok
73
return _filename.substr(pos + 1) ;
79
uint32 BasicEntry::getSize() const {
83
int BasicEntry::getTime() const {
84
return 0 ; // FIXME later
87
bool BasicEntry::isValid() const {
91
// virtual int hashCode() const {}
92
bool BasicEntry::isDirectory() const {
93
assert( _filename.size() != 0 ) ;
94
return _filename[ _filename.size() - 1 ] == separator ;
98
void BasicEntry::setComment( const string &comment ) {
102
void BasicEntry::setCompressedSize( uint32 size ) {
105
void BasicEntry::setCrc( uint32 crc ) {
108
void BasicEntry::setExtra( const vector< unsigned char > &extra ) {
111
void BasicEntry::setMethod( StorageMethod method ) {
114
void BasicEntry::setName( const string &name ) {
118
void BasicEntry::setSize( uint32 size ) {
122
void BasicEntry::setTime( int time ) {
126
string BasicEntry::toString() const {
127
OutputStringStream sout ;
128
sout << _filename << " (" << _size << " bytes)" ;
132
FileEntry *BasicEntry::clone() const {
133
return new BasicEntry( *this ) ;
136
BasicEntry::~BasicEntry() {
143
Implementation of BasicEntry.
147
Zipios++ - a small C++ library that provides easy access to .zip files.
148
Copyright (C) 2000 Thomas S�ndergaard
150
This library is free software; you can redistribute it and/or
151
modify it under the terms of the GNU Lesser General Public
152
License as published by the Free Software Foundation; either
153
version 2 of the License, or (at your option) any later version.
155
This library is distributed in the hope that it will be useful,
156
but WITHOUT ANY WARRANTY; without even the implied warranty of
157
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
158
Lesser General Public License for more details.
160
You should have received a copy of the GNU Lesser General Public
161
License along with this library; if not, write to the Free Software
162
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA