/*<html><pre>*/
#ifndef		V_FS_H
#define		V_FS_H

/*	IOCTL codes for different objects */
#include	"v_ioctl.h"

typedef	vhandle_t file_t;	/* IO port handle */

/*		Returned by file->seek() and file->tell() on error */
#define	INVALID_IO_OFFSET		0xFFFFFFFF

#ifdef	__cplusplus
extern "C" {
#endif	/* __cplusplus */
#ifndef	RIGHT_SLASHED
	vboolean	V_GLOBAL	fsAreApisUnix(void);
	void		V_GLOBAL	fsSetApisUnix(void);
	void		V_GLOBAL	fsSetApisNative(void);
	vboolean	V_GLOBAL	fsNative2Unix(char *unix_name,char *dos_name);
	vboolean	V_GLOBAL	fsUnix2Native(char *dos_name,char *unix_name);
#endif	/* !RIGHT_SLASHED */
	/*	========== FS service routines ================================ */
	/*	Enumerates contents of current directory (and, optionally, all
	 *	subdirectories).
	 *	Input:
	 *		- dir_callback (can be NULL): caller - supplied callback
	 *			for directories;
	 *		- file_callback (can be NULL): caller - supplied callback
	 *			for files;
	 *		- recursive: if nonzero, fsScan enumerates all subdirs.
	 *	Notes.
	 *		1. dir_callback always called BEFORE directory processing;
	 *	for example, if recursive == 0 than fsScan called 'dir_callback',
	 *	and than, for all files in directory, 'file_callback'.
	 *		2. Under MS OSes, names of files and directories passed in
	 *	UNIX - style: "c:\winnt" becomes "//c/winnt", etc.
	 */
	void		V_GLOBAL	fsEnumFiles(
		void (V_CALL *dir_callback)(char *full_unix_style_dir_name),
		void (V_CALL *file_callback)(char *full_unix_style_file_name),
		vboolean recursive);
	/* Splits full UNIX path */
	void		V_GLOBAL	fsSplitPath(char *full_path,
    	char *dir_ret,char *name_ret,char *ext_ret);
	void		V_GLOBAL	fsMakePath(char *path_ret,
    	char *dir,char *name, char *ext);
	/* Replaces extension in filename */
	void		V_GLOBAL	fsReplaceExt(char *dst,char *name,char *ext);
	/*	========== VFS service routines ================================ */
	/*	Mounts all recognized volumes in current directory and all 
	 *	subdirectories */
	void	V_GLOBAL	fsInit(void);
	/*	Unmounts all virtual filesystems */
	void	V_GLOBAL	fsShutdown();
	/*	========== file service routines ============================== */
	/*	All names in UNIX form. For MS OSes, see note #2 for
     *	'fsEnumFiles()'. These functions perform minimal validity checks
     *	and than call appropriate method from ioport_base_t object.
	 */
	u32_t	V_GLOBAL	fileRead(file_t handle,void *buf,u32_t len);
	u32_t	V_GLOBAL	fileWrite(file_t handle,void *buf,u32_t len);
	u32_t	V_GLOBAL	fileSeek(file_t handle,s32_t offset,int whence);
	u32_t	V_GLOBAL	fileTell(file_t handle);
	u32_t	V_GLOBAL	fileSize(file_t handle);
	vboolean	V_GLOBAL	fileControl(file_t handle,u32_t code,
    	void *parameters);
	vboolean	V_GLOBAL	fileClose(file_t handle);
    /* IO port factory functions */
	file_t		V_GLOBAL	fileOpenRead(char *name);
	file_t		V_GLOBAL	fileOpenWrite(char *name);
	file_t		V_GLOBAL	fileOpenAppend(char *name);
	/* IO port misc functions */
	vboolean	V_GLOBAL	fileEof(file_t file);
	char_t		V_GLOBAL	fileGetc(file_t file);
    /* NOTE: EOL *not* returned. */
	int			V_GLOBAL	fileGets(file_t file,char *buffer,int maxlen);
	/*	Reads little-endian word */
	u16_t		V_GLOBAL	fileGetLittleShort(file_t f);
	/*	Reads little-endian dword */
	u32_t		V_GLOBAL	fileGetLittleLong(file_t f);
	vboolean	V_GLOBAL	filePutc(file_t file,int c);
	/* NOTE: Writes system-dependent EOL after the string. */
	vboolean	V_GLOBAL	filePuts(file_t file,char *str);
	/* End-of-line sequence NOT APPENDED */
	vboolean	V_GLOBAL_VA	filePrintf(file_t file,const char *fmt,...);
	/*	Writes little-endian word */
	void		V_GLOBAL	filePutLittleShort(file_t f,u16_t w);
	/*	Writes little-endian dword */
	void		V_GLOBAL	filePutLittleLong(file_t f,u32_t dw);
#ifdef	__cplusplus
}

#endif	/* __cplusplus */

#endif	/* V_FS_H */
/*</pre></html>*/
/*EOF*/
