/*static char *SCCSID = "@(#)fs_dlete.c	6.2 92/01/31";*/
#define _BTXT _BTXT

/*
 *	HISTORY
 *	    26-May-1989 by JR (John Rogers, JohnRo@Microsoft)
 *		- DCR 259.2: added counting of write threads for shutdown.
 *		- DCR 259.2: changed names of macros in "frame.h".
 */

#define INCL_DOSERRORS
#include <os2.h>
#include <fsh.h>
#include "heap.h"
#include "api.h"
#include "const.h"
#include "misc.h"
#include "chain.h"
#include "buf.h"
#include "dir.h"
#include "storage.h"
#include "volume.h"
#include "tables.h"
#include "pb_ifs.h"
#include "pbmacros.h"
#include "superb.h"
#include "lw.h"
#include "frame.h"
#include "fsdata.h"
#include "shutdown.h"
#include "pr_fsd.h"
#include "pr_CACHE.h"
#include "pr_DEL.h"
#include "pr_HEAP.h"
#include "pr_WRSUB.h"
#include "pr_DEBUG.h"

unsigned int cdecl strlen(char far *str);


int far pascal
FS_DELETE (pcdfsi, pcdfsd, pFile, iCurDirEnd)
struct cdfsi far *	pcdfsi;
struct cdfsd far *	pcdfsd;
char far *		pFile;
USHORT			iCurDirEnd;
{
	PCRACKEDPATH	pcp;
	SHUTDOWN_LOCAL_VARS;		/* Data for INCR/DECR_WRITE_THREADS. */
	USHORT		usRet;
	FRAME		frm;

	frm.usHardErr = NO_ERROR;
	frm.fRecheckAddr = TRUE;

	/* Keep track of write threads for shutdown. */
	INCR_WRITE_THREADS;

	if ((usRet = CrackPath (pcdfsi->cdi_hVPB,
				(PBYTE) pFile,
				&pcp,&frm)) == NO_ERROR) {
	    usRet = Delete (TRUE, pcp, &frm);
	}

	if (pcp != NULL)
	    RetHeap (pcp);

#ifdef DEBUG
	VBS ();
#endif

	/* Revise count of write threads (for shutdown). */
	DECR_WRITE_THREADS;

	return (usRet);

	pcdfsi; pcdfsd; iCurDirEnd;
}
