43 lines
1.3 KiB
TeX

\subsubsection*{Purpose}
Deletes a file.
\subsubsection*{Prototype}
\code{esint16 rmfile(FileSystem *fs,euint8* filename);}
\subsubsection*{Arguments}
Objects passed to \code{rmfile}:
\begin{itemize}
\item{\code{fs}: pointer to the FileSystem object}
\item{\code{filename}: pointer to the path + name of the file to be removed}
\end{itemize}
\subsubsection*{Return value}
Returns 0 if no errors are detected.\\
\newline
Returns non-zero if an error is detected, most likely that the file does not exist.
\subsubsection*{Note}
If you have opened a file with \code{fopen()}, and you wish to delete it, first
close all instances of that file. If you do not, you may corrupt the filesystem.
\subsubsection*{Example}
\lstset{numbers=left, stepnumber=1, numberstyle=\small, numbersep=5pt, tabsize=4}
\begin{lstlisting}
#include "efs.h"
void main(void)
{
EmbeddedFileSystem efsl;
/* Initialize efsl */
DBG((TXT("Will init efsl now.\n")));
if(efs_init(&efsl,"/dev/sda")!=0){
DBG((TXT("Could not initialize filesystem (err \%d).\n"),ret));
exit(-1);
}
DBG((TXT("Filesystem correctly initialized.\n")));
/* Delete some files */
rmfile(&efsl.myFs,"file0.txt");
rmfile(&efsl.myFs,"dir0/file0.txt");
/* Close filesystem */
fs_umount(&efsl.myFs);
}
\end{lstlisting}