#ifndef		V_FS_H
#define		V_FS_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 */
	/*	========== 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.
	 */
	vsize_t	V_GLOBAL	fileRead(file_t handle,void *buf,vsize_t len);
	vsize_t	V_GLOBAL	fileWrite(file_t handle,void *buf,vsize_t len);
	vsize_t	V_GLOBAL	fileSeek(file_t handle,vssize_t offset,int whence);
	vsize_t	V_GLOBAL	fileTell(file_t handle);
	vsize_t	V_GLOBAL	fileSize(file_t handle);
	vboolean	V_GLOBAL	fileControl(file_t handle,unsigned 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);
	/*
	 * Keeps data in memory; at fileClose() creates temp file,
	 * saves the data, and renames the file (implemented in safeover.c).
	 */
	file_t		V_GLOBAL	fileOpenSafeOverwrite(char *name);
	/* IO port misc functions */
	vboolean	V_GLOBAL	fileEof(file_t file);
	char_t		V_GLOBAL	fileGetc(file_t file);
	/*	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	BUILD_DLL
	/*
	 * Quite usefull for Delphi apps
	 */
	void V_GLOBAL libvDosPathToUnixPath(char *unix_path_ret,char *dos_path);
	void V_GLOBAL libvUnixPathToDosPath(char *dos_path_ret,char *unix_path);
#endif	/* BUILD_DLL */

#ifdef	__cplusplus
}

#endif	/* __cplusplus */

#endif	/* V_FS_H */
