/[pcsx2_0.9.7]/branch/debug/0.X/0.9.X/0.9.7/ramdump-lateset/pcsx2/ZipTools/ThreadedZipTools.h
ViewVC logotype

Contents of /branch/debug/0.X/0.9.X/0.9.7/ramdump-lateset/pcsx2/ZipTools/ThreadedZipTools.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 330 - (show annotations) (download)
Tue Dec 28 04:24:23 2010 UTC (9 years, 9 months ago) by william
File MIME type: text/plain
File size: 4359 byte(s)
merged upstream r4154-r4160
1 /* PCSX2 - PS2 Emulator for PCs
2 * Copyright (C) 2002-2010 PCSX2 Dev Team
3 *
4 * PCSX2 is free software: you can redistribute it and/or modify it under the terms
5 * of the GNU Lesser General Public License as published by the Free Software Found-
6 * ation, either version 3 of the License, or (at your option) any later version.
7 *
8 * PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
9 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
10 * PURPOSE. See the GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License along with PCSX2.
13 * If not, see <http://www.gnu.org/licenses/>.
14 */
15
16 #pragma once
17
18 #include "Utilities/PersistentThread.h"
19 #include "Utilities/pxStreams.h"
20 #include "wx/zipstrm.h"
21
22 using namespace Threading;
23
24 // --------------------------------------------------------------------------------------
25 // ArchiveEntry
26 // --------------------------------------------------------------------------------------
27 class ArchiveEntry
28 {
29 protected:
30 wxString m_filename;
31 uptr m_dataidx;
32 size_t m_datasize;
33
34 public:
35 ArchiveEntry( const wxString& filename=wxEmptyString )
36 : m_filename( filename )
37 {
38 m_dataidx = 0;
39 m_datasize = 0;
40 }
41
42 virtual ~ArchiveEntry() throw() {}
43
44 ArchiveEntry& SetDataIndex( uptr idx )
45 {
46 m_dataidx = idx;
47 return *this;
48 }
49
50 ArchiveEntry& SetDataSize( size_t size )
51 {
52 m_datasize = size;
53 return *this;
54 }
55
56 wxString GetFilename() const
57 {
58 return m_filename;
59 }
60
61 uptr GetDataIndex() const
62 {
63 return m_dataidx;
64 }
65
66 uint GetDataSize() const
67 {
68 return m_datasize;
69 }
70 };
71
72 typedef SafeArray< u8 > ArchiveDataBuffer;
73
74 // --------------------------------------------------------------------------------------
75 // ArchiveEntryList
76 // --------------------------------------------------------------------------------------
77 class ArchiveEntryList
78 {
79 DeclareNoncopyableObject( ArchiveEntryList );
80
81 protected:
82 std::vector<ArchiveEntry> m_list;
83 ScopedPtr<ArchiveDataBuffer> m_data;
84
85 public:
86 virtual ~ArchiveEntryList() throw() {}
87
88 ArchiveEntryList() {}
89
90 ArchiveEntryList( ArchiveDataBuffer* data )
91 {
92 m_data = data;
93 }
94
95 ArchiveEntryList( ArchiveDataBuffer& data )
96 {
97 m_data = &data;
98 }
99
100 const VmStateBuffer* GetBuffer() const
101 {
102 return m_data;
103 }
104
105 VmStateBuffer* GetBuffer()
106 {
107 return m_data;
108 }
109
110 u8* GetPtr( uint idx )
111 {
112 return &(*m_data)[idx];
113 }
114
115 const u8* GetPtr( uint idx ) const
116 {
117 return &(*m_data)[idx];
118 }
119
120 ArchiveEntryList& Add( const ArchiveEntry& src )
121 {
122 m_list.push_back( src );
123 return *this;
124 }
125
126 size_t GetLength() const
127 {
128 return m_list.size();
129 }
130
131 ArchiveEntry& operator[](uint idx)
132 {
133 return m_list[idx];
134 }
135
136 const ArchiveEntry& operator[](uint idx) const
137 {
138 return m_list[idx];
139 }
140 };
141
142 // --------------------------------------------------------------------------------------
143 // BaseCompressThread
144 // --------------------------------------------------------------------------------------
145 class BaseCompressThread
146 : public pxThread
147 {
148 typedef pxThread _parent;
149
150 protected:
151 pxOutputStream* m_gzfp;
152 ArchiveEntryList* m_src_list;
153 bool m_PendingSaveFlag;
154
155 wxString m_final_filename;
156
157 public:
158 virtual ~BaseCompressThread() throw();
159
160 BaseCompressThread& SetSource( ArchiveEntryList* srcdata )
161 {
162 m_src_list = srcdata;
163 return *this;
164 }
165
166 BaseCompressThread& SetSource( ArchiveEntryList& srcdata )
167 {
168 m_src_list = &srcdata;
169 return *this;
170 }
171
172 BaseCompressThread& SetOutStream( pxOutputStream* out )
173 {
174 m_gzfp = out;
175 return *this;
176 }
177
178 BaseCompressThread& SetOutStream( pxOutputStream& out )
179 {
180 m_gzfp = &out;
181 return *this;
182 }
183
184 BaseCompressThread& SetFinishedPath( const wxString& path )
185 {
186 m_final_filename = path;
187 return *this;
188 }
189
190 wxString GetStreamName() const { return m_gzfp->GetStreamName(); }
191
192 BaseCompressThread& SetTargetFilename(const wxString& filename)
193 {
194 m_final_filename = filename;
195 return *this;
196 }
197
198 protected:
199 BaseCompressThread()
200 {
201 m_PendingSaveFlag = false;
202 }
203
204 void SetPendingSave();
205 void ExecuteTaskInThread();
206 void OnCleanupInThread();
207 };

  ViewVC Help
Powered by ViewVC 1.1.22