_io_mfs_dir_close() failing

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

_io_mfs_dir_close() failing

Jump to solution
514 Views
netra
Contributor IV

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);

Labels (1)
0 Kudos
Reply
1 Solution
353 Views
netra
Contributor IV

I got reason dir_ptr should have been pointer , thats why it is failing

View solution in original post

0 Kudos
Reply
1 Reply
354 Views
netra
Contributor IV

I got reason dir_ptr should have been pointer , thats why it is failing

0 Kudos
Reply