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