/****************************************************************************/
/* Copyright 2003-2018 MBARI												*/
/****************************************************************************/
/* Summary	: File I/O Utilities for BEDS2 on PIC32MX470 using FatFs		*/
/* 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 INCfileUtilsh
#define INCfileUtilsh		1

#include <beds.h>						/* BEDS2 definitions				*/
#include <file.h>						/* BEDS file I/O definitions		*/
#include "fatfs/ff.h"					/* FatFs file system definitions	*/

#define DRIVE			2				/* 'C' Drive						*/
#define FILEPATH		"C:"
#define FILENAME_SIZE	16
#define AM_VOL			0x08			/* Removed from FatFs v0.12a for some reason?*/

#define BACKUP_FILES			5

typedef struct
{
	Nat32		entries;
	IdxRcd		index[0];
} IndexStruct;


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

Int32	dirScan(char *matchStr, MBool (*func)(FILINFO *, void *), void *parm);
Nat32	fileGetFreeSpace(void);
FRESULT setFileTime(char *fname, time_t ftime);
MBool	getNextRec(FIL *fp, FileRcdType rtype, RcdUnion *recp);
MBool	getAnyRec(FIL *fp, RcdUnion *recp);
FRESULT setFileTime(char *fname, time_t ftime);
MBool	dirFileDelete(FILINFO *de, void *p);
void	backupFile(const char *fileName, const char *backupName);
MBool	trueFunc(void);
MBool	magnitudeFunc(IdxRcd *idx1, IdxRcd *idx2);
IndexStruct *createSortedIndex(char *fname, MBool (*compareFunc)());
CmdRtn	usrType(int argc, char **argv);
CmdRtn	usrMore(int argc, char **argv);
CmdRtn	usrCopy(int argc, char **argv);
CmdRtn	usrDelete(int argc, char **argv);
CmdRtn	usrRename(int argc, char **argv);
CmdRtn	usrHexDump(int argc, char **argv);
CmdRtn	usrDir(int argc, char **argv);
CmdRtn	usrTail(int argc, char **argv);
CmdRtn	usrChdir(int argc, char **argv);
CmdRtn	usrPwd(int argc, char **argv);
CmdRtn	usrMkdir(int argc, char **argv);
CmdRtn	deleteLine(int argc, char **argv);
CmdRtn	deleteChars(int argc, char **argv);
CmdRtn	insertLine(int argc, char **argv);
CmdRtn	insertChars(int argc, char **argv);

#endif /* INCfileh */
