/****************************************************************************/
/* Copyright 2003 MBARI														*/
/****************************************************************************/
/* Summary	: Definitions for File I/O Routines for OASIS3 Data Logging		*/
/* Filename : file.h														*/
/* Author	: Robert Herlien (rah)											*/
/* Project	: OASIS Mooring Replacement (OASIS3)							*/
/* Revision : 1.0															*/
/* Created	: 01/30/2003													*/
/*																			*/
/* MBARI provides this documentation and code "as is", with no warranty,	*/
/* express or implied, of its quality or consistency. It is provided without*/
/* support and without obligation on the part of the Monterey Bay Aquarium	*/
/* Research Institute to assist in its use, correction, modification, or	*/
/* enhancement. This information should not be published or distributed to	*/
/* third parties without specific written permission from MBARI.			*/
/*																			*/
/****************************************************************************/
/* Modification History:													*/
/* 30jan2003 rah - created													*/
/****************************************************************************/

#ifndef INCfileh
#define INCfileh		1


#include <oasis.h>						/* OASIS controller definitions		*/
#include "fatfs/ff.h"					/* FatFs file system definitions	*/
#include <log.h>						/* Log record definitions			*/

#define DRIVE			2				/* 'C' Drive						*/
#define FILEPATH		"C:"
#define FILENAME_SIZE	16
#define DATA_FILEFMT	"OAS%05lu.DAT"
#define INDEX_FILEFMT	"OAS%05lu.IDX"

#define AM_VOL			0x08			/* Removed from FatFs v0.12a for some reason?*/

typedef struct							/************************************/
{										/* Used by findLogFiles				*/
  LogBlk		minNum;					/* Smallest number of "OASnnnnn.*"	*/
  LogBlk		maxNum;					/* Largest number of "OASnnnnn.*"	*/
  Nat32			maxNumSize;				/* Size of file of maxNum			*/
} FileFound;							/************************************/


/****************************************/
/* Function Declarations				*/
/****************************************/

Errno	file_init(void);
void	takeFileSem(void);
void	giveFileSem(void);
void	fperr(int errnum, const char *s);
Int32	dirScan(char *matchStr, MBool (*func)(FILINFO *, void *), void *parm);
void	file_findLogFiles(LogPtr *newest, LogPtr *oldest);
CmdRtn	usrType(ParmMask_t pmask, char *fileName);
CmdRtn	usrMore(ParmMask_t pmask, char *fileName);
CmdRtn	usrCopy(ParmMask_t pmask, char *src, char *dst);
MBool	dirFileDelete(FILINFO *de, void *p);
CmdRtn	usrDelete(ParmMask_t pmask, char *fileName);
CmdRtn	usrRename(ParmMask_t pmask, char *oldName, char *newName);
CmdRtn	usrHexDump(ParmMask_t pmask, char *fileName, Parm_t start, Parm_t len);
CmdRtn	usrDir(ParmMask_t pmask, char *matchstr);
CmdRtn	deleteLine(ParmMask_t pmask, Nat32 linenum, char *filename);
CmdRtn	deleteChars(ParmMask_t pmask, Nat32 linenum, char *filename, Nat32 numchars);
CmdRtn	insertLine(ParmMask_t pmask, Nat32 linenum, char *filename);
CmdRtn	insertChars(ParmMask_t pmask, Nat32 linenum, char *filename);

#endif /* INCfileh */
