mirror of https://github.com/lianthony/NT4.0
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
90 lines
2.2 KiB
90 lines
2.2 KiB
/* delfile - deletes the given files from the project */
|
|
|
|
#include "precomp.h"
|
|
#pragma hdrstop
|
|
EnableAssert
|
|
|
|
private F FDirsEmpty(P1(AD *pad));
|
|
|
|
F FDelFInit(pad)
|
|
AD *pad;
|
|
{
|
|
CheckProjectDiskSpace(pad, cbProjectFreeMin);
|
|
|
|
return fTrue;
|
|
}
|
|
|
|
|
|
F FDelFDir(pad)
|
|
/* perform delfile operation for this directory */
|
|
AD *pad;
|
|
{
|
|
F fOk;
|
|
F fAny = fFalse;
|
|
|
|
if (!FDirsEmpty(pad))
|
|
return fFalse;
|
|
|
|
if (!FLoadStatus(pad, lckAll, flsNone))
|
|
return fFalse;
|
|
|
|
MarkFiForMarkedNeList(pad, pad->pneFiles);
|
|
|
|
OpenLog(pad, fTrue);
|
|
|
|
fOk = FDelFMarked(pad, &fAny);
|
|
if (fOk && pad->iedCur != iedNil)
|
|
fOk = FSyncMarked(pad, NULL);
|
|
|
|
CloseLog();
|
|
|
|
if (fAny)
|
|
ProjectChanged(pad);
|
|
|
|
if (pad->iedCur != iedNil)
|
|
SyncVerH(pad, NULL);
|
|
|
|
FlushStatus(pad);
|
|
|
|
return fOk;
|
|
}
|
|
|
|
|
|
private F FDirsEmpty(pad)
|
|
/* Ensure all directories in pad->pnefiles are empty. Marks deletable files
|
|
* and directories.
|
|
*/
|
|
AD *pad;
|
|
{
|
|
NE *pne;
|
|
F fEmpty;
|
|
|
|
ForEachNe(pne, pad->pneFiles)
|
|
{
|
|
CheckForBreak();
|
|
|
|
/* Determine if file/dir is empty. */
|
|
if (FDirNe(pne))
|
|
{
|
|
Warn("deleting directory %&P/C/%s will render its change history unavailable\n", pad, SzOfNe(pne));
|
|
ChngDir(pad, SzOfNe(pne));
|
|
if (!FLoadStatus(pad, lckNil, flsJustFi))
|
|
FatalError("can't load %&P/C status\n", pad);
|
|
|
|
fEmpty = FAllFiDel(pad);
|
|
if (fEmpty)
|
|
MarkNe(pne);
|
|
else
|
|
Error("directory %&P/C not empty, not deleted\n", pad);
|
|
|
|
FlushStatus(pad);
|
|
ChngDir(pad, "..");
|
|
|
|
if (!fEmpty && !FQContinue())
|
|
return fFalse;
|
|
}
|
|
else
|
|
MarkNe(pne);
|
|
}
|
|
return fTrue;
|
|
}
|