Ejemplo n.º 1
0
//! This function selects a file in the navigator via a file index
//!
//! @param     index       structure with information about file to select (disk, partition, dir, file/dir selected )
//!
//! @return    false in case of error, see global value "fs_g_status" for more detail
//! @return    true otherwise
//!
//! @verbatim
//! This routine allow to reinit a navigator quickly via a file index (disk, partition, dir, file/dir selected )
//! To get a file index, you shall used the routine nav_getindex().
//! @endverbatim
//!
bool  nav_filterlist_gotoindex( const Fs_index _MEM_TYPE_SLOW_ *index )
{
   if( !nav_drive_set( index->u8_lun ))
      return false;
#if (FS_MULTI_PARTITION  ==  true)
   if( !nav_partition_set(index->u8_partition))
      return false;
#endif
   if( !nav_partition_mount())
      return false;

    // Initialization of the current entry file with index information
   fs_g_nav.u32_cluster_sel_dir   = index->u32_cluster_sel_dir;

   // Reset position
   if ( !nav_filterlist_reset() )
      return false;

   // Research the index in directory
   while( fs_g_nav_fast.u16_entry_pos_sel_file != index->u16_entry_pos_sel_file )
   {
      if( !nav_filterlist_next() )
      {
         nav_filterlist_reset();
         return false;
      }
   }
   return true;
}
Ejemplo n.º 2
0
//! This function goes to a position in filtered file list
//!
//! @param     u16_newpos     new position to select (0 is the first position)
//!
//! @return    false in case of error, see global value "fs_g_status" for more detail
//! @return    true otherwise
//!
bool  nav_filterlist_goto( uint16_t u16_newpos )
{
   if (u16_newpos == FS_NO_SEL)
     return nav_filterlist_reset();

   if( u16_newpos < (fs_g_nav.u16_pos_filterlist/2) )
   {
      // Restart at the beginning of list to accelerate search
      if( !nav_filterlist_reset() )
         return false;
   }
   if( FS_NO_SEL == fs_g_nav.u16_pos_filterlist )
      if( !nav_filterlist_next() )
         return false;  // No file available
   while( u16_newpos > fs_g_nav.u16_pos_filterlist )
   {
      if( !nav_filterlist_next() )
         break;
   }
   while( u16_newpos < fs_g_nav.u16_pos_filterlist )
   {
      if( !nav_filterlist_previous() )
         break;
   }
   return (u16_newpos == fs_g_nav.u16_pos_filterlist);
}
Ejemplo n.º 3
0
//! This function goes to at the parent directory
//!
//! @return  false in case of error, see global value "fs_g_status" for more detail
//! @return  true otherwise
//!
//! @verbatim
//! After, the filtered file list changes and contains the files and directories of the new directory.
//! By default, the file selected in filtered file list is the previous (children) directory.
//! @endverbatim
//!
bool  nav_filterlist_gotoparent( void )
{
   uint32_t u32_cluster_old_dir;

   if (!fat_check_mount_noopen())
      return false;

   if (0 == fs_g_nav.u32_cluster_sel_dir)
   {
      fs_g_status = FS_ERR_IS_ROOT;        // There aren't parent
      return false;
   }

   // Select and read information about directory ".."
   fs_g_nav_fast.u16_entry_pos_sel_file = 1;
   if ( !fat_read_dir())
      return false;
   fat_get_entry_info();
   // Save the children directory cluster
   u32_cluster_old_dir = fs_g_nav.u32_cluster_sel_dir;

   // Select the parent directory via information present in the current directory ".."
   fs_g_nav.u32_cluster_sel_dir = fs_g_nav_entry.u32_cluster;

   // Select the children directory in new directory (=parent directory)
   if( false == nav_filterlist_reset())
      return false;
   while( nav_filterlist_next() )
   {
      if (fs_g_nav_entry.u32_cluster == u32_cluster_old_dir)
         return true;   // It is the children directory
   }
   fs_g_status = FS_ERR_FS;
   return false;
}
Ejemplo n.º 4
0
//! This function resets the pointer of selection, so "no file selected" in filtered file list
//!
//! @return  false in case of error, see global value "fs_g_status" for more detail
//! @return  true otherwise
//!
bool  nav_filterflat_reset( void )
{
   while( 0 != fs_g_nav.u8_flat_dir_level )
   {
      fs_g_nav.u8_flat_dir_level--;
      nav_dir_gotoparent();
   }
   fs_g_nav.u16_flat_pos_offset = 0;
   return nav_filterlist_reset();
}
Ejemplo n.º 5
0
//! This function goes to at the parent directory
//!
//! @return  false in case of error, see global value "fs_g_status" for more detail
//! @return  true otherwise
//!
//! @verbatim
//! After the selected file is the first entry
//! @endverbatim
//!
bool  nav_filterflat_gotoparent( void )
{
   _MEM_TYPE_SLOW_ Fs_index index;
   index = nav_getindex();
   while( 0 != fs_g_nav.u8_flat_dir_level )
   {
      fs_g_nav.u8_flat_dir_level--;
      nav_dir_gotoparent();
   }
   if( !nav_dir_gotoparent() )
   {
      nav_gotoindex( &index );
      return false;
   }
   // go to the beginning of FLAT list
   fs_g_nav.u8_flat_dir_level   = 0;
   fs_g_nav.u16_flat_pos_offset = 0;
   nav_filterlist_reset();
   nav_filterflat_next();
   return true;
}
Ejemplo n.º 6
0
//! This function affiliates an extension filter at current navigator
//!
//! @param     sz_filterext   extension filter (ASCII format, e.g.: "txt" or "txt,d*,wk" )
//!
void  nav_filterlist_setfilter( const FS_STRING sz_filterext  )
{
   fs_g_nav.sz_filterext = sz_filterext;
   nav_filterlist_reset();
}
Ejemplo n.º 7
0
//! This function computes the number of files and/or directories in filtered file list
//! This function is not blocking. It will return after \<retry\> iteration if the result
//! is not yet computed.
//!
//! @param      fl_type       FL_ALL  To check all types (files and directories). <br>
//!                           FL_DIR  To check the directory presence. <br>
//!                           FL_FILE To check the file presence.
//!
//! @param      sz_filterext  Extension filter (ASCII format, e.g.: "txt" or "txt,d*,wk" ). <br>
//!                           If this argument in NULL, then it uses the default filter used by the filterlist. <br>
//!                           This argument is also ignored for b_type == FS_DIR.
//! @param      p_total       Pointer to the result which will be updated by the function (added).
//!                           Initialization shall be done before entering into this function.
//! @param      retry         Number of files seen before leaving the function. 0 means that the
//!                           function is blocking until the result is known.
//!
//! @return     number of files and/or directories present in filtered file list.
//!
bool   nav_filterlist_nb_ex( fl_type_t fl_type, const FS_STRING sz_filterext, uint16_t* p_total, uint8_t retry )
{
   static uint16_t   u16_save_position;
   bool   b_is_dir;

   // save current position
   if( *p_total==(uint16_t) -1 )
   {
      u16_save_position = fs_g_nav.u16_pos_filterlist;

      // Reset position
      if ( !nav_filterlist_reset())
         return true;

      if (fl_type == FL_DIR)
        nav_filelist_single_enable(FS_DIR);
      else if (fl_type == FL_FILE)
        nav_filelist_single_enable(FS_FILE);

      *p_total = 0;
   }

   // Scan all
   while( nav_filelist_set( 0, FS_FIND_NEXT ) )
   {
      b_is_dir = nav_file_isdir();

      // Check if its a file for FL_FILE mode
      if (fl_type == FL_FILE && b_is_dir)
      {
        if (!update_counter(&retry))
          return false;
        continue;
      }
      // Check if its a directory for FL_DIR mode
      if (fl_type == FL_DIR && !b_is_dir)
      {
        if (!update_counter(&retry))
          return false;
        continue;
      }
      // If the selection is on a file
      if (!b_is_dir)
      {
        // Check the extension of the file
        if (!((sz_filterext)?nav_file_checkext(sz_filterext):nav_file_checkext(fs_g_nav.sz_filterext)))
          if (!update_counter(&retry))
            return false;
      }

      (*p_total)++;
      if (!update_counter(&retry))
         return false;
   }

   nav_filelist_single_disable();

   // Restore previous position
   if ( u16_save_position != FS_NO_SEL )
   {
      nav_filterlist_reset();
   }else{
      // After operation, there are a file selected
      nav_filterlist_goto( u16_save_position );
   }
   return true;
}