Subversion Repositories shark

Rev

Rev 1676 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1676 tullio 1
%----------------------------------------------------------------------------
2
\chapter{The File Management}
3
%----------------------------------------------------------------------------
4
 
5
S.Ha.R.K. provides a built-in File System that currently supports Hard Disk
6
Drivers and FAT16 partitions.
7
 
8
If you are using the DOS eXtender X to run the application, you can use some
9
callback to the DOS 0x21 interrupt, to write/read some bytes from the
10
filesystem \footnote{These callbacks are useful when you don't have any
11
partition that can be read by the filesystem... for example when running
12
S.Ha.R.K. applications from a FAT32 filesystem!}. These functions directly
13
interact with the underlying DOS, and can not be used when the system is in
14
protected mode. In particular, you can only use these functions into the
15
\_\_kernel\_register\_levels\_\_() function and in the RUNLEVEL\_AFTER\_EXIT
16
exit functions.
17
 
18
In the case of errors, a \texttt{NULL} or zero value is returned;
19
\texttt{DOS\_ferror()} can be used to get the DOS error code; the header file
20
\texttt{<ll/i386/x-dos.h>} must be included to use these functions. A running
21
(we hope) well documented example can be foun in the \texttt{demos/dosfs}
22
directory.
23
 
24
\vspace{7mm}
25
 
26
\begin{intest}
27
DOS\_FOPEN\index{DOS\_fopen()}
28
\end{intest}
29
 
30
\begin{description}
31
\item [\textbf{DOS\_FILE {*}DOS\_fopen(char {*}name, char {*}mode);}]
32
\item [\textbf{Description:}] It opens a file and returns a pointer to a file structure.
33
The \texttt{name} parameter contains the name of the file to be opened. The
34
\texttt{mode} parameter contains a string whose value can be one of the
35
following constants: {}``r'' to read, {}``w'' to write, and {}``rw'' to read and
36
write. In the case of error, \texttt{NULL} is returned; otherwise the returned
37
value can be used as last parameter in the functions listed below.
38
\end{description}
39
 
40
\begin{intest}
41
DOS\_FCLOSE\index{DOS\_fclose()}
42
\end{intest}
43
 
44
\begin{description}
45
\item [\textbf{void DOS\_fclose(DOS\_FILE {*}f);}]
46
\item [\textbf{Description:}] It closes the specified file and releases all allocated DOS
47
resources.
48
\end{description}
49
 
50
\begin{intest}
51
DOS\_FREAD\index{DOS\_fread()}
52
\end{intest}
53
 
54
\begin{description}
55
\item [\textbf{DWORD DOS\_fread(void {*}buf, DWORD size, DWORD num, DOS\_FILE {*}f);}]
56
\item [\textbf{Description:}] It reads \texttt{num} objects of \texttt{size} bytes from
57
file \texttt{f} and place them in a buffer pointed by \texttt{buf}. This
58
function returns the actual number of bytes read from the file (it can be less
59
than $num*size$ bytes). Zero is returned if an error occurs or
60
\textit{end-of-file} is found.
61
\end{description}
62
 
63
\begin{intest}
64
DOS\_FWRITE\index{DOS\_fwrite()}
65
\end{intest}
66
 
67
\begin{description}
68
\item [\textbf{DWORD DOS\_fwrite(void {*}buf,DWORD size,DWORD num,DOS\_FILE {*}f);}]
69
\item [\textbf{Description:}] It writes \texttt{num} objects of \texttt{size} bytes into
70
file \texttt{f}. Data are picked from the buffer pointed by \texttt{buf}. This
71
function returns the actual number of bytes written (it can be less than
72
$num*size$ bytes). Zero is returned if an error occurs.
73
\end{description}
74
 
75
\begin{intest}
76
DOS\_ERROR\index{DOS\_error()}
77
\end{intest}
78
 
79
\begin{description}
80
\item [\textbf{unsigned DOS\_error(void);}]
81
\item [\textbf{Description:}] Returns the error code of the latest \texttt{DOS\_xxx}
82
function.
83
\end{description}
84