Changeset 7a75401 in tol
- Timestamp:
- Jun 24, 2010, 1:52:18 PM (16 years ago)
- Branches:
- 1941-docker-image-to-test, devel, master
- Children:
- c92c7d9
- Parents:
- 4e559163
- Location:
- tol/PackArchive
- Files:
-
- 2 edited
-
PackArchive.cpp (modified) (3 diffs)
-
StoreZipArchive.cpp (modified) (19 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tol/PackArchive/PackArchive.cpp
r4e559163 r7a75401 48 48 HashStoreByHandle Store::_instances; 49 49 bool Store::_isInitialized = false; 50 int Store::_uniqueId = 0; 51 50 int Store::_uniqueId = 1; 51 52 bool _Store_initialize_ = Store::Initialize(); 52 53 53 54 … … 164 165 //-------------------------------------------------------------------- 165 166 DeclareContensClass(BDat, BDatTemporary, BDatPackArchiveOpen); 166 DefExtOpr(1, BDatPackArchiveOpen, "PackArchive.Open", 1, 1, "Text", 167 DefExtOpr(1, BDatPackArchiveOpen, "PackArchive.Open", 168 3, 3, "Text Text Text", 167 169 "(Text engine, Text path, Text openMode)", 168 170 I2("Open a packed archive for reading if openMode=='r' or writing " … … 197 199 if(store) 198 200 { 201 store->Close(); 199 202 delete store; 200 203 contens_ = true; -
tol/PackArchive/StoreZipArchive.cpp
r4e559163 r7a75401 47 47 //-------------------------------------------------------------------- 48 48 { 49 _errMsg[0]='\0'; 49 50 _path = path; 50 51 _openMode = openMode; … … 55 56 { 56 57 remove(_path); 57 _zip.Open(_path , CZipArchive::zipCreate);58 _zip.Open(_path.String(), CZipArchive::zipCreate); 58 59 } 59 60 else if(openMode=='r') 60 61 { 61 _zip.Open(_path , CZipArchive::zipOpenReadOnly, false);62 _zip.Open(_path.String(), CZipArchive::zipOpenReadOnly, false); 62 63 } 63 64 } … … 81 82 //-------------------------------------------------------------------- 82 83 { 84 _errMsg[0]='\0'; 83 85 if(_openMode == ' ') { return(true); } 84 86 bool ok = true; … … 107 109 //-------------------------------------------------------------------- 108 110 { 109 bool ok = true; 110 try 111 { 112 _zip.AddNewFile(originalFilePath); 111 _errMsg[0]='\0'; 112 bool ok = true; 113 try 114 { 115 _zip.AddNewFile(originalFilePath.String()); 113 116 } 114 117 catch(CZipException ex) … … 120 123 (LPCTSTR)ex.GetErrorDescription()); 121 124 } 125 if(!ok) { Error(_errMsg); } 122 126 return(ok); 123 127 } … … 129 133 //-------------------------------------------------------------------- 130 134 { 131 bool ok = true; 132 try 133 { 134 int index = _zip.FindFile(originalFilePath); 135 _errMsg[0]='\0'; 136 bool ok = true; 137 try 138 { 139 int index = _zip.FindFile(originalFilePath.String()); 135 140 if((index>=0) && (index!=ZIP_FILE_INDEX_NOT_FOUND)) 136 141 { 137 _zip.ExtractFile(index, destinationDirPath );142 _zip.ExtractFile(index, destinationDirPath.String()); 138 143 } 139 144 else … … 151 156 (LPCTSTR)ex.GetErrorDescription()); 152 157 } 158 if(!ok) { Error(_errMsg); } 153 159 return(ok); 154 160 } … … 160 166 //-------------------------------------------------------------------- 161 167 { 168 _errMsg[0]='\0'; 162 169 int index = -1; 163 170 bool ok = false; 164 171 try 165 172 { 166 index = _zip.FindFile(originalFilePath );173 index = _zip.FindFile(originalFilePath.String()); 167 174 ok = ((index>=0) && (index!=ZIP_FILE_INDEX_NOT_FOUND)); 168 175 } … … 175 182 (LPCTSTR)ex.GetErrorDescription()); 176 183 } 184 if(!ok) { Error(_errMsg); } 177 185 return(ok); 178 186 } … … 184 192 //-------------------------------------------------------------------- 185 193 { 194 _errMsg[0]='\0'; 186 195 bool ok = true; 187 196 try … … 193 202 ZipArchiveLib::CNameFileFilter::toAll); 194 203 // This will include empty directories 195 _zip.AddNewFiles(originalDirPath , filter);204 _zip.AddNewFiles(originalDirPath.String(), filter); 196 205 } 197 206 catch(CZipException ex) … … 203 212 (LPCTSTR)ex.GetErrorDescription()); 204 213 } 214 if(!ok) { Error(_errMsg); } 205 215 return(ok); 206 216 } … … 212 222 //-------------------------------------------------------------------- 213 223 { 224 _errMsg[0]='\0'; 214 225 bool ok = true; 215 226 try … … 218 229 // find files using wildcards 219 230 //zip.FindMatches(_T("file?.*"), indexes); 220 _zip.FindMatches(_T(originalDirPath+"/*"), indexes);221 _ tprintf(_T("Matches found at positions:\r\n"));231 BText match = originalDirPath; 232 _zip.FindMatches(match.String(), indexes); 222 233 ok = indexes.GetCount()>0; 234 if(!ok) 235 { 236 sprintf(_errMsg, "[ZipArchive] Cannot find files to extract from archive " 237 "%s matching pattern '%s'", 238 _path.String(), 239 match.String()); 240 } 223 241 for (ZIP_ARRAY_SIZE_TYPE i = 0; i < indexes.GetCount(); i++) 224 242 { … … 229 247 { 230 248 ok = false; 231 sprintf(_errMsg, "[ZipArchive] Error while extracting from archive %s file %s to %s: %s", 249 sprintf(_errMsg, "[ZipArchive] Error while extracting from archive %s file " 250 "%s to %s: %s", 232 251 _path.String(), 233 252 originalDirPath.String(), … … 235 254 (LPCTSTR)ex.GetErrorDescription()); 236 255 } 256 if(!ok) { Error(_errMsg); } 237 257 return(ok); 238 258 }; … … 244 264 //-------------------------------------------------------------------- 245 265 { 266 _errMsg[0]='\0'; 246 267 bool ok = true; 247 268 try … … 250 271 // find files using wildcards 251 272 //zip.FindMatches(_T("file?.*"), indexes); 252 _zip.FindMatches(_T(originalDirPath+"/*"), indexes);253 _ tprintf(_T("Matches found at positions:\r\n"));273 BText match = originalDirPath+"/*"; 274 _zip.FindMatches(match.String(), indexes); 254 275 ok = indexes.GetCount()>0; 255 276 } … … 262 283 (LPCTSTR)ex.GetErrorDescription()); 263 284 } 285 if(!ok) { Error(_errMsg); } 264 286 return(ok); 265 287 };
Note: See TracChangeset
for help on using the changeset viewer.
