/*
 *	File:					GetFile.h
 *	Description:s	Pop up a standard filerequester to let the user select a
 *								file.  Returns the selected path and file.
 *								NOTE! The pointer to the FileRequester must be freed when
 *											the program exits!
 *
 *	(C) 1993-1994, Ketil Hunn
 *
 */

#ifndef	GETFILE_H
#define	GETFILE_H

#define	INITWIDTH		1
#define	INITHEIGHT	190

#define ASL_V38_NAMES_ONLY

struct FileRequester *aslreq=NULL;

BOOL GetFile(	struct Window *window,
							char *title,
							char *input,
							char *pattern)
{
	if(aslreq==NULL)
		aslreq=MUI_AllocAslRequestTags(ASL_FileRequest,
											ASLFR_InitialWidth,			INITWIDTH,
											ASLFR_InitialHeight,		INITHEIGHT,
											ASLFR_Flags2,						FRF_REJECTICONS,
											TAG_DONE);
	if(aslreq)
	{
		char drawer[FMSIZE], *file;

		strcpy(drawer, input);
		file=FilePart(drawer);
		*PathPart(drawer)='\0';

		if(MUI_AslRequestTags(aslreq,
											ASLFR_Window,					window,
											ASLFR_SleepWindow,		window,
											ASLFR_TitleText,			title,
											ASLFR_Flags1,					FRF_DOPATTERNS,
											ASLFR_InitialDrawer,	drawer,
											ASLFR_InitialFile,		file,
											TAG_DONE))
		{
			strcpy(input, aslreq->fr_Drawer);
			AddPart(input, aslreq->fr_File, FNSIZE);
			return TRUE;
		}
	}
	return FALSE;
}

#endif
