This library contains functions for file system operations and formatting input and output data. The file system has been adapted from TINI's Java Runtime Environment to be able to be called from a C program.
The file system must reside in contiguous memory. The maximum size of the file system is likely to be far beyond the needs of most/any applications. Following is a more rigorous definition of the maximum file system size for those interested:
Pages in the file system are 256-byte blocks (on 256-byte boundaries). The file system's memory manager has several overhead blocks to maintain some information on block allocation. The number of overhead blocks cannot exceed 255 blocks (65280 bytes). 11 pages of overhead are consumed by file system specific overhead. The remaining possible overhead blocks are consumed by:
For detailed information on the DS80C400 please see the High-Speed Microcontroller User's Guide: DS80C400 Supplement.
#include <stddef.h>
Go to the source code of this file.
Data Structures | |
| struct | file_structure |
Defines | |
| #define | FS_VERSION 8 |
| #define | NULL ((void *) 0) |
| #define | FILE_FLAGS_EOF 1 |
| #define | FILE_FLAGS_TEMP 2 |
| #define | FILE_TYPE_TINIFS 1 |
| #define | FILENAME_MAX 255 |
| #define | FOPEN_MAX 8 |
| #define | L_tmpnam 20 |
| #define | SEEK_CUR 0x5555 |
| #define | SEEK_END 0x5556 |
| #define | SEEK_SET 0x5557 |
| #define | TMP_MAX 10 |
| #define | EOF -1 |
| #define | P_tmpdir "temp" |
Typedefs | |
| typedef unsigned int | size_t |
| typedef unsigned int | off_t |
| typedef long | fpos_t |
| typedef file_structure | FILE |
Functions | |
| void | clearerr (FILE *f_handle) |
| Clear the error indicators for a file stream. | |
| int | fclose (FILE *f_handle) |
| Closes the file stream. | |
| int | feof (FILE *f_handle) |
| Checks to see if this stream has reached the end of the file. | |
| int | ferror (FILE *f_handle) |
| Gets the error indicator for the file stream. | |
| int | fgetc (FILE *f_handle) |
| Gets the next unsigned character from the file stream. | |
| int | fgetpos (FILE *f_handle, fpos_t *position) |
| Gets the current value of the file position indicator. | |
| char * | fgets (char *string, int num, FILE *f_handle) |
| Reads a string from the file stream. | |
| FILE * | fopen (const char *filename, const char *mode) |
| Opens the specified file. | |
| int | fputc (int ch, FILE *f_handle) |
| Writes a character to a file stream. | |
| int | fputs (const char *str, FILE *f_handle) |
| Writes a string to a file stream. | |
| size_t | fread (void *ptr, size_t size, size_t num, FILE *f_handle) |
| Read a number of bytes from a file stream. | |
| FILE * | freopen (const char *newfilename, const char *mode, FILE *old_handle) |
| Associates an open stream with a different file. | |
| int | fseek (FILE *f_handle, long int offset, int tag) |
| Sets the file position indicator. | |
| int | fseeko (FILE *f_handle, off_t offset, int tag) |
| Sets the file position indicator. | |
| int | fsetpos (FILE *f_handle, const fpos_t *position) |
| Sets the file position indicator. | |
| long | ftell (FILE *f_handle) |
| Gets the file position indicator. | |
| off_t | ftello (FILE *f_handle) |
| Gets the file position indicator. | |
| void | flockfile (FILE *f_handle) |
| Gets exclusive access to a file. | |
| int | ftrylockfile (FILE *f_handle) |
| Tries to get exclusive accress to a file. | |
| void | funlockfile (FILE *f_handle) |
| Release exclusive access on a file. | |
| size_t | fwrite (const void *ptr, size_t size, size_t num, FILE *f_handle) |
| Write a number of bytes to a file stream. | |
| int | getc (FILE *f_handle) |
| Gets the next unsigned character from the file stream. | |
| int | putc (int value, FILE *f_handle) |
| Writes a character to a file stream. | |
| int | remove (const char *filename) |
| Removes a file from the file system. | |
| int | rename (const char *oldname, const char *newname) |
| Renames a file. | |
| void | rewind (FILE *f_handle) |
| Resets the file position indicator for a stream. | |
| char * | tempnam (const char *dirname, const char *pfx) |
| Generates a path/filename that can be used for a temporary file. | |
| FILE * | tmpfile (void) |
| Generates a stream to a temporary file. | |
| char * | tmpnam (char *nametarget) |
| Generates a uniqe temporary filename. | |
| int | fflush (FILE *f_handle) |
| Flushes the buffers for a file stream. | |
| int | fcleaninit (char numfd, int numblocks, void *start_address) |
| Initializes the file system to a blank state. | |
| int | finit (char numfd, int numblocks, void *start_address) |
| Initializes the file system. | |
| int | fexists (char *filename) |
| Tests for the existence of a file. | |
| void * | fopen_fd (const char *filename, const char *mode) |
| Helper function that opens a file descriptor. | |
| unsigned int | freadbytes (void *buffer, int length, FILE *stream) |
| Reads bytes into a buffer from a file stream. | |
| unsigned int | fwritebytes (void *buffer, int length, FILE *stream) |
| Writes bytes to a file stream. | |
| unsigned long | getfreefsram () |
| Gets the amount of free space in the file system. | |
| int | mkdir (char *dirname) |
| Creates a directory. | |
| char | _getkey (void) |
| Keil-provided function. | |
| char | getchar (void) |
| Keil-provided function. | |
| char | ungetchar (char) |
| Keil-provided function. | |
| char | putchar (char) |
| Keil-provided function. | |
| int | printf (const char *,...) |
| Keil-provided function. | |
| int | sprintf (char *, const char *,...) |
| Keil-provided function. | |
| int | vprintf (const char *, char *) |
| Keil-provided function. | |
| int | vsprintf (char *, const char *, char *) |
| Keil-provided function. | |
| char * | gets (char *, int n) |
| Keil-provided function. | |
| int | scanf (const char *,...) |
| Keil-provided function. | |
| int | sscanf (char *, const char *,...) |
| Keil-provided function. | |
| int | puts (const char *) |
| Keil-provided function. | |
| unsigned int | filesystem_version (void) |
| Returns the version number of this file system library. | |
|
|
Define for end-of-file. |
|
|
Definition for file flag. Denotes that the end of the file has been reached for this file.
|
|
|
Definition for file flag. Denotes that this is a temporary file.
|
|
|
Type for the file. Currently, this file system only supports the TINI File System type.
|
|
|
Maximum size in bytes of the longest filename string that the implementation guarantees can be opened.
|
|
|
Number of streams which the implementation guarantees can be open simultaneously.
|
|
|
Version number associated with this header file. Should be the same as the version number returned by the filesystem_version function.
|
|
|
Maximum size of character array to hold tmpnam output.
|
|
|
Definition for a null pointer. |
|
|
Default directory that temporary file names will be built into.
|
|
|
Seek offset is from the current location in the file.
|
|
|
Seek offset is from the end of the file.
|
|
|
Seek offset is from the beginning of the file. |
|
|
Maximum number of guaranteed unique file names that can be created by the tmpnam function.
|
|
|
Type definition for a C file object. |
|
|
Type definition for the position in a file. |
|
|
Type definition for the offset in a file. |
|
|
Type definition for the amount of data to be written or read. |
|
|
Keil-provided function. This is a Keil-provided function. Please see Keil's documentation for information on this function. It is exported by this header file so that we can override stdio.h. |
|
|
Clear the error indicators for a file stream. Clears the error and end-of-file indicators for a file stream. This function is safe to be called from multiple processes at the same time.
|
|
||||||||||||||||
|
Initializes the file system to a blank state. Initializes the file system. This method (or finit) must be called every time the DS80C400 boots up and wants to use the file system. Starts with a blank file system automatically. Note that the init_rom function must be called before the file system is initialized. This function is safe to be called from multiple processes at the same time.
|
|
|
Closes the file stream. Closes the stream associated with f_handle. In the TINI File System, there are no buffers, so this function has nothing to flush before closing. This function is safe to be called from multiple processes at the same time.
|
|
|
Checks to see if this stream has reached the end of the file. Tests the end-of-stream indicator for this file stream. This function is safe to be called from multiple processes at the same time.
|
|
|
Gets the error indicator for the file stream. Gets the current error indicator for the file stream. This function is safe to be called from multiple processes at the same time.
|
|
|
Tests for the existence of a file. Checks to see if the file filename exists in this file system. This function is safe to be called from multiple processes at the same time.
|
|
|
Flushes the buffers for a file stream. The TINI File System has no buffers (data is read and written directly on the file system, since it resides in XDATA). Therefore, this function only clears the error flag. This function is safe to be called from multiple processes at the same time.
|
|
|
Gets the next unsigned character from the file stream. Returns the next unsigned character (if available) from the file stream (converted to an int), advancing the file position pointer. This function is safe to be called from multiple processes at the same time.
|
|
||||||||||||
|
Gets the current value of the file position indicator. Puts the current value of the file position indicator into the location position. The value in position after the function call is to be used for resetting the stream to this position using a later call to fsetpos.
|
|
||||||||||||||||
|
Reads a string from the file stream. Reads at most num-1 characters from the file stream. Will not return any data read after a newline character (which is included) or the end of the file. A null character is appended to the data read. Note that the implementation of this method is not efficient. For more efficient reading of data, use the fread function. This function is safe to be called from multiple processes at the same time.
|
|
|
Returns the version number of this file system library.
|
|
||||||||||||||||
|
Initializes the file system. Initializes the file system. This method (or fcleaninit) must be called every time the DS80C400 boots up and wants to use the file system. If the file system does not exist or is corrupted, it will erase and start with a blank file system. Also, if any of the parameters given to finit do not match how the file system was previously initialized, the file system will erase and start blank. Note that the init_rom function must be called before the file system is initialized. This function is safe to be called from multiple processes at the same time.
|
|
|
Gets exclusive access to a file. Sleeps until exclusive access to a file is available. Note that locks cannot be nested. A nested lock will be released on the very first call to funlockfile, and not the matching call. This function is safe to be called from multiple processes at the same time.
|
|
||||||||||||
|
Opens the specified file. Opens the file specified and associates a stream with it. Files can be opened in read, write, or append mode.
|
|
||||||||||||
|
Helper function that opens a file descriptor. Helper function that opens a file descriptor. File descriptors are not immediately useful to any C library function. Applications should use the fopen function to open a file.
|
|
||||||||||||
|
Writes a character to a file stream. Writes the specified character (converted from an int) to a file stream, advancing the file position indicator. This function is safe to be called from multiple processes at the same time.
|
|
||||||||||||
|
Writes a string to a file stream. Writes a null-terminated string to a file stream. The terminating character is not written.
|
|
||||||||||||||||||||
|
Read a number of bytes from a file stream.
Reads a block of data from a file stream. This function allows you to read num elements of size size. However, note that this function always behaves as if it had been called by: This function is safe to be called from multiple processes at the same time.
|
|
||||||||||||||||
|
Reads bytes into a buffer from a file stream. Reads a specified number of bytes into a buffer from a file stream. This function is used by fread as a helper function. It may safely be used from user applications, although it is not a standard file reading function (is not part of an ANSI-C standard library).
|
|
||||||||||||||||
|
Associates an open stream with a different file. Closes the file associated with old_handle and opens a stream to the file newfilename. This function is safe to be called from multiple processes at the same time.
|
|
||||||||||||||||
|
Sets the file position indicator. Sets the file position indicator for a file stream. Note that the only currently supported value for tag is SEEK_SET, meaning that the value offset wil always be interpreted as the offset from the beginning of the file. After a call to fseek, the end-of-file indicator for the file stream is reset. This function behaves the same as fseeko. The only difference is that fseeko accepts an offset parameter of type off_t.
|
|
||||||||||||||||
|
Sets the file position indicator. Sets the file position indicator for a file stream. Note that the only currently supported value for tag is SEEK_SET, meaning that the value offset wil always be interpreted as the offset from the beginning of the file. After a call to fseeko, the end-of-file indicator for the file stream is reset. This function behaves the same as fseek. The only difference is that fseek accepts an offset parameter of type long int. This function is safe to be called from multiple processes at the same time.
|
|
||||||||||||
|
Sets the file position indicator. Sets a stream's file position indicator from the position information pointed to by position. The value in position should have been obtained by a call to fgetpos. If successful, this function will also clear the end-of-file indicator for the stream.
|
|
|
Gets the file position indicator. Gets the file position indicator for the specified file. This is the number of characters from the beginning of the file. This function behaves the same as ftello. The only difference is that ftello returns a value of type off_t. This function is safe to be called from multiple processes at the same time.
|
|
|
Gets the file position indicator. Gets the file position indicator for the specified file. This is the number of characters from the beginning of the file. This function behaves the same as ftell. The only difference is that ftell returns a value of type long. This function is safe to be called from multiple processes at the same time.
|
|
|
Tries to get exclusive accress to a file. Obtains exclusive access to a file if it is available. Otherwise, returns without waiting for exclusive access. Note that locks cannot be nested. A nested lock will be released on the very first call to funlockfile, and not the matching call. This function is safe to be called from multiple processes at the same time.
|
|
|
Release exclusive access on a file. Releases exclusive access that was earlier acquired on this file using flockfile or ftrylockfile. Note that locks cannot be nested. This function will release all locks that the current thread/process have on the file. This function is safe to be called from multiple processes at the same time.
|
|
||||||||||||||||||||
|
Write a number of bytes to a file stream.
Writes a block of data to a file stream. This function allows you to write num elements of size size. However, note that this function always behaves as if it had been called by: This function is safe to be called from multiple processes at the same time.
|
|
||||||||||||||||
|
Writes bytes to a file stream. Writes the specified number of bytes to a file stream. This function is used by fwrite as a helper function. It may safely be used from user applications, although it is not a standard file writing function (is not part of an ANSI-C standard library).
|
|
|
Gets the next unsigned character from the file stream. Returns the next unsigned character (if available) from the file stream (converted to an int), advancing the file position pointer. Note: This function is equivalent to fgetc. This function is safe to be called from multiple processes at the same time.
|
|
|
Keil-provided function. This is a Keil-provided function. Please see Keil's documentation for information on this function. It is exported by this header file so that we can override stdio.h. |
|
|
Gets the amount of free space in the file system. Returns the number of bytes available to the file system. Note that this number is completely independent of the amount of free RAM available from the ROM's memory manager. The TINI File System uses its own independent memory manager. This function is safe to be called from multiple processes at the same time.
|
|
||||||||||||
|
Keil-provided function. This is a Keil-provided function. Please see Keil's documentation for information on this function. It is exported by this header file so that we can override stdio.h. |
|
|
Creates a directory. Creates a directory with the specified directory name. This function is safe to be called from multiple processes at the same time.
|
|
||||||||||||
|
Keil-provided function. This is a Keil-provided function. Please see Keil's documentation for information on this function. It is exported by this header file so that we can override stdio.h. |
|
||||||||||||
|
Writes a character to a file stream. Writes the specified character (converted from an int) to a file stream, advancing the file position indicator. Note: This function is equivalent to fputc. This function is safe to be called from multiple processes at the same time.
|
|
|
Keil-provided function. This is a Keil-provided function. Please see Keil's documentation for information on this function. It is exported by this header file so that we can override stdio.h. |
|
|
Keil-provided function. This is a Keil-provided function. Please see Keil's documentation for information on this function. It is exported by this header file so that we can override stdio.h. |
|
|
Removes a file from the file system. Deletes the file specified by filename. This function is safe to be called from multiple processes at the same time.
|
|
||||||||||||
|
Renames a file. Renames the file identified by oldname to now be identified by newname.
|
|
|
Resets the file position indicator for a stream.
Sets the file position indicator for the stream to the beginning of the file. It also resets the end of file condition. This is functionally equivalent to: This function is safe to be called from multiple processes at the same time.
|
|
||||||||||||
|
Keil-provided function. This is a Keil-provided function. Please see Keil's documentation for information on this function. It is exported by this header file so that we can override stdio.h. |
|
||||||||||||||||
|
Keil-provided function. This is a Keil-provided function. Please see Keil's documentation for information on this function. It is exported by this header file so that we can override stdio.h. |
|
||||||||||||||||
|
Keil-provided function. This is a Keil-provided function. Please see Keil's documentation for information on this function. It is exported by this header file so that we can override stdio.h. |
|
||||||||||||
|
Generates a path/filename that can be used for a temporary file. Generates a path/filename that can be used to create a temporary file with. The pointer that is returned is suitable to be freed using mem_free. Make sure to use the Dallas Semiconductor memory management library (rom400_mem.h) rather than the Keil memory manager to free the memory. This function is safe to be called from multiple processes at the same time.
|
|
|
Generates a stream to a temporary file. Generates a stream to a temporary file, opened for writing/update. This function is safe to be called from multiple processes at the same time.
|
|
|
Generates a uniqe temporary filename. Capable of generating TMP_MAX unique temporary filenames. This filename is suitable for using in a call to fopen. If the name is written to a static location, then this call destroys the previous filename stored in that location. This function is safe to be called from multiple processes at the same time.
|
|
|
Keil-provided function. This is a Keil-provided function. Please see Keil's documentation for information on this function. It is exported by this header file so that we can override stdio.h. |
|
||||||||||||
|
Keil-provided function. This is a Keil-provided function. Please see Keil's documentation for information on this function. It is exported by this header file so that we can override stdio.h. |
|
||||||||||||||||
|
Keil-provided function. This is a Keil-provided function. Please see Keil's documentation for information on this function. It is exported by this header file so that we can override stdio.h. |
| Copyright 2004 Dallas Semiconductor, Inc.. | Documentation generated by Doxygen. |