nulib2/nulib2/Delete.c

46 lines
1011 B
C
Raw Normal View History

2000-05-23 01:55:31 +00:00
/*
* Nulib2
2007-02-19 23:11:55 +00:00
* Copyright (C) 2000-2007 by Andy McFadden, All Rights Reserved.
2000-05-23 01:55:31 +00:00
* This is free software; you can redistribute it and/or modify it under the
2007-02-19 23:11:55 +00:00
* terms of the BSD License, see the file COPYING.
2000-05-23 01:55:31 +00:00
*
* Delete files from the archive.
*/
#include "Nulib2.h"
/*
* Delete the specified files.
*
* This uses the "bulk" delete call, allowing the SelectionFilter callback
* to do the matching against specified filenames.
*/
NuError DoDelete(NulibState* pState)
2000-05-23 01:55:31 +00:00
{
NuError err;
2014-12-22 02:17:23 +00:00
NuArchive* pArchive = NULL;
2000-05-23 01:55:31 +00:00
2014-12-22 02:17:23 +00:00
Assert(pState != NULL);
2000-05-23 01:55:31 +00:00
err = OpenArchiveReadWrite(pState);
if (err != kNuErrNone)
goto bail;
pArchive = NState_GetNuArchive(pState);
2014-12-22 02:17:23 +00:00
Assert(pArchive != NULL);
2000-05-23 01:55:31 +00:00
NState_SetMatchCount(pState, 0);
2000-05-23 01:55:31 +00:00
err = NuDelete(pArchive);
if (err != kNuErrNone)
goto bail;
2000-05-23 01:55:31 +00:00
if (!NState_GetMatchCount(pState))
printf("%s: no records matched\n", gProgName);
2000-05-23 01:55:31 +00:00
bail:
2014-12-22 02:17:23 +00:00
if (pArchive != NULL)
(void) NuClose(pArchive);
return err;
2000-05-23 01:55:31 +00:00
}