/****************************************************************************/
/* 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 <cfxpico.h>			/* For ulong							*/
#include <log.h>				/* Log record definitions				*/

typedef short	dsdfunc(short, ulong, void *, short);
typedef dsdfunc *dsdfp;

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

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				*/
/****************************************/

short	DSDReadSectorsPatch(short logdrv, ulong sector, 
							void *buffer, short count);
short	DSDWriteSectorsPatch(short logdrv, ulong sector, 
							 void *buffer, short count);
Errno	file_init(Void);
Void	file_pwrup(Void);
Void	takeFileSem(Void);
Void	giveFileSem(Void);
Void	dirScan(char *matchStr, MBool (*func)(struct dirent *, void *), void *parm);
Void	file_findLogFiles(LogPtr *newest, LogPtr *oldest);
Int16	usrType(Nat16 pmask, char *fileName);
Int16	usrMore(Nat16 pmask, char *fileName);
Int16	usrCopy(Nat16 pmask, char *src, char *dst);
MBool	dirFileDelete(struct dirent *de, void *p);
Int16	usrDelete(Nat16 pmask, char *fileName);
Int16	usrRename(Nat16 pmask, char *oldName, char *newName);
Int16	usrHexDump(Nat16 pmask, char *fileName, Parm_t start, Parm_t len);
Int16	usrCapture(Nat16 pmask, char *fileName, char *option, Parm_t parm2);
Int16	usrDir(Nat16 pmask, char *matchstr);
Void	file_coredump(Void);
Int16	deleteLine(Nat16 pmask, Nat32 linenum, char *filename);
Int16	deleteChars(Nat16 pmask, Nat32 linenum, char *filename, Nat32 numchars);
Int16	insertLine(Nat16 pmask, Nat32 linenum, char *filename);
Int16	insertChars(Nat16 pmask, Nat32 linenum, char *filename);

#endif /* INCfileh */
