~ubuntu-branches/ubuntu/intrepid/enigma/intrepid

« back to all changes in this revision

Viewing changes to lib-src/zipios++/src/basicentry.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Erich Schubert
  • Date: 2005-08-28 15:30:09 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050828153009-sky64kb6tcq37xt5
Tags: 0.92.1-1
* New upstream subversion checkout
* Remove menu.s3m, which we are allowed to distributed but not to modify
  also copyright notice is confusing... (Closes: #321669)
* Rebuild with new libzipios (Closes: #325405)
  I hope this works without a versioned build-dependency
* Added "enigma replaces enigma-data" for upgrades (Closes: #308558)
* Added notes about the fonts copyright.
* updated to policy 3.6.2.1 (no changes)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
 
#include "zipios++/zipios-config.h"
3
 
 
4
 
#include <assert.h>
5
 
 
6
 
#include "zipios++/meta-iostreams.h"
7
 
#include <string>
8
 
 
9
 
#include "zipios_common.h"
10
 
#include "zipios++/basicentry.h"
11
 
#include "zipios++/zipios_defs.h"
12
 
 
13
 
#include "outputstringstream.h"
14
 
 
15
 
namespace zipios {
16
 
 
17
 
using std::ifstream ;
18
 
using std::ios ;
19
 
 
20
 
//
21
 
// Public definitions
22
 
//
23
 
 
24
 
BasicEntry::BasicEntry( const string &filename, const string &comment,
25
 
                       const FilePath &basepath ) 
26
 
  : _filename ( filename ),
27
 
    _comment  ( comment  ),
28
 
    _basepath ( basepath )
29
 
{
30
 
  string full_path = _basepath + _filename ;
31
 
  ifstream is( full_path.c_str(), ios::in | ios::binary ) ;
32
 
  if ( ! is ) {
33
 
    _valid = false ;
34
 
  } else {
35
 
    is.seekg( 0, ios::end ) ;
36
 
    _size = is.tellg() ;
37
 
    is.close() ;
38
 
    _valid = true ;
39
 
  }
40
 
}
41
 
 
42
 
string BasicEntry::getComment() const {
43
 
  return _comment ;
44
 
}
45
 
 
46
 
uint32 BasicEntry::getCompressedSize() const {
47
 
  return getSize() ;
48
 
}
49
 
 
50
 
uint32 BasicEntry::getCrc() const {
51
 
  return 0 ;
52
 
}
53
 
 
54
 
vector< unsigned char > BasicEntry::getExtra() const {
55
 
  return vector< unsigned char > () ;
56
 
}
57
 
 
58
 
StorageMethod BasicEntry::getMethod() const {
59
 
  return STORED ;
60
 
}
61
 
 
62
 
string BasicEntry::getName() const {
63
 
  return _filename ;
64
 
}
65
 
 
66
 
string BasicEntry::getFileName() const {
67
 
  if ( isDirectory() )
68
 
    return string() ;
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) ;
74
 
  } else {
75
 
    return _filename ;
76
 
  }
77
 
}
78
 
 
79
 
uint32 BasicEntry::getSize() const {
80
 
  return _size ;
81
 
}
82
 
 
83
 
int BasicEntry::getTime() const {
84
 
  return 0 ; // FIXME later
85
 
}
86
 
 
87
 
bool BasicEntry::isValid() const {
88
 
  return _valid ;
89
 
}
90
 
 
91
 
//     virtual int hashCode() const {}
92
 
bool BasicEntry::isDirectory() const {
93
 
  assert( _filename.size() != 0 ) ;
94
 
  return  _filename[ _filename.size() - 1 ] == separator ;
95
 
}
96
 
 
97
 
 
98
 
void BasicEntry::setComment( const string &comment ) {
99
 
  _comment = comment ;
100
 
}
101
 
 
102
 
void BasicEntry::setCompressedSize( uint32 size ) {
103
 
}
104
 
 
105
 
void BasicEntry::setCrc( uint32 crc ) {
106
 
}
107
 
 
108
 
void BasicEntry::setExtra( const vector< unsigned char > &extra ) {
109
 
}
110
 
 
111
 
void BasicEntry::setMethod( StorageMethod method ) {
112
 
}
113
 
 
114
 
void BasicEntry::setName( const string &name ) {
115
 
  _filename = name ;
116
 
}
117
 
 
118
 
void BasicEntry::setSize( uint32 size ) {
119
 
  _size = size ;
120
 
}
121
 
 
122
 
void BasicEntry::setTime( int time ) {
123
 
}
124
 
 
125
 
 
126
 
string BasicEntry::toString() const {
127
 
  OutputStringStream sout ;
128
 
  sout << _filename << " (" << _size << " bytes)" ;
129
 
  return sout.str() ;
130
 
}
131
 
 
132
 
FileEntry *BasicEntry::clone() const {
133
 
  return new BasicEntry( *this ) ;
134
 
}
135
 
 
136
 
BasicEntry::~BasicEntry() {
137
 
}
138
 
 
139
 
 
140
 
} // namespace
141
 
 
142
 
/** \file
143
 
    Implementation of BasicEntry.
144
 
*/
145
 
 
146
 
/*
147
 
  Zipios++ - a small C++ library that provides easy access to .zip files.
148
 
  Copyright (C) 2000  Thomas S�ndergaard
149
 
  
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.
154
 
  
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.
159
 
  
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
163
 
*/