コード例 #1
0
ファイル: nav_filterlist.c プロジェクト: Ripagood/AVR-NES
//! 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;
}
コード例 #2
0
//! This function moves back to the parent directory and selects this directory
//!
//! @param b_direction  direction of navigation (FS_FIND_NEXT or FS_FIND_PREV)
//!
//! @return     The state of the function
//!
static navauto_mov_explorer_rec_t navauto_mov_explorer_updir(bool b_direction)
{
  bool b_updir_ok = false;

  // To support directory only mode
  if (g_navauto_exp_mode == NAVAUTO_MODE_DIRONLY)
    return NAVAUTO_MOV_EXPLORER_ERROR;

  // To Support subdirectories mode
  if (g_navauto_exp_mode == NAVAUTO_MODE_DIRSUB)
  {
    // If the selection is on the root level
    if (g_navauto_u16_dir_level <= g_navauto_u16_dir_level_root)
      return NAVAUTO_MOV_EXPLORER_ERROR;
  }

#if defined(NAVAUTO_SPEED_OPTIMIZATION) && NAVAUTO_SPEED_OPTIMIZATION == true
  if (i_navauto_cache >= 0)
  {
    if (i_navauto_cache >= NAVAUTO_SPEED_OPTIMIZATION_LEVEL)
    {
      if (nav_dir_gotoparent())
      {
        b_updir_ok = true;
        i_navauto_cache--;
      }
    }
    else
    {
      fat_clear_entry_info_and_ptr();
      // Look for the "../" directory entry
      fs_g_nav_fast.u16_entry_pos_sel_file = 1;
      if (!fat_read_dir())
        return NAVAUTO_MOV_EXPLORER_ERROR;
      fat_get_entry_info();

      fs_g_nav.u32_cluster_sel_dir = fs_g_nav_entry.u32_cluster;
      fs_g_nav.u16_pos_sel_file = navauto_cache[i_navauto_cache].u16_pos_file;
      fs_g_nav_fast.u16_entry_pos_sel_file = navauto_cache[i_navauto_cache].u16_entry_pos_file;

      fat_read_dir();
      fat_get_entry_info();

      i_navauto_cache--;
      b_updir_ok = true;
    }
  }
#else
  if (nav_dir_gotoparent())
    b_updir_ok = true;
#endif

  if (b_updir_ok)
  {
    // Set folder change bit
    bitfield_status.folder_change = 1;

    g_navauto_u16_dir_level--;
    return NAVAUTO_MOV_EXPLORER_RECURSIVE;
  }
  else // If it fails, means the pointer is on the root
    return NAVAUTO_MOV_EXPLORER_ERROR;
}