FILE
****
This module offers you basic operating system's filesystem routines.

When using files, you work with file handles. In some implementations these
handles can be ones returned by OS, but you should use them only with FASMLIB.

For every opened file you also have position (offset) at which you are in file.
After opening/creating file this is always 0, "file.read" and "file.write"
shift this position behind data you read/write. You can change position with
"file.seek"



proc file.open name, mode
=========================
desc:	opens file to allow you access it's contents
args:	name	- string pointer or handle containing file name
	mode	- access mode: 0=read, 1=write, 2=read/write
ret:	CF on error, otherwise
	EAX = handle to file
note:	Don't forget to close file handle with file.close


proc file.create name, mode
===========================
desc:	creates new file
args:	name	- string pointer or handle containing file name
	mode	bit0: 1 to overwrite when file exists
		bit1: 1 if you want read access too
ret:	CF on error, otherwise
	EAX = handle to file
note:	Don't forget to close file handle with file.close

proc file.seek handle, dist, method
===================================
desc:	move to specific position in file
args:	handle	- file handle (returned by file.open)
	dist	- distance to move (signed)
	method	- from where to move
		0: from beginning
		1: relative to current position
		2: from end
ret:	CF set on error, otherwise
	EAX = new file position (from beginning of file)
note:	- you can use this to get current position
		libcall	file.seek, <handle>, 0, 1
	- you can use this to get size of opened file:
		libcall	file.seek, <handle>, 0, 2
	  but note that this also changes position in file to end
	- you can safely use this call only on files smaller than 2GB
	- TODO: what does it do when out-of-file

proc file.read handle, buffer, size
===================================
desc:	read data from current position in file
args:	handle - file handle, must be opened for reading
	buffer - pointer to buffer where to store data
	count - number of bytes to read
ret:	CF set on error, otherwise
	ZF set if read behind end of file occured
	EAX = number of bytes readen


proc file.write handle, buffer, size
====================================
desc:	write data to current position in file
args:	handle - file handle, must be opened for writing
	buffer - pointer to buffer which contains data to be written
	count - number of bytes to write
ret:	CF set on error

proc file.close handle
======================
desc:	closes file handle
args:	handle	- file handle
ret:	CF set on error
note:	when "file.close" fails consider handle closed and don't use it anymore
