AnsweredAssumed Answered

_io_mfs_dir_close() failing

Question asked by netra on Oct 24, 2013
Latest reply on Oct 28, 2013 by netra

I am using mqx 3.5 , I wrote a code to count no. of files present in root directory wiith extension ".txt".

It is crashing while closing directory.I have attached the code also below .

char *arg[2];

    DIR_STRUCT_PTR       dir_ptr;

    int result;

    char_ptr             path_ptr, mode_ptr;

    int_32 error = 0;

      int_32               return_code = SHELL_EXIT_SUCCESS;

    char  *buffer_file = NULL;

    path_ptr  ="*.txt";

    mode_ptr = "m*";

    arg[1] = path_ptr;

    arg[2] = mode_ptr;

   

    message.header.size = sizeof(sSoeFile);

           fs_ptr = Shell_get_current_filesystem(arg);

    if (fs_ptr == NULL) 

    {

         printf("Error, file system not mounted\n");

         return_code = SHELL_EXIT_ERROR;

    }

    else 

    {

            buffer_file = _mem_alloc(FILE_MAXSIZE);

           

            if (buffer_file && !error)

            {           

               dir_ptr = _io_mfs_dir_open(fs_ptr, path_ptr, mode_ptr );

                if (dir_ptr == NULL) 

                {   

                  printf("File not found.\n");

                }

                else

                {

                      while ((_io_is_fs_valid(fs_ptr)) && (len = _io_mfs_dir_read(dir_ptr, buffer_file, BUFFER_SIZE)) > 0)

                        totalfile++;                                      

                }

               

             }

             else

             {

                 printf("Memory allocation Error\n");

             }

    }

    _io_mfs_dir_close(dir_ptr);

Outcomes