Subversion Repositories NaviCtrl

Rev

Rev 88 | Rev 90 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 88 Rev 89
Line 1343... Line 1343...
1343
/*      Description:    This function looks for the specified file in the rootdirectory of the drive. If the file is found the number of the    */
1343
/*      Description:    This function looks for the specified file in the rootdirectory of the drive. If the file is found the number of the    */
1344
/*                                      corrosponding filepointer is returned. Only modes 'r' (reading) and 'a' append are implemented yet.                                             */
1344
/*                                      corrosponding filepointer is returned. Only modes 'r' (reading) and 'a' append are implemented yet.                                             */
1345
/*                                                                                                                                                                                                                                                                                      */
1345
/*                                                                                                                                                                                                                                                                                      */
1346
/*      Returnvalue:    The filepointer to the file or 0 if faild.                                                                                                                                                              */
1346
/*      Returnvalue:    The filepointer to the file or 0 if faild.                                                                                                                                                              */
1347
/********************************************************************************************************************************************/
1347
/********************************************************************************************************************************************/
1348
File_t * fopen_(const s8 *filename, const s8 mode)
1348
File_t * fopen_(s8 * const filename, const s8 mode)
1349
{
1349
{
1350
        File_t *file    = 0;
1350
        File_t *file    = 0;
Line 1351... Line 1351...
1351
 
1351
 
Line 1725... Line 1725...
1725
/*                                                                                                                                                                                                                                                                              */
1725
/*                                                                                                                                                                                                                                                                              */
1726
/*      Description:    This function writes a string to the specified file.                                                                                                                            */
1726
/*      Description:    This function writes a string to the specified file.                                                                                                                            */
1727
/*                                                                                                                                                                                                                                                                              */
1727
/*                                                                                                                                                                                                                                                                              */
1728
/*      Returnvalue:    The function returns a no negative value or EOF on error.                                                                                                                       */
1728
/*      Returnvalue:    The function returns a no negative value or EOF on error.                                                                                                                       */
1729
/****************************************************************************************************************************************/
1729
/****************************************************************************************************************************************/
1730
s16 fputs_(const s8 *string, File_t *file)
1730
s16 fputs_(s8 * const string, File_t * const file)
1731
{
1731
{
1732
        u8 i=0;
1732
        u8 i=0;
1733
        s16 c = 0;
1733
        s16 c = 0;
Line 1734... Line 1734...
1734
 
1734
 
Line 1747... Line 1747...
1747
/*                                                                                                                                                                                                                                                                              */
1747
/*                                                                                                                                                                                                                                                                              */
1748
/*      Description:    This function reads a string from the file to the specifies string.                                                                                             */
1748
/*      Description:    This function reads a string from the file to the specifies string.                                                                                             */
1749
/*                                                                                                                                                                                                                                                                              */
1749
/*                                                                                                                                                                                                                                                                              */
1750
/*      Returnvalue:    A pointer to the string read from the file or 0 on error.                                                                                                                       */
1750
/*      Returnvalue:    A pointer to the string read from the file or 0 on error.                                                                                                                       */
1751
/****************************************************************************************************************************************/
1751
/****************************************************************************************************************************************/
1752
u8 * fgets_(s8 *string, s16 length, File_t *file)
1752
s8 * fgets_(s8 * const string, s16 const length, File_t * const file)
1753
{
1753
{
1754
        u8 *pbuff;
1754
        s8 *pbuff;
1755
        s16 c = 0;
1755
        s16 c = 0, bytecount;
Line 1756... Line 1756...
1756
 
1756
 
1757
        if((!Partition.IsValid) || (file == NULL) || (string == NULL) || (length = 0)) return (0);
1757
        if((!Partition.IsValid) || (file == NULL) || (string == NULL) || (length < 1)) return (0);
-
 
1758
        bytecount = length;
1758
        pbuff = string;
1759
        pbuff = string;                                                         // set write pointer to start of string
1759
        while(length > 1)                                                       // read the length-1 characters from the file to the string.
1760
        while(bytecount > 1)                                            // read the length-1 characters from the file to the string.
1760
        {
1761
        {
1761
                c = fgetc_(file);                                               // read a character from the opened file.
1762
                c = fgetc_(file);                                               // read a character from the opened file.
1762
                switch(c)
1763
                switch(c)
1763
                {
1764
                {
1764
                        case 0x0A:
1765
                        case 0x0A:                                                      // new line
1765
                                c = 0;                                                  // set string terminator
1766
                                *pbuff = 0;                                             // set string terminator
1766
                                length = 1;                                             // stop loop
-
 
Line 1767... Line 1767...
1767
                                break;
1767
                                return(string);                                 // return normal
1768
 
1768
 
-
 
1769
                        case EOF:
-
 
1770
                                *pbuff = 0;                                             // set string terminator
-
 
1771
                                return(0);
1769
                        case EOF:
1772
 
-
 
1773
                        default:
1770
                                c = 0;                                                  // set string terminator
1774
                                *pbuff++ = (s8)c;                               // copy byte to string
1771
                                length = 1;                                             // stop loop
1775
                                bytecount--;
1772
                                break;
-
 
1773
                }
-
 
1774
                *pbuff = (s8)c;                                                 // copy byte to string
-
 
1775
                length--;
1776
                                break;
-
 
1777
                }
1776
                pbuff++;
1778
        }
1777
        }
1779
        *pbuff = 0;     // set string terminator
Line 1778... Line 1780...
1778
        return(string);
1780
        return(string);
1779
}
1781
}
1780
 
1782
 
1781
/****************************************************************************************************************************************/
1783
/****************************************************************************************************************************************/
1782
/*      Function:               fexist_(const u8*);                                                                                                                                                                                                     */
1784
/*      Function:               fexist_(const u8*);                                                                                                                                                                                                     */
1783
/*                                                                                                                                                                                                                                                                              */
1785
/*                                                                                                                                                                                                                                                                              */
1784
/*      Description:    This function checks if a file already exist.                                                                                                                                           */
1786
/*      Description:    This function checks if a file already exist.                                                                                                                                           */
1785
/*                                                                                                                                                                                                                                                                              */
1787
/*                                                                                                                                                                                                                                                                              */
1786
/*      Returnvalue:    1 if the file exist else 0.                                                                                                                                                                                     */
1788
/*      Returnvalue:    1 if the file exist else 0.                                                                                                                                                                                     */
1787
/****************************************************************************************************************************************/
1789
/****************************************************************************************************************************************/
1788
u8 fexist_(const s8* filename)
1790
u8 fexist_(s8 * const filename)
1789
{
1791
{
1790
        u8 exist = 0;
1792
        u8 exist = 0;