FreeCAD

Форк
0
/
zipinputstream.cpp 
89 строк · 2.6 Кб
1

2
#include "zipios-config.h"
3

4
#include "meta-iostreams.h"
5

6
#include "zipinputstreambuf.h"
7
#include "zipinputstream.h"
8
#if defined(_WIN32) && defined(ZIPIOS_UTF8)
9
#include <Base/FileInfo.h>
10
#endif
11

12
using std::istream;
13

14
namespace zipios {
15

16
ZipInputStream::ZipInputStream( std::istream &is, std::streampos pos ) 
17
  : std::istream( nullptr ), 
18
// SGIs basic_ifstream calls istream with 0, but calls basic_ios constructor first??
19
    ifs( nullptr )
20
{
21
  izf = new ZipInputStreambuf( is.rdbuf(), pos ) ;
22
//  this->rdbuf( izf ) ; is replaced by:
23
  this->init( izf ) ;
24
}
25

26
ZipInputStream::ZipInputStream( const std::string &filename, std::streampos pos )
27
  : std::istream( nullptr ),
28
    ifs( nullptr )
29
{
30
#if defined(_WIN32) && defined(ZIPIOS_UTF8)
31
  std::wstring wsname = Base::FileInfo(filename).toStdWString();
32
  ifs = new std::ifstream( wsname.c_str(), std::ios::in |std:: ios::binary ) ;
33
#else
34
  ifs = new std::ifstream( filename.c_str(), std::ios::in |std:: ios::binary ) ;
35
#endif
36
  izf = new ZipInputStreambuf( ifs->rdbuf(), pos ) ;
37
//  this->rdbuf( izf ) ; is replaced by:
38
  this->init( izf ) ;
39
}
40

41
int ZipInputStream::available() {
42
  return 1 ; // FIXME: Dummy implementation
43
}
44

45
void ZipInputStream::closeEntry() {
46
  izf->closeEntry() ;
47
}
48

49
void ZipInputStream::close() {
50
  izf->close() ;  
51
}
52

53
//    ZipLocalEntry *ZipInputStream::createZipCDirEntry( const string
54
//    &name ) {}
55

56
ConstEntryPointer ZipInputStream::getNextEntry() {
57
  clear() ; // clear eof and other flags.
58
  return izf->getNextEntry() ;
59
}
60

61
ZipInputStream::~ZipInputStream() {
62
  // It's ok to call delete with a Null pointer.
63
  delete izf ;
64
  delete ifs ;
65
}
66

67
} // namespace
68

69
/** \file
70
    Implementation of ZipInputStream.
71
*/
72

73
/*
74
  Zipios++ - a small C++ library that provides easy access to .zip files.
75
  Copyright (C) 2000  Thomas Søndergaard
76
  
77
  This library is free software; you can redistribute it and/or
78
  modify it under the terms of the GNU Lesser General Public
79
  License as published by the Free Software Foundation; either
80
  version 2 of the License, or (at your option) any later version.
81
  
82
  This library is distributed in the hope that it will be useful,
83
  but WITHOUT ANY WARRANTY; without even the implied warranty of
84
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
85
  Lesser General Public License for more details.
86
  
87
  You should have received a copy of the GNU Lesser General Public
88
  License along with this library; if not, write to the Free Software
89
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
90
*/
91

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.