]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_SmartFusion2_M2S050_SoftConsole/RTOSDemo/Full-Demo/File-releated-CLI-commands.c
Add additional critical section to the default tickless implementations.
[freertos] / FreeRTOS / Demo / CORTEX_SmartFusion2_M2S050_SoftConsole / RTOSDemo / Full-Demo / File-releated-CLI-commands.c
1 /*\r
2     FreeRTOS V7.5.2 - Copyright (C) 2013 Real Time Engineers Ltd.\r
3 \r
4     FEATURES AND PORTS ARE ADDED TO FREERTOS ALL THE TIME.  PLEASE VISIT\r
5     http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
6 \r
7     ***************************************************************************\r
8      *                                                                       *\r
9      *    FreeRTOS tutorial books are available in pdf and paperback.        *\r
10      *    Complete, revised, and edited pdf reference manuals are also       *\r
11      *    available.                                                         *\r
12      *                                                                       *\r
13      *    Purchasing FreeRTOS documentation will not only help you, by       *\r
14      *    ensuring you get running as quickly as possible and with an        *\r
15      *    in-depth knowledge of how to use FreeRTOS, it will also help       *\r
16      *    the FreeRTOS project to continue with its mission of providing     *\r
17      *    professional grade, cross platform, de facto standard solutions    *\r
18      *    for microcontrollers - completely free of charge!                  *\r
19      *                                                                       *\r
20      *    >>> See http://www.FreeRTOS.org/Documentation for details. <<<     *\r
21      *                                                                       *\r
22      *    Thank you for using FreeRTOS, and thank you for your support!      *\r
23      *                                                                       *\r
24     ***************************************************************************\r
25 \r
26 \r
27     This file is part of the FreeRTOS distribution.\r
28 \r
29     FreeRTOS is free software; you can redistribute it and/or modify it under\r
30     the terms of the GNU General Public License (version 2) as published by the\r
31     Free Software Foundation AND MODIFIED BY the FreeRTOS exception.\r
32 \r
33     >>>>>>NOTE<<<<<< The modification to the GPL is included to allow you to\r
34     distribute a combined work that includes FreeRTOS without being obliged to\r
35     provide the source code for proprietary components outside of the FreeRTOS\r
36     kernel.\r
37 \r
38     FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
39     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
40     FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more\r
41     details. You should have received a copy of the GNU General Public License\r
42     and the FreeRTOS license exception along with FreeRTOS; if not itcan be\r
43     viewed here: http://www.freertos.org/a00114.html and also obtained by\r
44     writing to Real Time Engineers Ltd., contact details for whom are available\r
45     on the FreeRTOS WEB site.\r
46 \r
47     1 tab == 4 spaces!\r
48 \r
49     ***************************************************************************\r
50      *                                                                       *\r
51      *    Having a problem?  Start by reading the FAQ "My application does   *\r
52      *    not run, what could be wrong?"                                     *\r
53      *                                                                       *\r
54      *    http://www.FreeRTOS.org/FAQHelp.html                               *\r
55      *                                                                       *\r
56     ***************************************************************************\r
57 \r
58 \r
59     http://www.FreeRTOS.org - Documentation, books, training, latest versions,\r
60     license and Real Time Engineers Ltd. contact details.\r
61 \r
62     http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
63     including FreeRTOS+Trace - an indispensable productivity tool, and our new\r
64     fully thread aware and reentrant UDP/IP stack.\r
65 \r
66     http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High\r
67     Integrity Systems, who sell the code with commercial support,\r
68     indemnification and middleware, under the OpenRTOS brand.\r
69 \r
70     http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
71     engineered and independently SIL3 certified version for use in safety and\r
72     mission critical applications that require provable dependability.\r
73 */\r
74 \r
75 /* FreeRTOS includes. */\r
76 #include "FreeRTOS.h"\r
77 #include "task.h"\r
78 \r
79 /* Standard includes. */\r
80 #include <stdint.h>\r
81 #include <stdio.h>\r
82 #include <stdlib.h>\r
83 #include <string.h>\r
84 \r
85 /* FreeRTOS+CLI includes. */\r
86 #include "FreeRTOS_CLI.h"\r
87 \r
88 /* File system includes. */\r
89 #include "fat_sl.h"\r
90 #include "api_mdriver_ram.h"\r
91 \r
92 #ifdef _WINDOWS_\r
93         #define snprintf _snprintf\r
94 #endif\r
95 \r
96 #define cliNEW_LINE             "\r\n"\r
97 \r
98 /*******************************************************************************\r
99  * See the URL in the comments within main.c for the location of the online\r
100  * documentation.\r
101  ******************************************************************************/\r
102 \r
103 /*\r
104  * Print out information on a single file.\r
105  */\r
106 static void prvCreateFileInfoString( int8_t *pcBuffer, F_FIND *pxFindStruct );\r
107 \r
108 /*\r
109  * Copies an existing file into a newly created file.\r
110  */\r
111 static portBASE_TYPE prvPerformCopy( int8_t *pcSourceFile,\r
112                                                         int32_t lSourceFileLength,\r
113                                                         int8_t *pcDestinationFile,\r
114                                                         int8_t *pxWriteBuffer,\r
115                                                         size_t xWriteBufferLen );\r
116 \r
117 /*\r
118  * Implements the DIR command.\r
119  */\r
120 static portBASE_TYPE prvDIRCommand( int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString );\r
121 \r
122 /*\r
123  * Implements the CD command.\r
124  */\r
125 static portBASE_TYPE prvCDCommand( int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString );\r
126 \r
127 /*\r
128  * Implements the DEL command.\r
129  */\r
130 static portBASE_TYPE prvDELCommand( int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString );\r
131 \r
132 /*\r
133  * Implements the TYPE command.\r
134  */\r
135 static portBASE_TYPE prvTYPECommand( int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString );\r
136 \r
137 /*\r
138  * Implements the COPY command.\r
139  */\r
140 static portBASE_TYPE prvCOPYCommand( int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString );\r
141 \r
142 /* Structure that defines the DIR command line command, which lists all the\r
143 files in the current directory. */\r
144 static const CLI_Command_Definition_t xDIR =\r
145 {\r
146         ( const int8_t * const ) "dir", /* The command string to type. */\r
147         ( const int8_t * const ) "\r\ndir:\r\n Lists the files in the current directory\r\n",\r
148         prvDIRCommand, /* The function to run. */\r
149         0 /* No parameters are expected. */\r
150 };\r
151 \r
152 /* Structure that defines the CD command line command, which changes the\r
153 working directory. */\r
154 static const CLI_Command_Definition_t xCD =\r
155 {\r
156         ( const int8_t * const ) "cd", /* The command string to type. */\r
157         ( const int8_t * const ) "\r\ncd <dir name>:\r\n Changes the working directory\r\n",\r
158         prvCDCommand, /* The function to run. */\r
159         1 /* One parameter is expected. */\r
160 };\r
161 \r
162 /* Structure that defines the TYPE command line command, which prints the\r
163 contents of a file to the console. */\r
164 static const CLI_Command_Definition_t xTYPE =\r
165 {\r
166         ( const int8_t * const ) "type", /* The command string to type. */\r
167         ( const int8_t * const ) "\r\ntype <filename>:\r\n Prints file contents to the terminal\r\n",\r
168         prvTYPECommand, /* The function to run. */\r
169         1 /* One parameter is expected. */\r
170 };\r
171 \r
172 /* Structure that defines the DEL command line command, which deletes a file. */\r
173 static const CLI_Command_Definition_t xDEL =\r
174 {\r
175         ( const int8_t * const ) "del", /* The command string to type. */\r
176         ( const int8_t * const ) "\r\ndel <filename>:\r\n deletes a file or directory\r\n",\r
177         prvDELCommand, /* The function to run. */\r
178         1 /* One parameter is expected. */\r
179 };\r
180 \r
181 /* Structure that defines the COPY command line command, which deletes a file. */\r
182 static const CLI_Command_Definition_t xCOPY =\r
183 {\r
184         ( const int8_t * const ) "copy", /* The command string to type. */\r
185         ( const int8_t * const ) "\r\ncopy <source file> <dest file>:\r\n Copies <source file> to <dest file>\r\n",\r
186         prvCOPYCommand, /* The function to run. */\r
187         2 /* Two parameters are expected. */\r
188 };\r
189 \r
190 /*-----------------------------------------------------------*/\r
191 \r
192 void vRegisterFileSystemCLICommands( void )\r
193 {\r
194         /* Register all the command line commands defined immediately above. */\r
195         FreeRTOS_CLIRegisterCommand( &xDIR );\r
196         FreeRTOS_CLIRegisterCommand( &xCD );\r
197         FreeRTOS_CLIRegisterCommand( &xTYPE );\r
198         FreeRTOS_CLIRegisterCommand( &xDEL );\r
199         FreeRTOS_CLIRegisterCommand( &xCOPY );\r
200 }\r
201 /*-----------------------------------------------------------*/\r
202 \r
203 static portBASE_TYPE prvTYPECommand( int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString )\r
204 {\r
205 int8_t *pcParameter;\r
206 portBASE_TYPE xParameterStringLength, xReturn = pdTRUE;\r
207 static F_FILE *pxFile = NULL;\r
208 int iChar;\r
209 size_t xByte;\r
210 size_t xColumns = 50U;\r
211 \r
212         /* Ensure there is always a null terminator after each character written. */\r
213         memset( pcWriteBuffer, 0x00, xWriteBufferLen );\r
214 \r
215         /* Ensure the buffer leaves space for the \r\n. */\r
216         configASSERT( xWriteBufferLen > ( strlen( cliNEW_LINE ) * 2 ) );\r
217         xWriteBufferLen -= strlen( cliNEW_LINE );\r
218 \r
219         if( xWriteBufferLen < xColumns )\r
220         {\r
221                 /* Ensure the loop that uses xColumns as an end condition does not\r
222                 write off the end of the buffer. */\r
223                 xColumns = xWriteBufferLen;\r
224         }\r
225 \r
226         if( pxFile == NULL )\r
227         {\r
228                 /* The file has not been opened yet.  Find the file name. */\r
229                 pcParameter = ( int8_t * ) FreeRTOS_CLIGetParameter\r
230                                                                         (\r
231                                                                                 pcCommandString,                /* The command string itself. */\r
232                                                                                 1,                                              /* Return the first parameter. */\r
233                                                                                 &xParameterStringLength /* Store the parameter string length. */\r
234                                                                         );\r
235 \r
236                 /* Sanity check something was returned. */\r
237                 configASSERT( pcParameter );\r
238 \r
239                 /* Attempt to open the requested file. */\r
240                 pxFile = f_open( ( const char * ) pcParameter, "r" );\r
241         }\r
242 \r
243         if( pxFile != NULL )\r
244         {\r
245                 /* Read the next chunk of data from the file. */\r
246                 for( xByte = 0; xByte < xColumns; xByte++ )\r
247                 {\r
248                         iChar = f_getc( pxFile );\r
249 \r
250                         if( iChar == -1 )\r
251                         {\r
252                                 /* No more characters to return. */\r
253                                 f_close( pxFile );\r
254                                 pxFile = NULL;\r
255                                 break;\r
256                         }\r
257                         else\r
258                         {\r
259                                 pcWriteBuffer[ xByte ] = ( int8_t ) iChar;\r
260                         }\r
261                 }\r
262         }\r
263 \r
264         if( pxFile == NULL )\r
265         {\r
266                 /* Either the file was not opened, or all the data from the file has\r
267                 been returned and the file is now closed. */\r
268                 xReturn = pdFALSE;\r
269         }\r
270 \r
271         strcat( ( char * ) pcWriteBuffer, cliNEW_LINE );\r
272 \r
273         return xReturn;\r
274 }\r
275 /*-----------------------------------------------------------*/\r
276 \r
277 static portBASE_TYPE prvCDCommand( int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString )\r
278 {\r
279 int8_t *pcParameter;\r
280 portBASE_TYPE xParameterStringLength;\r
281 unsigned char ucReturned;\r
282 size_t xStringLength;\r
283 \r
284         /* Obtain the parameter string. */\r
285         pcParameter = ( int8_t * ) FreeRTOS_CLIGetParameter\r
286                                                                 (\r
287                                                                         pcCommandString,                /* The command string itself. */\r
288                                                                         1,                                              /* Return the first parameter. */\r
289                                                                         &xParameterStringLength /* Store the parameter string length. */\r
290                                                                 );\r
291 \r
292         /* Sanity check something was returned. */\r
293         configASSERT( pcParameter );\r
294 \r
295         /* Attempt to move to the requested directory. */\r
296         ucReturned = f_chdir( ( char * ) pcParameter );\r
297 \r
298         if( ucReturned == F_NO_ERROR )\r
299         {\r
300                 sprintf( ( char * ) pcWriteBuffer, "In: " );\r
301                 xStringLength = strlen( ( const char * ) pcWriteBuffer );\r
302                 f_getcwd( ( char * ) &( pcWriteBuffer[ xStringLength ] ), ( unsigned char ) ( xWriteBufferLen - xStringLength ) );\r
303         }\r
304         else\r
305         {\r
306                 sprintf( ( char * ) pcWriteBuffer, "Error" );\r
307         }\r
308 \r
309         strcat( ( char * ) pcWriteBuffer, cliNEW_LINE );\r
310 \r
311         return pdFALSE;\r
312 }\r
313 /*-----------------------------------------------------------*/\r
314 \r
315 static portBASE_TYPE prvDIRCommand( int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString )\r
316 {\r
317 static F_FIND *pxFindStruct = NULL;\r
318 unsigned char ucReturned;\r
319 portBASE_TYPE xReturn = pdFALSE;\r
320 \r
321         /* This assumes pcWriteBuffer is long enough. */\r
322         ( void ) pcCommandString;\r
323 \r
324         /* Ensure the buffer leaves space for the \r\n. */\r
325         configASSERT( xWriteBufferLen > ( strlen( cliNEW_LINE ) * 2 ) );\r
326         xWriteBufferLen -= strlen( cliNEW_LINE );\r
327 \r
328         if( pxFindStruct == NULL )\r
329         {\r
330                 /* This is the first time this function has been executed since the Dir\r
331                 command was run.  Create the find structure. */\r
332                 pxFindStruct = ( F_FIND * ) pvPortMalloc( sizeof( F_FIND ) );\r
333 \r
334                 if( pxFindStruct != NULL )\r
335                 {\r
336                         ucReturned = f_findfirst( "*.*", pxFindStruct );\r
337 \r
338                         if( ucReturned == F_NO_ERROR )\r
339                         {\r
340                                 prvCreateFileInfoString( pcWriteBuffer, pxFindStruct );\r
341                                 xReturn = pdPASS;\r
342                         }\r
343                         else\r
344                         {\r
345                                 snprintf( ( char * ) pcWriteBuffer, xWriteBufferLen, "Error: f_findfirst() failed." );\r
346                         }\r
347                 }\r
348                 else\r
349                 {\r
350                         snprintf( ( char * ) pcWriteBuffer, xWriteBufferLen, "Failed to allocate RAM (using heap_4.c will prevent fragmentation)." );\r
351                 }\r
352         }\r
353         else\r
354         {\r
355                 /* The find struct has already been created.  Find the next file in\r
356                 the directory. */\r
357                 ucReturned = f_findnext( pxFindStruct );\r
358 \r
359                 if( ucReturned == F_NO_ERROR )\r
360                 {\r
361                         prvCreateFileInfoString( pcWriteBuffer, pxFindStruct );\r
362                         xReturn = pdPASS;\r
363                 }\r
364                 else\r
365                 {\r
366                         /* There are no more files.  Free the find structure. */\r
367                         vPortFree( pxFindStruct );\r
368                         pxFindStruct = NULL;\r
369 \r
370                         /* No string to return. */\r
371                         pcWriteBuffer[ 0 ] = 0x00;\r
372                 }\r
373         }\r
374 \r
375         strcat( ( char * ) pcWriteBuffer, cliNEW_LINE );\r
376 \r
377         return xReturn;\r
378 }\r
379 /*-----------------------------------------------------------*/\r
380 \r
381 static portBASE_TYPE prvDELCommand( int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString )\r
382 {\r
383 int8_t *pcParameter;\r
384 portBASE_TYPE xParameterStringLength;\r
385 unsigned char ucReturned;\r
386 \r
387         /* This function assumes xWriteBufferLen is large enough! */\r
388         ( void ) xWriteBufferLen;\r
389 \r
390         /* Obtain the parameter string. */\r
391         pcParameter = ( int8_t * ) FreeRTOS_CLIGetParameter\r
392                                                                 (\r
393                                                                         pcCommandString,                /* The command string itself. */\r
394                                                                         1,                                              /* Return the first parameter. */\r
395                                                                         &xParameterStringLength /* Store the parameter string length. */\r
396                                                                 );\r
397 \r
398         /* Sanity check something was returned. */\r
399         configASSERT( pcParameter );\r
400 \r
401         /* Attempt to delete the file. */\r
402         ucReturned = f_delete( ( const char * ) pcParameter );\r
403 \r
404         if( ucReturned == F_NO_ERROR )\r
405         {\r
406                 sprintf( ( char * ) pcWriteBuffer, "%s was deleted", pcParameter );\r
407         }\r
408         else\r
409         {\r
410                 sprintf( ( char * ) pcWriteBuffer, "Error" );\r
411         }\r
412 \r
413         strcat( ( char * ) pcWriteBuffer, cliNEW_LINE );\r
414 \r
415         return pdFALSE;\r
416 }\r
417 /*-----------------------------------------------------------*/\r
418 \r
419 static portBASE_TYPE prvCOPYCommand( int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString )\r
420 {\r
421 int8_t *pcSourceFile, *pcDestinationFile;\r
422 portBASE_TYPE xParameterStringLength;\r
423 long lSourceLength, lDestinationLength = 0;\r
424 \r
425         /* Obtain the name of the destination file. */\r
426         pcDestinationFile = ( int8_t * ) FreeRTOS_CLIGetParameter\r
427                                                                 (\r
428                                                                         pcCommandString,                /* The command string itself. */\r
429                                                                         2,                                              /* Return the second parameter. */\r
430                                                                         &xParameterStringLength /* Store the parameter string length. */\r
431                                                                 );\r
432 \r
433         /* Sanity check something was returned. */\r
434         configASSERT( pcDestinationFile );\r
435 \r
436         /* Obtain the name of the source file. */\r
437         pcSourceFile = ( int8_t * ) FreeRTOS_CLIGetParameter\r
438                                                                 (\r
439                                                                         pcCommandString,                /* The command string itself. */\r
440                                                                         1,                                              /* Return the first parameter. */\r
441                                                                         &xParameterStringLength /* Store the parameter string length. */\r
442                                                                 );\r
443 \r
444         /* Sanity check something was returned. */\r
445         configASSERT( pcSourceFile );\r
446 \r
447         /* Terminate the string. */\r
448         pcSourceFile[ xParameterStringLength ] = 0x00;\r
449 \r
450         /* See if the source file exists, obtain its length if it does. */\r
451         lSourceLength = f_filelength( ( const char * ) pcSourceFile );\r
452 \r
453         if( lSourceLength == 0 )\r
454         {\r
455                 sprintf( ( char * ) pcWriteBuffer, "Source file does not exist" );\r
456         }\r
457         else\r
458         {\r
459                 /* See if the destination file exists. */\r
460                 lDestinationLength = f_filelength( ( const char * ) pcDestinationFile );\r
461 \r
462                 if( lDestinationLength != 0 )\r
463                 {\r
464                         sprintf( ( char * ) pcWriteBuffer, "Error: Destination file already exists" );\r
465                 }\r
466         }\r
467 \r
468         /* Continue only if the source file exists and the destination file does\r
469         not exist. */\r
470         if( ( lSourceLength != 0 ) && ( lDestinationLength == 0 ) )\r
471         {\r
472                 if( prvPerformCopy( pcSourceFile, lSourceLength, pcDestinationFile, pcWriteBuffer, xWriteBufferLen ) == pdPASS )\r
473                 {\r
474                         sprintf( ( char * ) pcWriteBuffer, "Copy made" );\r
475                 }\r
476                 else\r
477                 {\r
478                         sprintf( ( char * ) pcWriteBuffer, "Error during copy" );\r
479                 }\r
480         }\r
481 \r
482         strcat( ( char * ) pcWriteBuffer, cliNEW_LINE );\r
483 \r
484         return pdFALSE;\r
485 }\r
486 /*-----------------------------------------------------------*/\r
487 \r
488 static portBASE_TYPE prvPerformCopy( int8_t *pcSourceFile,\r
489                                                         int32_t lSourceFileLength,\r
490                                                         int8_t *pcDestinationFile,\r
491                                                         int8_t *pxWriteBuffer,\r
492                                                         size_t xWriteBufferLen )\r
493 {\r
494 int32_t lBytesRead = 0, lBytesToRead, lBytesRemaining;\r
495 F_FILE *pxFile;\r
496 portBASE_TYPE xReturn = pdPASS;\r
497 \r
498         /* NOTE:  Error handling has been omitted for clarity. */\r
499 \r
500         while( lBytesRead < lSourceFileLength )\r
501         {\r
502                 /* How many bytes are left? */\r
503                 lBytesRemaining = lSourceFileLength - lBytesRead;\r
504 \r
505                 /* How many bytes should be read this time around the loop.  Can't\r
506                 read more bytes than will fit into the buffer. */\r
507                 if( lBytesRemaining > ( long ) xWriteBufferLen )\r
508                 {\r
509                         lBytesToRead = ( long ) xWriteBufferLen;\r
510                 }\r
511                 else\r
512                 {\r
513                         lBytesToRead = lBytesRemaining;\r
514                 }\r
515 \r
516                 /* Open the source file, seek past the data that has already been\r
517                 read from the file, read the next block of data, then close the\r
518                 file again so the destination file can be opened. */\r
519                 pxFile = f_open( ( const char * ) pcSourceFile, "r" );\r
520                 if( pxFile != NULL )\r
521                 {\r
522                         f_seek( pxFile, lBytesRead, F_SEEK_SET );\r
523                         f_read( pxWriteBuffer, lBytesToRead, 1, pxFile );\r
524                         f_close( pxFile );\r
525                 }\r
526                 else\r
527                 {\r
528                         xReturn = pdFAIL;\r
529                         break;\r
530                 }\r
531 \r
532                 /* Open the destination file and write the block of data to the end of\r
533                 the file. */\r
534                 pxFile = f_open( ( const char * ) pcDestinationFile, "a" );\r
535                 if( pxFile != NULL )\r
536                 {\r
537                         f_write( pxWriteBuffer, lBytesToRead, 1, pxFile );\r
538                         f_close( pxFile );\r
539                 }\r
540                 else\r
541                 {\r
542                         xReturn = pdFAIL;\r
543                         break;\r
544                 }\r
545 \r
546                 lBytesRead += lBytesToRead;\r
547         }\r
548 \r
549         return xReturn;\r
550 }\r
551 /*-----------------------------------------------------------*/\r
552 \r
553 static void prvCreateFileInfoString( int8_t *pcBuffer, F_FIND *pxFindStruct )\r
554 {\r
555 const char *pcWritableFile = "writable file", *pcReadOnlyFile = "read only file", *pcDirectory = "directory";\r
556 const char * pcAttrib;\r
557 \r
558         /* Point pcAttrib to a string that describes the file. */\r
559         if( ( pxFindStruct->attr & F_ATTR_DIR ) != 0 )\r
560         {\r
561                 pcAttrib = pcDirectory;\r
562         }\r
563         else if( pxFindStruct->attr & F_ATTR_READONLY )\r
564         {\r
565                 pcAttrib = pcReadOnlyFile;\r
566         }\r
567         else\r
568         {\r
569                 pcAttrib = pcWritableFile;\r
570         }\r
571 \r
572         /* Create a string that includes the file name, the file size and the\r
573         attributes string. */\r
574         sprintf( ( char * ) pcBuffer, "%s [%s] [size=%d]", pxFindStruct->filename, pcAttrib, ( int ) pxFindStruct->filesize );\r
575 }\r