/*static char *SCCSID = "@(#)fs_mkdir.c	6.2 91/01/14";*/
#define SCCSID "@(#)fs_mkdir.c	6.2 91/01/14"
/*
 *	IBM/Microsoft Confidential
 *
 *	Copyright (c) IBM Corporation 1987, 1989
 *	Copyright (c) Microsoft Corporation 1987, 1989
 *
 *	All Rights Reserved
 *
 */

/***    FS_MKDIR - Make subdirectory
 *      
 *      Create the specified directory
 *
 *
 *  REVISION HISTORY (in reverse chronological order)
 *  --------------------------------------------------------------------------
 *  2/22/90     Brian Andrew    Modified to simulate HPFS/FAT type response
 *                              when the disk would not need to be modified.
 *                              Return CDROM_WRITE_PROTECT otherwise.
 *  9/13/89     Paul Bingman    First CDROM version
 *  8/4/89      Brian Andrew    Initial blank template
 *
 *
 * TO DO
 * --------------------------------------------------------------------------
 *
 */


#define INCL_DOSERRORS
#define INCL_NOPMAPI
#include <os2.h>
#include <fsd.h>

#include "cdfs.h"
#include "sem.h"
#include "path.h"
#include "vol.h"
#include "file.h"
#include "buffer.h"
#include "mem.h"
#include "heap.h"
#include "pr_memin.h"

#ifdef DEBUG
#include "pr_DEBUG.h"
#endif


int far pascal
FS_MKDIR (PCDFSI    pcdfsi,
		  PCDFSD    pcdfsd,
		  PCHAR     pName,
		  USHORT    iCurDirEnd,
		  PCHAR     pEABuf,
		  USHORT    flags)
{

	USHORT  usRet;
	USHORT  afAttr;

#ifdef DEBUG
	dprintf ("FS_MKDIR(\"%Fs\", flags=%d)\n", pName, flags);
#endif

	/*
	 *  Check if the indended directory name already exists.  If it
	 *  does, return ERROR_ACCESS_DENIED.  Otherwise return
	 *  CDROM_WRITE_PROTECT.
	 */

	if (usRet = FS_FILEATTRIBUTE (
					FA_RETRIEVE,
					pcdfsi,
					pcdfsd,
					pName,
					iCurDirEnd,
					&afAttr))
	{
		/* Target not found, instead of creating, return write protect */
		usRet = CDROM_WRITE_PROTECT;
	}

	else
	{
		/* Directory creation dissallowed anyway. */
		usRet = ERROR_ACCESS_DENIED;
	}

#ifdef DEBUG
	dprintf ("\tFS_MKDIR: Return value -- %d \n", usRet);
#endif

	return usRet;

	/* defeat compiler warnings */

	pcdfsi;
	pcdfsd;
	pName;
	iCurDirEnd;
	pEABuf;
	flags;

}   /* end FS_MKDIR */

/* end of fs_mkdir.c */
