Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Homepage FreeRTOS+ Products FreeRTOS Labs Integration Services Contact / Enquiries

f_truncate()

[FreeRTOS Embedded File System API]

header_file.h
F_FILE * f_truncate( const char * pcFileName, long lTruncateSize );
		

Opens a file for writing, then sets the length of the file to a specified value. If the specified length is longer than the current file length then the file is extended (rather than truncated) and the new space is padded with zeros. If the specified length is shorter than the current file length then the file is truncated and all data after the truncation point is lost.

Parameters:

pcFileHandle   The name of the file being opened and truncated. The name is specified as a standard null terminated C string.

lTruncateSize   The length to which the opened file will be truncated/extended.

Returns:
Null   The file could not be opened.

Any other value   The returned value is the handle to the opened file.

See also

f_open.shtml, f_seteof().

Example usage:


void vSampleFunction( char *pcFileName, unsigned long ulLength )
{
F_FILE *pxFile;

    /* Open and truncate the file specified by the pcFileName parameter. */
    pxFile = f_truncate( pcFileName, ulLength );

    if( pxFile == NULL )
    {
        /* The file could not be opened. */
    }
    else
    {
        /* The file was opened and the file length was set. */

        /*
         * The file can be accessed here.
         */

        /* Close the file when it is no longer required. */
        f_close( pxFile );
    }
}
						
Example use of the f_truncate() API function


[ Back to the top ]    [ About FreeRTOS ]    [ FreeRTOS+ Sitemap ]    [ Main FreeRTOS Sitemap ]    [ ]


Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.