archive.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655
  1. /*##############################################################################
  2. HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems®.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. ############################################################################## */
  13. #include "platform.h"
  14. #ifdef _WIN32
  15. #define S_ISDIR(m) (((m)&_S_IFDIR)!=0)
  16. #endif
  17. #include "jlib.hpp"
  18. #include "jio.hpp"
  19. #include "jmutex.hpp"
  20. #include "jfile.hpp"
  21. #include "jlog.hpp"
  22. #include "jregexp.hpp"
  23. #include "archive.hpp"
  24. #include <sys/stat.h>
  25. #include <archive.h>
  26. #include <archive_entry.h>
  27. /*
  28. * Direct access to files in zip archives (and other libarchive-supported formats), without needing to extract them first
  29. * Installs hooks into createIFile, spotting filenames of the form /my/directory/myfile.zip/{password}/path/within/archive
  30. */
  31. #ifdef _WIN32
  32. #define ARCHIVE_SIGNATURE "[.]{zip|tar|tar[.]gz|tgz}{$|/|\\\\}"
  33. #else
  34. #define ARCHIVE_SIGNATURE "[.]{zip|tar|tar[.]gz|tgz}{$|/}"
  35. #endif
  36. static RegExpr *signature;
  37. static SpinLock *lock;
  38. static const char *splitName(const char *fileName)
  39. {
  40. if (!fileName)
  41. return NULL;
  42. SpinBlock b(*lock);
  43. const char *sig = signature->find(fileName);
  44. if (sig)
  45. return sig+signature->findlen();
  46. else
  47. return NULL;
  48. }
  49. static void splitArchivedFileName(const char *fullName, StringAttr &container, StringAttr &option, StringAttr &relPath)
  50. {
  51. const char *tail = splitName(fullName);
  52. assertex(tail);
  53. size_t containerLen = tail-fullName;
  54. if (fullName[containerLen-1]==PATHSEPCHAR)
  55. containerLen--;
  56. container.set(fullName, containerLen);
  57. if (*tail=='{')
  58. {
  59. tail++;
  60. const char *end = strchr(tail, '}');
  61. if (!end)
  62. throw MakeStringException(0, "Invalid archive-embedded filename - no matching } found");
  63. option.set(tail, end - tail);
  64. tail = end+1;
  65. if (*tail==PATHSEPCHAR)
  66. tail++;
  67. else if (*tail != 0)
  68. throw MakeStringException(0, "Invalid archive-embedded filename - " PATHSEPSTR " expected after }");
  69. }
  70. else
  71. option.clear();
  72. if (tail && *tail)
  73. {
  74. StringBuffer s(tail);
  75. s.replace(PATHSEPCHAR, '/');
  76. relPath.set(s);
  77. }
  78. else
  79. relPath.clear();
  80. }
  81. static StringBuffer & buildArchivedFileName(StringBuffer &fullname, const char *archiveFile, const char *option, const char *relPath)
  82. {
  83. fullname.append(archiveFile);
  84. if (option && *option)
  85. fullname.append(PATHSEPCHAR).append('{').append(option).append('}');
  86. if (relPath && *relPath)
  87. fullname.append(PATHSEPCHAR).append(relPath);
  88. return fullname;
  89. }
  90. IDirectoryIterator *createArchiveDirectoryIterator(const char *gitFileName, const char *mask, bool sub, bool includeDirs);
  91. // Wrapper around libarchive's archive_entry struct to ensure we free them at right time
  92. // Because not clear whether safe to use a struct archive_entry object after the archive has been closed,
  93. // we copy the info we need out of them into something we CAN be sure of the lifespan of
  94. class ArchiveEntry : public CInterface, implements IInterface
  95. {
  96. public:
  97. IMPLEMENT_IINTERFACE;
  98. ArchiveEntry(struct archive_entry *entry)
  99. {
  100. mode = archive_entry_filetype(entry);
  101. filesize = archive_entry_size(entry);
  102. path.set(archive_entry_pathname(entry));
  103. accessTime = archive_entry_atime(entry);
  104. createTime = archive_entry_ctime(entry);
  105. modifiedTime = archive_entry_mtime(entry);
  106. }
  107. bool isDir() const
  108. {
  109. return S_ISDIR(mode);
  110. }
  111. inline offset_t size()
  112. {
  113. return filesize;
  114. }
  115. const char *pathname()
  116. {
  117. return path.get();
  118. }
  119. CDateTime &getAccessTime(CDateTime &t)
  120. {
  121. t.set(accessTime);
  122. return t;
  123. }
  124. CDateTime &getCreateTime(CDateTime &t)
  125. {
  126. t.set(createTime);
  127. return t;
  128. }
  129. CDateTime &getModifiedTime(CDateTime &t)
  130. {
  131. t.set(modifiedTime);
  132. return t;
  133. }
  134. private:
  135. unsigned mode;
  136. offset_t filesize;
  137. StringAttr path;
  138. time_t accessTime;
  139. time_t createTime;
  140. time_t modifiedTime;
  141. };
  142. // IFileIO implementation for reading out of libarchive-supported archives
  143. // Because of the nature of the libarchive this may not be efficient for some archive formats
  144. // Have to read through the entire archive directory to find the bit you want, it seems
  145. // It's possible that we could add some seek support to at least avoid having to do so twice?
  146. class ArchiveFileIO : public CInterface, implements IFileIO
  147. {
  148. public:
  149. IMPLEMENT_IINTERFACE;
  150. ArchiveFileIO(const char *_fullName) : fullName(_fullName)
  151. {
  152. // Sadly it seems we can't use a saved entry to read data from an archive. We have to open a new archive
  153. // object and scan through until we find the matching file, in order to extract it.
  154. StringAttr container, option, relpath;
  155. splitArchivedFileName(_fullName, container, option, relpath);
  156. curPos = 0;
  157. lastPos = 0;
  158. curBuffSize = 0;
  159. curBuff = NULL;
  160. archive = archive_read_new();
  161. #ifdef _WIN32
  162. archive_read_support_format_zip(archive);
  163. archive_read_support_format_tar(archive);
  164. archive_read_support_compression_bzip2(archive);
  165. #else
  166. archive_read_support_format_all(archive);
  167. #if (ARCHIVE_VERSION_NUMBER >= 3000000)
  168. archive_read_support_filter_all(archive);
  169. #else
  170. archive_read_support_compression_all(archive);
  171. #endif
  172. #endif
  173. int retcode = archive_read_open_filename(archive, container, 10240);
  174. if (retcode == ARCHIVE_OK)
  175. {
  176. struct archive_entry *entry = archive_entry_new();
  177. while (archive_read_next_header2(archive, entry) == ARCHIVE_OK)
  178. {
  179. const char *filename = archive_entry_pathname(entry);
  180. if (strcmp(filename, relpath.get())==0)
  181. {
  182. fileSize = archive_entry_size(entry);
  183. break;
  184. }
  185. }
  186. archive_entry_free(entry);
  187. }
  188. }
  189. ~ArchiveFileIO()
  190. {
  191. #if (ARCHIVE_VERSION_NUMBER >= 3000000)
  192. archive_read_free(archive);
  193. #else
  194. archive_read_finish(archive);
  195. #endif
  196. }
  197. virtual size32_t read(offset_t pos, size32_t len, void * _data)
  198. {
  199. // NOTE - we don't support multithreaded access (the sequential-only restriction would make that tricky anyway)
  200. if (pos < lastPos)
  201. throw MakeStringException(0, "Only sequential access to contained file %s supported", fullName.get());
  202. byte *data = (byte *) _data;
  203. size32_t lenRequested = len;
  204. while (len > 0 && pos < fileSize)
  205. {
  206. if (pos >= curPos+curBuffSize)
  207. {
  208. int ret = archive_read_data_block(archive, &curBuff, &curBuffSize, &curPos);
  209. if (ret != ARCHIVE_OK)
  210. {
  211. if (ret == ARCHIVE_EOF)
  212. break; // This shouldn't happen if the quoted fileSize was accurate...
  213. else
  214. throw MakeStringException(0, "Read error reading contained file %s", fullName.get());
  215. }
  216. }
  217. else
  218. {
  219. // Copy as much of the current request as we can fulfil from this block
  220. offset_t buffOffset = (pos - curPos);
  221. size_t copyLen = (curBuffSize - buffOffset) > len ? len : curBuffSize - buffOffset; // careful for overflows, we are mixing 64/32bit values
  222. if (curBuff)
  223. memcpy(data, ((const byte *) curBuff) + buffOffset, copyLen);
  224. else
  225. memset(data, 0, copyLen); // Sparse areas of compressed files may be represented with NULL buffers
  226. data += copyLen;
  227. len -= copyLen;
  228. pos += copyLen;
  229. }
  230. }
  231. lastPos = pos;
  232. return lenRequested - len;
  233. }
  234. virtual offset_t size()
  235. {
  236. return fileSize;
  237. }
  238. virtual void close()
  239. {
  240. }
  241. // Write methods not implemented - this is a read-only file
  242. virtual size32_t write(offset_t pos, size32_t len, const void * data)
  243. {
  244. throwUnexpected();
  245. }
  246. virtual offset_t appendFile(IFile *file,offset_t pos=0,offset_t len=(offset_t)-1)
  247. {
  248. throwUnexpected();
  249. }
  250. virtual void setSize(offset_t size)
  251. {
  252. throwUnexpected();
  253. }
  254. virtual void flush()
  255. {
  256. throwUnexpected();
  257. }
  258. unsigned __int64 getStatistic(StatisticKind kind)
  259. {
  260. return 0;
  261. }
  262. protected:
  263. struct archive *archive;
  264. offset_t fileSize;
  265. #if ARCHIVE_VERSION_NUMBER < 3000000
  266. off_t curPos;
  267. #else
  268. #if defined(_WIN32)
  269. #define int64_t __int64
  270. #endif
  271. int64_t curPos;
  272. #endif
  273. offset_t lastPos;
  274. size_t curBuffSize;
  275. const void *curBuff;
  276. StringAttr fullName;
  277. };
  278. // IFile implementation for reading out of libarchive-supported archives
  279. // These use the struct_archive_entry objects allocated in the directory iterator
  280. // in the hope they might be useful for directly seeking to the file to be extracted
  281. // at some point.
  282. class ArchiveFile : public CInterface, implements IFile
  283. {
  284. public:
  285. IMPLEMENT_IINTERFACE;
  286. ArchiveFile(const char *_fileName, ArchiveEntry *_entry)
  287. : fullName(_fileName),entry(_entry)
  288. {
  289. }
  290. virtual bool exists()
  291. {
  292. return entry != NULL;
  293. }
  294. virtual bool getTime(CDateTime * createTime, CDateTime * modifiedTime, CDateTime * accessedTime)
  295. {
  296. if (entry)
  297. {
  298. if (accessedTime)
  299. entry->getAccessTime(*accessedTime);
  300. if (createTime)
  301. entry->getCreateTime(*createTime);
  302. if (modifiedTime)
  303. entry->getModifiedTime(*modifiedTime);
  304. return true;
  305. }
  306. else
  307. return false;
  308. }
  309. virtual fileBool isDirectory()
  310. {
  311. if (!entry)
  312. return notFound;
  313. return entry->isDir() ? foundYes : foundNo;
  314. }
  315. virtual fileBool isFile()
  316. {
  317. if (!entry)
  318. return notFound;
  319. return entry->isDir() ? foundNo : foundYes;
  320. }
  321. virtual fileBool isReadOnly()
  322. {
  323. if (!entry)
  324. return notFound;
  325. return foundYes;
  326. }
  327. virtual IFileIO * open(IFOmode mode, IFEflags extraFlags=IFEnone)
  328. {
  329. assertex(mode==IFOread && entry != NULL);
  330. return new ArchiveFileIO(fullName.str());
  331. }
  332. virtual IFileAsyncIO * openAsync(IFOmode mode)
  333. {
  334. UNIMPLEMENTED;
  335. }
  336. virtual IFileIO * openShared(IFOmode mode, IFSHmode shmode, IFEflags extraFlags=IFEnone)
  337. {
  338. assertex(mode==IFOread && entry != NULL);
  339. return new ArchiveFileIO(fullName.str());
  340. }
  341. virtual const char * queryFilename()
  342. {
  343. return fullName.str();
  344. }
  345. virtual offset_t size()
  346. {
  347. if (!entry)
  348. return 0;
  349. return entry->size();
  350. }
  351. // Directory functions
  352. virtual IDirectoryIterator *directoryFiles(const char *mask, bool sub, bool includeDirs)
  353. {
  354. if (isDirectory() != foundYes || (mask && !*mask)) // Empty mask string means matches nothing - NULL means matches everything
  355. return createNullDirectoryIterator();
  356. else
  357. {
  358. StringBuffer dirName(fullName);
  359. dirName.append(PATHSEPCHAR);
  360. return createArchiveDirectoryIterator(dirName, mask, sub, includeDirs);
  361. }
  362. }
  363. virtual bool getInfo(bool &_isdir,offset_t &_size,CDateTime &_modtime)
  364. {
  365. _isdir = isDirectory()==foundYes;
  366. _size = size();
  367. _modtime.clear(); // MORE could probably do better
  368. return true; // MORE should this be false if not existing?
  369. }
  370. // Not going to be implemented - this IFile interface is too big..
  371. virtual bool setTime(const CDateTime * createTime, const CDateTime * modifiedTime, const CDateTime * accessedTime) { UNIMPLEMENTED; }
  372. virtual bool remove() { UNIMPLEMENTED; }
  373. virtual void rename(const char *newTail) { UNIMPLEMENTED; }
  374. virtual void move(const char *newName) { UNIMPLEMENTED; }
  375. virtual void setReadOnly(bool ro) { UNIMPLEMENTED; }
  376. virtual bool setCompression(bool set) { UNIMPLEMENTED; }
  377. virtual offset_t compressedSize() { UNIMPLEMENTED; }
  378. virtual unsigned getCRC() { UNIMPLEMENTED; }
  379. virtual void setCreateFlags(unsigned short cflags) { UNIMPLEMENTED; }
  380. virtual void setShareMode(IFSHmode shmode) { UNIMPLEMENTED; }
  381. virtual bool createDirectory() { UNIMPLEMENTED; }
  382. virtual IDirectoryDifferenceIterator *monitorDirectory(
  383. IDirectoryIterator *prev=NULL, // in (NULL means use current as baseline)
  384. const char *mask=NULL,
  385. bool sub=false,
  386. bool includedirs=false,
  387. unsigned checkinterval=60*1000,
  388. unsigned timeout=(unsigned)-1,
  389. Semaphore *abortsem=NULL) { UNIMPLEMENTED; }
  390. virtual void copySection(const RemoteFilename &dest, offset_t toOfs=(offset_t)-1, offset_t fromOfs=0, offset_t size=(offset_t)-1, ICopyFileProgress *progress=NULL, CFflags copyFlags=CFnone) { UNIMPLEMENTED; }
  391. virtual void copyTo(IFile *dest, size32_t buffersize=DEFAULT_COPY_BLKSIZE, ICopyFileProgress *progress=NULL, bool usetmp=false, CFflags copyFlags=CFnone) { UNIMPLEMENTED; }
  392. virtual IMemoryMappedFile *openMemoryMapped(offset_t ofs=0, memsize_t len=(memsize_t)-1, bool write=false) { UNIMPLEMENTED; }
  393. virtual void treeCopyTo(IFile *dest,IpSubNet &subnet,IpAddress &resfrom,bool usetmp=false,CFflags copyFlags=CFnone) { UNIMPLEMENTED; }
  394. protected:
  395. StringBuffer fullName;
  396. Linked<ArchiveEntry> entry;
  397. };
  398. static IFile *createIFileInArchive(const char *containedFileName)
  399. {
  400. StringBuffer fname(containedFileName);
  401. assertex(fname.length());
  402. removeTrailingPathSepChar(fname);
  403. StringAttr container, option, relpath;
  404. splitArchivedFileName(fname.str(), container, option, relpath);
  405. if (relpath.length())
  406. {
  407. StringBuffer dirPath, dirTail;
  408. dirPath.append(container).append(option);
  409. splitFilename(relpath, &dirPath, &dirPath, &dirTail, &dirTail);
  410. Owned<IDirectoryIterator> dir = createArchiveDirectoryIterator(dirPath.str(), dirTail.str(), false, true);
  411. if (dir->first())
  412. {
  413. Linked<IFile> file = &dir->query();
  414. assertex(!dir->next());
  415. return file.getClear();
  416. }
  417. else
  418. return new ArchiveFile(containedFileName, NULL);
  419. }
  420. else
  421. {
  422. // Create an IFile representing the root of the archive as a directory
  423. struct archive_entry *rootEntry = archive_entry_new();
  424. archive_entry_set_pathname(rootEntry, ".");
  425. archive_entry_set_mode(rootEntry, S_IFDIR);
  426. archive_entry_set_size(rootEntry, 0);
  427. return new ArchiveFile(containedFileName, new ArchiveEntry(rootEntry));
  428. }
  429. }
  430. class ArchiveDirectoryIterator : public CInterface, implements IDirectoryIterator
  431. {
  432. public:
  433. IMPLEMENT_IINTERFACE;
  434. ArchiveDirectoryIterator(const char *_containedFileName, const char *_mask, bool _sub, bool _includeDirs)
  435. : mask(_mask), sub(_sub), includeDirs(_includeDirs)
  436. {
  437. splitArchivedFileName(_containedFileName, container, option, relDir);
  438. curIndex = 0;
  439. }
  440. virtual StringBuffer &getName(StringBuffer &buf)
  441. {
  442. assertex(curFile);
  443. return buf.append(curFile->queryFilename());
  444. }
  445. virtual bool isDir()
  446. {
  447. assertex(curFile);
  448. return curFile->isDirectory();
  449. }
  450. virtual __int64 getFileSize()
  451. {
  452. assertex(curFile);
  453. return curFile->size();
  454. }
  455. virtual bool getModifiedTime(CDateTime &ret)
  456. {
  457. UNIMPLEMENTED;
  458. }
  459. virtual bool first()
  460. {
  461. curFile.clear();
  462. entries.kill();
  463. curIndex = 0;
  464. struct archive *archive = archive_read_new();
  465. #ifdef _WIN32
  466. archive_read_support_format_zip(archive);
  467. archive_read_support_format_tar(archive);
  468. archive_read_support_compression_bzip2(archive);
  469. #else
  470. archive_read_support_format_all(archive);
  471. #if (ARCHIVE_VERSION_NUMBER >= 3000000)
  472. archive_read_support_filter_all(archive);
  473. #else
  474. archive_read_support_compression_all(archive);
  475. #endif
  476. #endif
  477. int retcode = archive_read_open_filename(archive, container, 10240);
  478. if (retcode == ARCHIVE_OK)
  479. {
  480. struct archive_entry *entry = archive_entry_new();
  481. while (archive_read_next_header2(archive, entry) == ARCHIVE_OK)
  482. {
  483. unsigned mode = archive_entry_filetype(entry);
  484. bool isDir = S_ISDIR(mode);
  485. if (includeDirs || !isDir)
  486. {
  487. const char *filename = archive_entry_pathname(entry);
  488. if (memcmp(filename, relDir.get(), relDir.length())==0)
  489. {
  490. StringBuffer tail(filename + relDir.length());
  491. if (tail.length())
  492. {
  493. if (tail.charAt(tail.length()-1)=='/' || tail.charAt(tail.length()-1)==PATHSEPCHAR)
  494. tail.remove(tail.length()-1, 1);
  495. }
  496. else
  497. {
  498. assert(isDir);
  499. tail.append(".");
  500. }
  501. // Strip off a trailing /, then check that there is no / in the tail
  502. if (strchr(tail, PATHSEPCHAR) == NULL && (!mask.length() || WildMatch(tail, mask, false)))
  503. {
  504. entries.append(*new ArchiveEntry(entry));
  505. }
  506. }
  507. }
  508. }
  509. archive_entry_free(entry);
  510. }
  511. #if (ARCHIVE_VERSION_NUMBER >= 3000000)
  512. archive_read_free(archive);
  513. #else
  514. archive_read_finish(archive);
  515. #endif
  516. return next();
  517. }
  518. virtual bool next()
  519. {
  520. if (entries.isItem(curIndex))
  521. {
  522. ArchiveEntry &entry = entries.item(curIndex);
  523. curIndex++;
  524. const char *filename = entry.pathname();
  525. StringBuffer containedFileName;
  526. buildArchivedFileName(containedFileName, container, option, filename);
  527. removeTrailingPathSepChar(containedFileName);
  528. curFile.setown(new ArchiveFile(containedFileName, &entry));
  529. return true;
  530. }
  531. else
  532. {
  533. curFile.clear();
  534. return false;
  535. }
  536. }
  537. virtual bool isValid() { return curFile != NULL; }
  538. virtual IFile & query() { return *curFile; }
  539. protected:
  540. StringAttr container;
  541. StringAttr option;
  542. StringAttr relDir;
  543. StringAttr mask;
  544. Owned<IFile> curFile;
  545. unsigned curIndex;
  546. IArrayOf<ArchiveEntry> entries; // The entries that matched
  547. bool includeDirs;
  548. bool sub;
  549. };
  550. IDirectoryIterator *createArchiveDirectoryIterator(const char *gitFileName, const char *mask, bool sub, bool includeDirs)
  551. {
  552. assertex(sub==false); // I don't know what it means!
  553. return new ArchiveDirectoryIterator(gitFileName, mask, sub, includeDirs);
  554. }
  555. class CArchiveFileHook : public CInterface, implements IContainedFileHook
  556. {
  557. public:
  558. IMPLEMENT_IINTERFACE;
  559. virtual IFile * createIFile(const char *fileName)
  560. {
  561. if (isArchiveFileName(fileName))
  562. return createIFileInArchive(fileName);
  563. else
  564. return NULL;
  565. }
  566. protected:
  567. static bool isArchiveFileName(const char *fileName)
  568. {
  569. if (fileName)
  570. return splitName(fileName) != NULL;
  571. return false;
  572. }
  573. } *archiveFileHook;
  574. extern ARCHIVEFILE_API void installFileHook()
  575. {
  576. SpinBlock b(*lock); // Probably overkill!
  577. if (!archiveFileHook)
  578. {
  579. archiveFileHook = new CArchiveFileHook;
  580. addContainedFileHook(archiveFileHook);
  581. }
  582. }
  583. extern ARCHIVEFILE_API void removeFileHook()
  584. {
  585. if (lock)
  586. {
  587. SpinBlock b(*lock); // Probably overkill!
  588. if (archiveFileHook)
  589. {
  590. removeContainedFileHook(archiveFileHook);
  591. delete archiveFileHook;
  592. archiveFileHook = NULL;
  593. }
  594. }
  595. }
  596. MODULE_INIT(INIT_PRIORITY_STANDARD)
  597. {
  598. lock = new SpinLock;
  599. signature = new RegExpr(ARCHIVE_SIGNATURE);
  600. archiveFileHook = NULL;
  601. return true;
  602. }
  603. MODULE_EXIT()
  604. {
  605. if (archiveFileHook)
  606. {
  607. removeContainedFileHook(archiveFileHook);
  608. archiveFileHook = NULL;
  609. }
  610. delete signature;
  611. delete lock;
  612. lock = NULL;
  613. signature = NULL;
  614. ::Release(archiveFileHook);
  615. }