Subversion Repositories NaviCtrl

Rev

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

Rev 349 Rev 353
Line 60... Line 60...
60
#include "timer1.h"
60
#include "timer1.h"
61
#include "fat16.h"
61
#include "fat16.h"
62
#include "sdc.h"
62
#include "sdc.h"
63
#include "uart1.h"
63
#include "uart1.h"
Line 64... Line -...
64
 
-
 
65
void Test(void);
64
 
66
//________________________________________________________________________________________________________________________________________
65
//________________________________________________________________________________________________________________________________________
67
// Module name:                 fat16.c
66
// Module name:                 fat16.c
68
// Compiler used:               avr-gcc 3.4.5
67
// Compiler used:               avr-gcc 3.4.5
69
// Last Modifikation:   20.03.2010
68
// Last Modifikation:   20.03.2010
Line 321... Line 320...
321
Partition_t     Partition;              // Structure holds partition information
320
Partition_t     Partition;              // Structure holds partition information
Line 322... Line 321...
322
 
321
 
Line -... Line 322...
-
 
322
File_t FilePointer[FILE_MAX_OPEN];      // Allocate Memmoryspace for each filepointer used.
-
 
323
 
323
File_t FilePointer[FILE_MAX_OPEN];      // Allocate Memmoryspace for each filepointer used.
324
 
324
 
325
 
325
 
326
 
326
/****************************************************************************************************************************************/
327
/****************************************************************************************************************************************/
327
/*      Function:               FileDate(DateTime_t *);                                                                                                                                                                                         */
328
/*      Function:               FileDate(DateTime_t *);                                                                                                                                                                                         */
Line 448... Line 449...
448
        }
449
        }
Line 449... Line 450...
449
 
450
 
450
        // clear dirname with spaces
451
        // clear dirname with spaces
451
        dirname[11] = 0; // terminate dirname
452
        dirname[11] = 0; // terminate dirname
-
 
453
        for(writepointer = 0; writepointer < 11; writepointer++) dirname[writepointer] = ' ';
-
 
454
 
-
 
455
        // handle the special dirnames "." and ".." seperately
-
 
456
        readpointer = 0;
-
 
457
        if(filepath[0] == '/') readpointer++;
-
 
458
        // if we are trying to enter directories "." or ".." 
-
 
459
        if(filepath[readpointer] == '.')
-
 
460
        {
-
 
461
                // directory '.'
-
 
462
                if(filepath[readpointer+1] == 0)
-
 
463
                {
-
 
464
                        dirname[0] = '.';
-
 
465
                        return((s8*)&filepath[readpointer]);
-
 
466
                }
-
 
467
                // directory '..'               
-
 
468
                if((filepath[readpointer+1] == '.') &&  (filepath[readpointer+2] == 0))
-
 
469
                {
-
 
470
                        dirname[0] = '.';
-
 
471
                        dirname[1] = '.';
-
 
472
                        return((s8*)&filepath[readpointer]);
-
 
473
                }
-
 
474
        }
452
        for(writepointer = 0; writepointer < 11; writepointer++) dirname[writepointer] = ' ';
475
 
453
        writepointer = 0;
476
        writepointer = 0;
454
        // start seperating the dirname from the filepath.
477
        // start seperating the dirname from the filepath.
455
        readpointer = 0;
478
        readpointer = 0;
456
        if(filepath[0] == '/') readpointer = 1; // ignore first '/'
479
        if(filepath[0] == '/') readpointer = 1; // ignore first '/'
Line 660... Line 683...
660
        }
683
        }
661
        Partition.IsValid = 1; // mark data in partition structure as valid
684
        Partition.IsValid = 1; // mark data in partition structure as valid
662
        Partition.CurrentWorkingDirectory = Partition.FirstRootDirSector;
685
        Partition.CurrentWorkingDirectory = Partition.FirstRootDirSector;
663
        strcpy(Partition.PathToCwd,"/");
686
        strcpy(Partition.PathToCwd,"/");
664
        result = 0;
687
        result = 0;
665
 
-
 
666
//      Test();
-
 
667
        end:
688
        end:
668
        if(result != 0) Fat16_Deinit();
689
        if(result != 0) Fat16_Deinit();
669
        else UART1_PutString("ok");
690
        else UART1_PutString("ok");
670
        return(result);
691
        return(result);
671
}
692
}
Line 754... Line 775...
754
        }
775
        }
755
        return(cluster);
776
        return(cluster);
756
}
777
}
Line -... Line 778...
-
 
778
 
757
 
779
 
758
 
780
 
759
/****************************************************************************************************************************************/
781
/****************************************************************************************************************************************/
760
/* Function:    FindNextFreeCluster(File_t *);                                                                                                                                                                          */
782
/* Function:    FindNextFreeCluster(File_t *);                                                                                                                                                                          */
761
/*                                                                                                                                                                                                                                                                              */
783
/*                                                                                                                                                                                                                                                                              */
Line 2079... Line 2101...
2079
/*      Returnvalue:    TRUE if an matching element was found                                                                                                                                                                           */
2101
/*      Returnvalue:    TRUE if an matching element was found                                                                                                                                                                           */
2080
/********************************************************************************************************************************************/
2102
/********************************************************************************************************************************************/
Line 2081... Line 2103...
2081
 
2103
 
2082
u8 FindItem(Find_t *findelement)
2104
u8 FindItem(Find_t *findelement)
2083
{
2105
{
-
 
2106
        u16             index = 0;
2084
        u16     index = 0;
2107
        u16             max_dir_sector = 0;
2085
        u16   end_of_directory_not_reached = 1;                                                                         // the directory has been read completely without a result.
2108
        u16     end_of_directory_not_reached = 1;                                                                               // the directory has been read completely without a result.
2086
        u8      i = 0;
2109
        u8              i = 0;
2087
        u8              readpointer = 0;
2110
        u8              readpointer = 0;
2088
        u8              writepointer = 0;
2111
        u8              writepointer = 0;
2089
        u8              retvalue = 0;
2112
        u8              retvalue = 0;
2090
        DirEntry_t      *DirectoryEntry;
2113
        DirEntry_t      *DirectoryEntry;
Line 2091... Line 2114...
2091
        File_t  file;
2114
        File_t  file;
2092
 
2115
 
2093
        file.FirstSectorOfCurrCluster   = findelement->fp.FirstSectorOfCurrCluster;
2116
        file.FirstSectorOfCurrCluster   = findelement->fp.FirstSectorOfCurrCluster;
Line -... Line 2117...
-
 
2117
        file.SectorOfCurrCluster        = findelement->fp.SectorOfCurrCluster;
-
 
2118
        index                                                   = findelement->fp.DirectoryIndex;
-
 
2119
 
-
 
2120
        // within the root directory area we can read sectors sequentially until the end of this area
-
 
2121
        if((Partition.FirstRootDirSector <= file.FirstSectorOfCurrCluster) && (file.FirstSectorOfCurrCluster < Partition.FirstDataSector))
-
 
2122
        {
-
 
2123
                max_dir_sector = (Partition.MaxRootEntries * DIRENTRY_SIZE)/BYTES_PER_SECTOR;
-
 
2124
        }
-
 
2125
        // within the data clusters we can read sectors sequentially only within the cluster
-
 
2126
        else if((Partition.FirstDataSector <= file.FirstSectorOfCurrCluster) && (file.FirstSectorOfCurrCluster <= Partition.LastDataSector))
Line 2094... Line 2127...
2094
        file.SectorOfCurrCluster        = findelement->fp.SectorOfCurrCluster;
2127
        {
2095
        index                                                   = findelement->fp.DirectoryIndex;
2128
                max_dir_sector = Partition.SectorsPerCluster;                           // limit max secters before next cluster
2096
 
2129
        }
2097
 
2130
 
Line 2119... Line 2152...
2119
                                                findelement->name[writepointer] = DirectoryEntry[index].Name[readpointer];      // copy the name of the item found to the find_structure.
2152
                                                findelement->name[writepointer] = DirectoryEntry[index].Name[readpointer];      // copy the name of the item found to the find_structure.
2120
                                                writepointer++;
2153
                                                writepointer++;
2121
                                        }
2154
                                        }
2122
                                        else  
2155
                                        else  
2123
                                        {
2156
                                        {
2124
                                                if(DirectoryEntry[index].Attribute == ATTR_ARCHIVE)
2157
                                                if(DirectoryEntry[index].Attribute == ATTR_ARCHIVE)                                            
2125
                                                {
2158
                                                {
2126
                                        if(readpointer < 8) readpointer=8;
2159
                                        if(readpointer < 8) readpointer=8;
2127
                                        if(DirectoryEntry[index].Name[readpointer] != ' ')
2160
                                        if(DirectoryEntry[index].Name[readpointer] != ' ')
2128
                                        {
2161
                                        {
2129
                                        findelement->name[writepointer] = '.';                                                  // then seperate the name and the extension by a '.' at index 8.                                                
2162
                                        findelement->name[writepointer] = '.';                                                  // then seperate the name and the extension by a '.' at index 8.                                                
Line 2145... Line 2178...
2145
                                findelement->fp.SectorOfCurrCluster      = file.SectorOfCurrCluster;
2178
                                findelement->fp.SectorOfCurrCluster      = file.SectorOfCurrCluster;
2146
                findelement->fp.Size            = DirectoryEntry[index].Size;
2179
                findelement->fp.Size            = DirectoryEntry[index].Size;
2147
                                findelement->fp.Attribute               = DirectoryEntry[index].Attribute;
2180
                                findelement->fp.Attribute               = DirectoryEntry[index].Attribute;
2148
                retvalue = 1;
2181
                retvalue = 1;
2149
                        }                      
2182
                        }                      
-
 
2183
                        /* search the next sector */
2150
                        index++;
2184
                        index++;
2151
                }
2185
                }
-
 
2186
                /* this sector has been searched but we havn't found what we are looking for. Therefore we have to find the next sector */
2152
                if(!retvalue)                                                                                                                           // file not found in this sector so take next sector.
2187
                if(!retvalue)                                                                                                                           // file not found in this sector so take next sector.
2153
                {
2188
                {
2154
                file.SectorOfCurrCluster++;                            
-
 
2155
                        if(file.SectorOfCurrCluster >= Partition.SectorsPerCluster)
2189
                        /* in the next sector we start looking for the specified entry beginning at index 0 */
2156
                {  
2190
                        index = 0;
-
 
2191
                        /* there are still sectors to be read within the cluster or within the linear addresspace of the rootdirectory */
-
 
2192
                        if(file.SectorOfCurrCluster < max_dir_sector-1)  file.SectorOfCurrCluster++; else end_of_directory_not_reached = 0;
-
 
2193
                        /* if we are looking for an directoryentry outside the rootdirectory and have reached the end of the cluster we have to get the next one */
2157
                                file.SectorOfCurrCluster=0;
2194
                        if(Partition.FirstDataSector <= file.FirstSectorOfCurrCluster)
-
 
2195
                        {
2158
                                end_of_directory_not_reached = GetNextCluster(&file);
2196
                                end_of_directory_not_reached = GetNextCluster(&file);
2159
                        }
2197
                        }
2160
                }
2198
                }
2161
                index = 0;
-
 
2162
        }
2199
        }
2163
        while((end_of_directory_not_reached) && (!retvalue));
2200
        while((end_of_directory_not_reached) && (!retvalue));
Line 2164... Line 2201...
2164
 
2201
 
2165
        return(retvalue);      
2202
        return(retvalue);      
Line -... Line 2203...
-
 
2203
}
-
 
2204
 
2166
}
2205
 
2167
 
2206
 
2168
 
2207
 
2169
/********************************************************************************************************************************************/
2208
/********************************************************************************************************************************************/
2170
/*      Function:               findnext_(Find_t *);                                                                                                                                                                                                                    */
2209
/*      Function:               findnext_(Find_t *);                                                                                                                                                                                                                    */
Line 2193... Line 2232...
2193
}
2232
}
Line 2194... Line 2233...
2194
 
2233
 
2195
 
2234
 
2196
 
2235
 
2197
/********************************************************************************************************************************************/
2236
/********************************************************************************************************************************************/
2198
/*      Function:               findfirst_(s8* filename, u8 attribfilter, u8 attribmask, Find_t *);                                                                                                                             */
2237
/*      Function:               findfirst_(s8* filename, u8 attribmask, Find_t *);                                                                                                                                              */
2199
/*                                                                                                                                                                                                                                                                                      */
2238
/*                                                                                                                                                                                                                                                                                      */
2200
/*      Description:    This function looks for the first item in the specified directory with a matching filename and fileattributes                   */
2239
/*      Description:    This function looks for the first item in the specified directory with a matching filename and fileattributes                   */
Line 2365... Line 2404...
2365
void RemoveLastDirFromPath(void)
2404
void RemoveLastDirFromPath(void)
2366
{
2405
{
2367
        /* a pointer to the beginning of the absolute path to the cwd */
2406
        /* a pointer to the beginning of the absolute path to the cwd */
2368
        s8 * cptr = Partition.PathToCwd;
2407
        s8 * cptr = Partition.PathToCwd;
2369
        /* lets find the end of the path to the cwd */
2408
        /* lets find the end of the path to the cwd */
2370
        while(*cptr++ != 0);
2409
        while(*cptr != 0) cptr++;
-
 
2410
        /* if the path is terminated with an '/' */
-
 
2411
        if((*(cptr-1)) == '/') *(cptr-1)=0;    
2371
        /* now lets find the beginning of the last directorientry */
2412
        /* now lets find the beginning of the last directorientry */
-
 
2413
        while((*cptr != '/') && cptr > Partition.PathToCwd) cptr--;
-
 
2414
        /* is there one subdirectory left within the path? */
2372
        while(*cptr-- != '/');
2415
        if(cptr > Partition.PathToCwd)
-
 
2416
        {
2373
        /* we delete the direntry by terminating the path with 0 */
2417
                /* we delete the direntry by terminating the path with 0 */
2374
        *++cptr = 0;
2418
                *cptr = 0;
-
 
2419
        }
-
 
2420
        /* there is no subdirectory left within the path. Therefore we create the root instead. */
-
 
2421
        else
-
 
2422
        {
-
 
2423
                *cptr = '/';
-
 
2424
                *(cptr+1) = 0;
-
 
2425
        }
2375
}
2426
}
Line 2376... Line 2427...
2376
 
2427
 
2377
/********************************************************************************************************************************************/
2428
/********************************************************************************************************************************************/
2378
/*      Function:               chdir_(s8* filepath);                                                                                                                                                                                                   */
2429
/*      Function:               chdir_(s8* filepath);                                                                                                                                                                                                   */
2379
/*                                                                                                                                                                                                                                                                                      */
2430
/*                                                                                                                                                                                                                                                                                      */
2380
/*      Description:    This function changed the current working directory to the directory specified by the filepath                                                  */
2431
/*      Description:    This function changed the current working directory to the directory specified by the filepath                                                  */
2381
/*                  by function findfirst()                                                                                                                                                                                                     */
2432
/*                  by function findfirst()                                                                                                                                                                                                     */
2382
/*                                                                                                                                                                                                                                                                                      */
2433
/*                                                                                                                                                                                                                                                                                      */
2383
/*      Returnvalue:                                                                                                                                                                                                                                                    */
2434
/*      Returnvalue:                                                                                                                                                                                                                                                    */
2384
/********************************************************************************************************************************************/
2435
/********************************************************************************************************************************************/
2385
/*
2436
/*                                                                         
2386
#define ATTR_NONE               0x00    // normal file
2437
#define ATTR_NONE               0x00    // normal file
2387
#define ATTR_READONLY           0x01    // file is readonly
2438
#define ATTR_READONLY           0x01    // file is readonly
2388
#define ATTR_HIDDEN                     0x02    // file is hidden
2439
#define ATTR_HIDDEN                     0x02    // file is hidden
2389
#define ATTR_SYSTEM                     0x04    // file is a system file
2440
#define ATTR_SYSTEM                     0x04    // file is a system file
Line 2406... Line 2457...
2406
 
2457
 
2407
        /* lets remember the actual path */
2458
        /* lets remember the actual path */
2408
        strcpy(tp, Partition.PathToCwd);
2459
        strcpy(tp, Partition.PathToCwd);
2409
        cwdt = Partition.CurrentWorkingDirectory;
2460
        cwdt = Partition.CurrentWorkingDirectory;
-
 
2461
        /* if the path is absolute we begin at the rootdirectory */
-
 
2462
        if(path[0] == '/')
2410
        /* if the path is absolute we begin at the rootdirectory */
2463
        {
-
 
2464
                strcpy(Partition.PathToCwd, "/");
-
 
2465
                Partition.CurrentWorkingDirectory = Partition.FirstRootDirSector;
2411
        strcpy(Partition.PathToCwd, "/");
2466
        }
2412
        /* how many subdirectories are there within the path? */
2467
        /* how many subdirectories are there within the path? */
2413
        dircount = GetDirCount(path);  
2468
        dircount = GetDirCount(path);  
2414
        /* now we parse through all the subdirectories within the path */
2469
        /* now we parse through all the subdirectories within the path */
2415
        do
2470
        do
Line 2445... Line 2500...
2445
        while(dircount && retvalue);
2500
        while(dircount && retvalue);
Line 2446... Line 2501...
2446
 
2501
 
2447
        /* if we could not change to the specified directory we restore the actual path */
2502
        /* if we could not change to the specified directory we restore the actual path */
2448
        if(!retvalue)
2503
        if(!retvalue)
2449
        {
2504
        {
2450
                Partition.CurrentWorkingDirectory = cwdt;
2505
                Partition.CurrentWorkingDirectory = cwdt;                                                  
2451
                strcpy(Partition.PathToCwd, tp);
2506
                strcpy(Partition.PathToCwd, tp);
2452
        }
2507
        }
2453
        return(retvalue);      
2508
        return(retvalue);      
Line 2454... Line -...
2454
}
-
 
2455
 
-
 
2456
/********************************************************************************************************************************************/
-
 
2457
/*      Function:               void Test(void);                                                                                                                                                                                                                */
-
 
2458
/*                                                                                                                                                                                                                                                                                      */
-
 
2459
/*      Description:    Diese Funktion demonstriert die Möglichkeiten der Funktionen findfirst_() findnext_() und changedir_()                                  */
-
 
2460
/*                                                                                                                                                                                                                                                              */
-
 
2461
/*                                                                                                                                                                                                                                                                                      */
-
 
-
 
2509
}
Line 2462... Line 2510...
2462
/*      Returnvalue:                                                                                                                                                                                                                                                    */
2510
 
2463
/********************************************************************************************************************************************/
2511
 
2464
 
-
 
2465
void Test(void)
2512
 
2466
{
-
 
2467
        File_t *fp = NULL;
-
 
2468
        Find_t fe;
-
 
2469
        u32 cwd = 0;
-
 
2470
 
-
 
2471
 
-
 
2472
        cwd = Partition.CurrentWorkingDirectory;
-
 
2473
sprintf(text,"\r\n Path: %s\r\n",Partition.PathToCwd); UART1_PutString(text);
-
 
2474
        /* Als Erstes suchen wir uns das erste Unterverzeichnis (ATTR_SUBDIRECTORY) auf der Speicherkarte */
-
 
2475
        if(findfirst_("*.*", ATTR_SUBDIRECTORY, &fe))
-
 
2476
        {
-
 
2477
                /* Danach wechseln wir in in dieses Unterverzeichnis auf der speicherkarte */
-
 
2478
                if(chdir_(fe.name))
-
 
2479
                {
-
 
2480
sprintf(text,"\r\n Path: %s\r\n",Partition.PathToCwd); UART1_PutString(text);
-
 
2481
                        /* Dann finden wir die erste Datei (ATTR_ARCIVE) in diesem Unterverzeichnis */
-
 
2482
                        if(findfirst_("*.*", ATTR_ARCHIVE, &fe))
-
 
2483
                        {
-
 
2484
                                /* Der Name der gefundenen Datei wird ausgegeben */
-
 
2485
                                UART1_PutString("\r\n");
-
 
2486
                                UART1_PutString(fe.name);              
-
 
2487
                                /* nun wir die erste gefundene Datei im Unterverzeichnis lesend geöffnet */
-
 
2488
                                fp = fopen_(fe.name, 'r');
-
 
2489
                                if(fp != NULL){
-
 
2490
                                        /* und die erste Zeile aus dem Inhalt ausgegeben */
-
 
2491
                                        fgets_(text,60,fp);
-
 
2492
                                        UART1_PutString("\r\n");
-
 
2493
                                        UART1_PutString(text);
2513
void Test(void)
2494
                                        fclose_(fp);
-
 
2495
                                }
-
 
Line -... Line 2514...
-
 
2514
{
-
 
2515
        Find_t find;
-
 
2516
        text[64];
-
 
2517
 
-
 
2518
        UART1_PutString("\r\nsearching for elements in CWD:");
-
 
2519
        UART1_PutString(GetPath());
-
 
2520
                                                                                 
-
 
2521
        if(chdir_("log"))
-
 
2522
        {
-
 
2523
                UART1_PutString(" done");
-
 
2524
                UART1_PutString("\r\n cwd: "); UART1_PutString(GetPath());
-
 
2525
 
-
 
2526
                if(chdir_("log11"))
-
 
2527
                {
-
 
2528
                        UART1_PutString(" done");
-
 
2529
                        UART1_PutString("\r\n cwd: "); UART1_PutString(GetPath());
-
 
2530
 
-
 
2531
                        if(chdir_("log12"))
-
 
2532
                        {
-
 
2533
                                UART1_PutString(" done");
2496
                                else {
2534
                                UART1_PutString("\r\n cwd: "); UART1_PutString(GetPath());
2497
                                        UART1_PutString("\r\nfile not found");
2535
 
-
 
2536
                                if(findfirst_("*.*", 0xff, &find))
-
 
2537
                                {
-
 
2538
                                        sprintf(text,"\r\n %s %x",find.name, find.fp.Attribute); UART1_PutString(text);
-
 
2539
                                        while(findnext_(&find))
-
 
2540
                                        {
2498
                                }
2541
                                                sprintf(text,"\r\n %s %x",find.name, find.fp.Attribute); UART1_PutString(text);
2499
 
-
 
2500
                                /* anschließend suchen wir alle weiteren Dateien im aktuellen Unterverzeichnis */              
2542
                                        }
2501
                                while(findnext_(&fe))
2543
                                }
2502
                                {
-
 
2503
                                        /* und geben ebenfalls deren Namen */
2544
                                if(chdir_("."))
2504
                                        UART1_PutString("\r\n");
-
 
2505
                                        UART1_PutString(fe.name);              
2545
                                {
-
 
2546
                                        UART1_PutString(" done");
2506
                                        /* sowie nach dem Öffnen ihren Inhalt aus */
2547
                                        UART1_PutString("\r\n cwd: "); UART1_PutString(GetPath());
2507
                                        fp = fopen_(fe.name, 'r');
2548
                                        if(findfirst_("*.*", 0xff, &find))
2508
                                        if(fp != NULL)
2549
                                        {
2509
                                        {
2550
                                                sprintf(text,"\r\n %s %x",find.name, find.fp.Attribute); UART1_PutString(text);
2510
                                                fgets_(text,60,fp);
2551
                                                while(findnext_(&find))
2511
                                                UART1_PutString("\r\n");
2552
                                                {
-
 
2553
                                                        sprintf(text,"\r\n %s %x",find.name, find.fp.Attribute); UART1_PutString(text);
-
 
2554
                                                }
-
 
2555
                                        }
-
 
2556
                                }
-
 
2557
                                else UART1_PutString(" failed");
-
 
2558
                                if(chdir_(".."))
-
 
2559
                                {
-
 
2560
                                        UART1_PutString(" done");
-
 
2561
                                        UART1_PutString("\r\n cwd: "); UART1_PutString(GetPath());
-
 
2562
                                        if(findfirst_("*.*", 0xff, &find))
-
 
2563
                                        {
-
 
2564
                                                sprintf(text,"\r\n %s %x",find.name, find.fp.Attribute); UART1_PutString(text);
-
 
2565
                                                while(findnext_(&find))
-
 
2566
                                                {
-
 
2567
                                                        sprintf(text,"\r\n %s %x",find.name, find.fp.Attribute); UART1_PutString(text);
-
 
2568
                                                }
-
 
2569
                                        }
-
 
2570
                                }      
-
 
2571
                                else UART1_PutString(" failed");
-
 
2572
                                if(chdir_(".."))
-
 
2573
                                {
-
 
2574
                                        UART1_PutString(" done");
-
 
2575
                                        UART1_PutString("\r\n cwd: "); UART1_PutString(GetPath());
-
 
2576
                                        if(findfirst_("*.*", 0xff, &find))
-
 
2577
                                        {
-
 
2578
                                                sprintf(text,"\r\n %s %x",find.name, find.fp.Attribute); UART1_PutString(text);
-
 
2579
                                                while(findnext_(&find))
-
 
2580
                                                {
-
 
2581
                                                        sprintf(text,"\r\n %s %x",find.name, find.fp.Attribute); UART1_PutString(text);
-
 
2582
                                                }
-
 
2583
                                        }
-
 
2584
                                }      
-
 
2585
                                else UART1_PutString(" failed");
-
 
2586
                                if(chdir_(".."))
-
 
2587
                                {
-
 
2588
                                        UART1_PutString(" done");
-
 
2589
                                        UART1_PutString("\r\n cwd: "); UART1_PutString(GetPath());
-
 
2590
                                        if(findfirst_("*.*", 0xff, &find))
-
 
2591
                                        {
-
 
2592
                                                sprintf(text,"\r\n %s %x",find.name, find.fp.Attribute); UART1_PutString(text);
-
 
2593
                                                while(findnext_(&find))
-
 
2594
                                                {
-
 
2595
                                                        sprintf(text,"\r\n %s %x",find.name, find.fp.Attribute); UART1_PutString(text);
2512
                                                UART1_PutString(text);
2596
                                                }
2513
                                                fclose_(fp);
2597
                                        }
2514
                                        }
2598
                                }      
2515
                                }
-
 
2516
                        }
-
 
2517
                }
-
 
2518
        }
-
 
2519
        Partition.CurrentWorkingDirectory = cwd;
-
 
2520
sprintf(text,"\r\n Path: %s\r\n",Partition.PathToCwd); UART1_PutString(text);
-
 
2521
        if(chdir_("/ordner1/ordner12/ordner13"))
-
 
2522
        {
-
 
2523
sprintf(text,"\r\n Path: %s\r\n",Partition.PathToCwd); UART1_PutString(text);
-
 
2524
                fp = fopen_("Datei13.txt", 'r');
2599
                                else UART1_PutString(" failed");
2525
                if(fp != NULL){
-
 
2526
                        /* und die erste Zeile aus dem Inhalt ausgegeben */
-
 
2527
                        fgets_(text,60,fp);
-
 
2528
                        UART1_PutString("\r\n");
-
 
2529
                        UART1_PutString(text);
-
 
2530
                        fclose_(fp);
-
 
2531
                }
-
 
2532
                else {
-
 
2533
                        UART1_PutString("\r\nfile not found");
-
 
2534
                }                              
-
 
2535
        }
-
 
2536
        else
-
 
2537
                UART1_PutString("\r\ndirectory not found");
2600
                        }
2538
        /* jetzt sind wir wieder im Rootverzeichnis */
-