Microchip® Advanced Software Framework

reader_txt.c File Reference
#include "conf_explorer.h"
#include <string.h>
#include "file.h"
#include "navigation.h"
#include "reader_txt.h"
#include "unicode.h"

Functions

void reader_txt_beg (void)
 This function goes at the beginning of file and read the text header. More...
 
void reader_txt_close (void)
 Close text file. More...
 
uint16_t reader_txt_get_line (bool b_unicode, FS_STRING string, uint16_t u16_str_size)
 This function fills an ASCII buffer with the current text line of opened file. More...
 
bool reader_txt_jump_line (uint16_t nb_line)
 This function jumps text lines. More...
 
bool reader_txt_new (const FS_STRING sz_name, uint8_t u8_txt_format)
 Create a new text file. More...
 
bool reader_txt_open (bool b_readonly)
 Open a selected text file in the current navigator. More...
 
void reader_txt_select_format (uint8_t u8_txt_format)
 This function allow to select the text format to decode. More...
 

void reader_txt_beg ( void  )
void reader_txt_close ( void  )

Close text file.

References file_close().

uint16_t reader_txt_get_line ( bool  b_unicode,
FS_STRING  string,
uint16_t  u16_str_size 
)

This function fills an ASCII buffer with the current text line of opened file.

@param     b_unicode      true to return a unicode string (UTF16), ASCII otherwise over there
@param     string         string used to store text line
@param     u16_str_size   maximum size of string (unit character, 1B for ASCII, 2B for unicode)

@return    size of the line (may be < or > at u16_str_size)
@return    0, in case of error
//! This routine remove the character '\n' '\r'
//! 

References file_eof(), file_getc(), file_read_buf(), file_seek(), FS_EOF, FS_ERR_EOF, fs_g_nav_entry, fs_g_status, FS_SEEK_CUR_RE, LSB, MSB, nav_checkdisk_disable(), nav_checkdisk_enable(), Fs_management_entry::u8_txt_format, UNI_MAX_UTF8_SIZE, UNI_TYPE_UTF16BE, UNI_TYPE_UTF16LE, UNI_TYPE_UTF8, and utf8_to_unicode().

Referenced by pl_main_readline(), reader_id3_read_string(), and reader_txt_jump_line().

bool reader_txt_jump_line ( uint16_t  nb_line)

This function jumps text lines.

Parameters
nb_linenumber of lines to jump
Returns
false in case of error

References file_eof(), and reader_txt_get_line().

bool reader_txt_new ( const FS_STRING  sz_name,
uint8_t  u8_txt_format 
)

Create a new text file.

Parameters
sz_namecontains the file name (ASCII or UNICODE )
u8_txt_formattext format to use (UNI_TYPE_UTF8, UNI_TYPE_UTF16BE, UNI_TYPE_UTF16LE, UNI_TYPE_ASCII)
Returns
false in case of error, see global value "fs_g_status" for more detail
true otherwise

References file_write_buf(), fs_g_nav_entry, nav_file_create(), Fs_management_entry::u8_txt_format, UNI_MAX_HEADER_SIZE, and unicode_header_get().

bool reader_txt_open ( bool  b_readonly)

Open a selected text file in the current navigator.

Parameters
b_readonlytrue to open the text file in read only access
Returns
false in case of error, see global value "fs_g_status" for more detail
true otherwise

References file_open(), FOPEN_MODE_R, FOPEN_MODE_R_PLUS, and reader_txt_beg().

Referenced by pl_main_open().

void reader_txt_select_format ( uint8_t  u8_txt_format)

This function allow to select the text format to decode.

Parameters
u8_txt_formattext format selected (UNI_TYPE_UTF8, UNI_TYPE_UTF16BE, UNI_TYPE_UTF16LE, UNI_TYPE_ASCII)

References fs_g_nav_entry, and Fs_management_entry::u8_txt_format.

Referenced by reader_id3_read_string().