eudora-mac/squish.c

1 line
12 KiB
C
Raw Permalink Normal View History

2018-05-23 09:59:15 +00:00
/* Copyright (c) 2017, Computer History Museum All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted (subject to the limitations in the disclaimer below) provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Computer History Museum nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "squish.h" #define FILE_NUM 44 #pragma segment Squish Boolean NeedsCompaction(FSSpecPtr spec,Boolean *opened); /************************************************************************ * DoCompact - compact all mailboxes ************************************************************************/ void DoCompact(short vRef,long dirId,CInfoPBRec *hfi,short suffixLen) { FSSpec thisOne, resolved; FSSpecHandle names; short count,item; short index; Boolean wasAlias; short err; Boolean newTOC = PrefIsSet(PREF_NEW_TOC); short badIndices[] = {ALIAS_FILE,CACHE_ALIAS_FILE,PERSONAL_ALIAS_FILE,LOG_NAME,OLD_LOG,FILTERS_NAME,SIG_FOLDER,NICK_FOLDER,PHOTO_FOLDER,ATTACH_FOLDER,STATION_FOLDER,SPOOL_FOLDER,ITEMS_FOLDER,LINK_HISTORY_FOLDER,0}; short bad; Boolean opened; Boolean bNeedsProgress = (dirId==MailRoot.dirId && SameVRef(vRef,MailRoot.vRef)) || (dirId==IMAPMailRoot.dirId && SameVRef(vRef,IMAPMailRoot.vRef)); /* * get started */ if ((names=NuHandle(0L))==nil) DieWithError(ALLO_MBOX_LIST,MemError()); /* * read names of mailbox files */ hfi->hFileInfo.ioNamePtr = thisOne.name; for (hfi->hFileInfo.ioFDirIndex=index=0;!DirIterate(vRef,dirId,hfi);hfi->hFileInfo.ioFDirIndex=++index) { /* * make an FSSpec out of the info */ thisOne.vRefNum = vRef; thisOne.parID = dirId; /* * skip special files */ if (dirId==Root.dirId && vRef==Root.vRef) { for (bad=0;badIndices[bad];bad++) if (EqualStrRes(thisOne.name,badIndices[bad])) break; if (badIndices[bad]) continue; } /* * if alias, resolve it and get hfi of new file */ resolved = thisOne; if ((err=ResolveAliasNoMount(&resolved,&resolved,&wasAlias)) && err!=fnfErr) continue; /* fnfErr in the above context means a directory */ if (wasAlias) { err = AFSpGetCatInfo(&resolved,&resolved,hfi); hfi->hFileInfo.ioNamePtr = thisOne.name; /* o the tangled webs we weave */ if (err) continue; } /* * directory; set name to zero to indicate that we want the directory, and follow * the alias (if any) */ if (0!=(hfi->hFileInfo.ioFlAttrib&0x10)) { thisOne.vRefNum = resolved.vRefNum; thisOne.parID = SpecDirId(&resolved); *thisOne.name = 0; } /* * regular file; we only need compact boxes with .toc's, so we look * only for .toc files */ else if (!newTOC) { if (hfi->hFileInfo.ioFlFndrInfo.fdType!=TOC_TYPE) continue; if (*thisOne.nam