コード例 #1
0
//! This function jumps to the next or previous file in file list corresponding at a play list file
//!
//! @param b_direction  jump direction (FS_FIND_NEXT or FS_FIND_PREV)
//!
//! @return    The status of the action
//!
//! @verbatim
//! This routine is not authorized then a play list file is not opened
//! @endverbatim
//!
Navauto_mov_state   navauto_mov_playlist( bool b_direction )
{
   bool b_endof_loop;
   b_endof_loop = false;
   Navauto_mov_state state;

   state.bitfield.all = 0;
   while( 1 )
   {
      if( NAVAUTO_RAND_ON == g_navauto_rand )
      {
         g_navauto_u16_pos = navauto_rand_choose();
         if( 0 == g_navauto_u16_pos )
         {
            // Loop finish, then reset random and choose other value
            if( b_endof_loop )
            {
               state.status = NAVAUTO_MOV_DISKERROR;
               return state;
            }
            b_endof_loop = true;
            navauto_rand_init();
            g_navauto_u16_pos = navauto_rand_choose();
         }
         pl_nav_setpos( g_navauto_u16_pos );
      }
      else
      {
         g_navauto_u16_pos += (FS_FIND_NEXT==b_direction)? 1 : -1;
         if( !pl_nav_setpos( g_navauto_u16_pos ) )
         {
            // Loop finish or error
            if( b_endof_loop )
            {
               state.status = NAVAUTO_MOV_DISKERROR;
               return state;
            }
            b_endof_loop = true;
            if( FS_FIND_NEXT == b_direction )
            {
               g_navauto_u16_pos = 1-1;                  // end of list then go to the beginning
            }else{
               g_navauto_u16_pos = pl_nav_getnbfile()+1; // beginning of list then go to the end
            }
         }
      }
      if( nav_filelist_validpos() )
         break;
      // Here it is a DEAD path or to large for system memory
   }
   g_navauto_u16_pos = pl_nav_getpos();
   if( b_endof_loop )
   {
      state.status = NAVAUTO_MOV_OK_LOOP;
      return state;
   }
   state.status = NAVAUTO_MOV_OK;
   return state;
}
コード例 #2
0
//! This function jumps to the next or previous file in file list corresponding at a play list file
//!
//! @param b_direction  jump direction (FS_FIND_NEXT or FS_FIND_PREV)
//!
//! @return    The status of the action
//!
//! @verbatim
//! This routine is not authorized then a play list file is not opened
//! @endverbatim
//!
Navauto_mov_state   navauto_mov_playlist( bool b_direction )
{
   bool b_endof_loop;
   b_endof_loop = false;
   Navauto_mov_state state;

   state.bitfield.all = 0;
   while( 1 )
   {
      if( NAVAUTO_RAND_ON == g_navauto_rand )
      {
         g_navauto_u16_pos = navauto_rand_choose(g_navauto_u16_pos, g_navauto_u16_nb);
         pl_nav_setpos( g_navauto_u16_pos + 1 );
      }
      else
      {
         g_navauto_u16_pos += (FS_FIND_NEXT==b_direction)? 1 : -1;
         if( !pl_nav_setpos( g_navauto_u16_pos + 1 ) )
         {
            // Loop finish or error
            if( b_endof_loop )
            {
               state.status = NAVAUTO_MOV_DISKERROR;
               return state;
            }
            b_endof_loop = true;
            if( FS_FIND_NEXT == b_direction )
            {
               g_navauto_u16_pos = (uint16_t) -1;           // end of list then go to the beginning
            }else{
               g_navauto_u16_pos = pl_nav_getnbfile(); // beginning of list then go to the end
            }
            continue;
         }
      }
      if (nav_filelist_validpos() && nav_file_checkext(g_navauto_filter))
         break;
      // Here it is a DEAD path or to large for system memory
   }
   g_navauto_u16_pos = pl_nav_getpos() - 1;
   if( b_endof_loop )
   {
      state.status = NAVAUTO_MOV_OK_LOOP;
      return state;
   }
   state.status = NAVAUTO_MOV_OK;
   return state;
}
コード例 #3
0
ファイル: play_list.c プロジェクト: AndreyMostovov/asf
bool   pl_main_save( void )
{
   _MEM_TYPE_SLOW_ Fs_index index;
   uint8_t nav_id_save;
   uint16_t u16_pos;

   // Check if the play list file is opened and modified
   if( !pl_main_isopen() )
      return false;
   if( !pl_g_list_is_modify )
      return true;
   pl_g_list_is_modify = false;

   // Check if a undo file exists
   if( !pl_g_list_undo )
      return true;

   // Remove original copy of play list file
   nav_id_save = nav_get();
   nav_select( FS_NAV_ID_PLAYLIST );
   u16_pos = pl_g_u16_list_sel;           // Save position in play list
   file_close();                          // Close list
   index = nav_getindex();                // Save the pointer on play list file
   pl_g_list_is_open = false;
   if( nav_gotoindex( &copyfile_index ) ) // Go to the copy of file
      nav_file_del( true );               // Remove the copy
   nav_gotoindex( &index );               // Re select play list file
   pl_main_open( true );                  // Re open play list file
   pl_nav_setpos(u16_pos);                // Restore position in play list
   nav_select( nav_id_save );

   return true;
}
コード例 #4
0
ファイル: play_list.c プロジェクト: AndreyMostovov/asf
//! This function remove the dead file in the list
//!
//! @return    false in case of error, see global value "fs_g_status" for more detail
//! @return    true otherwise
//!
bool pl_rem_dead( void )
{
   uint8_t nav_id_save;

   pl_g_u16_list_sel = 0;

   nav_id_save = nav_get();
   nav_select( FS_NAV_ID_PLAYLIST );

   while( pl_g_u16_list_sel < pl_g_u16_list_size )
   {
      if( nav_gotoindex( &pl_g_list[ pl_g_u16_list_sel ] ))
      {
         // the file is good -> go to next file in list
         pl_g_u16_list_sel++;
         continue;
      }

      // The file is dead -> remove this one
      pl_rem_sel();
   }
   nav_select( nav_id_save );
   pl_nav_setpos(0);
}
コード例 #5
0
//! This function opens a file list at the current position in navigator
//!
//! @param b_playlist   if true then the current selected file is a play list file to open
//!                     else create a file list with files included in a disk part
//! @param pos          If b_playlist true, then position in the play list to start
//!                     else folder level of the current position
//!
//! @return             false, in case of error or file list empty
//!
bool  navauto_open( bool b_playlist , uint16_t pos )
{
   Navauto_mov_state state;

   g_navauto_b_playlist     = b_playlist;
   g_navauto_u16_dir_level_root = 0;
   g_navauto_u16_nb = 0;

   if( b_playlist )
   {
      g_navauto_u16_pos        = pos;
      if( !pl_main_open(false) )
         return false;
      g_navauto_u16_nb = pl_nav_getnbfile();
      if( 0 == g_navauto_u16_nb )
         return false;
      if( NAVAUTO_RAND_OFF == navauto_getrand() )
      {
         if( pl_nav_setpos( g_navauto_u16_pos ))
         {
            if( nav_filelist_validpos() )
               return true;
         }
      }else{
         navauto_rand_init();
      }
      // Error position then restart at the beginning
      g_navauto_u16_pos = 0;
   }
   else
   {
#if( FS_NAV_AUTOMATIC_NBFILE == ENABLE )
      Fs_index       index;
      Fs_index       index2;
      Navauto_rand   rand_mode;
      uint16_t            u16_current_pos=0;

      index.u8_lun = 0xFF;    // Reset index (by default no valid selected file)
      g_navauto_u16_dir_level  = pos;

      rand_mode = navauto_getrand();               // Save random mode
      navauto_setrand( NAVAUTO_RAND_OFF );

      // If no valid file then found the first valid file
      if( !nav_file_checkext( g_navauto_filter ))
      {
         // Go to previous position because "navauto_mov_explorer()" execute a next before search valid file
         if( !nav_filelist_set( 0 , FS_FIND_PREV ) )
           nav_filelist_reset();
         state = navauto_mov_explorer(FS_FIND_NEXT, NAVAUTO_MOV_OPTS_NONE);
         if((NAVAUTO_MOV_OK_LOOP != state.status)
         && (NAVAUTO_MOV_OK      != state.status) )
         {
           navauto_setrand(rand_mode);
           return false;  // List empty
         }
      }
      index = nav_getindex();

      // Compute the size of file list and search the position of selected file
      navauto_mov_explorer_reset();                // Go to beginning of loop
      // Note: the number of file is updated in navauto_mov_explorer() routine when the end of list is detected

      while( navauto_mov_explorer( FS_FIND_NEXT, NAVAUTO_MOV_OPTS_NONE ).status == NAVAUTO_MOV_OK )
      {
         index2 = nav_getindex();
         // Check the current position with the selected file
         if( (index.u8_lun == index2.u8_lun)
         &&  (index.u32_cluster_sel_dir == index2.u32_cluster_sel_dir)
         &&  (index.u16_entry_pos_sel_file == index2.u16_entry_pos_sel_file) )
         {
            u16_current_pos = g_navauto_u16_pos;   // Save the position number found
            g_navauto_u16_dir_level_root = g_navauto_u16_dir_level;
         }
      }

      navauto_setrand(rand_mode);                  // Restore random mode
      if( 0 == g_navauto_u16_nb )
         return false;  // loop empty

      // Go to a file from file list
      if( NAVAUTO_RAND_OFF == navauto_getrand() )
      {
         if( 0xFF != index.u8_lun )
         {
            // Reselect the file selected at startup
            nav_gotoindex( &index );               // Go to this one
            g_navauto_u16_dir_level  = g_navauto_u16_dir_level_root;        // Update position file
            g_navauto_u16_pos = u16_current_pos;   // Update folder level corresponding at file
         }
         // Else, the first file is already selected at the end of "compute file list size" loop
         return true;
      }else{
         navauto_rand_init();
      }
#else
      Fs_index       index;
      Navauto_rand   rand_mode;

      rand_mode = navauto_getrand();
      navauto_setrand(NAVAUTO_RAND_OFF);

      // If no valid file then find the first valid file
      if( !nav_file_checkext( g_navauto_filter ))
      {
         // Go to previous position because "navauto_mov_explorer()" execute a next before search valid file
         if( !nav_filelist_set( 0 , FS_FIND_PREV ) )
           nav_filelist_reset();
         state = navauto_mov_explorer(FS_FIND_NEXT, NAVAUTO_MOV_OPTS_NONE);
         if((NAVAUTO_MOV_OK_LOOP != state.status)
         && (NAVAUTO_MOV_OK      != state.status) )
         {
           navauto_setrand(rand_mode);
           return false;  // List empty
         }
      }
      index = nav_getindex();

      navauto_setrand(rand_mode);

      navauto_mov_explorer_reset();
      // Compute directory level
      g_navauto_u16_dir_level = 0;
      while(nav_dir_gotoparent())
        g_navauto_u16_dir_level++;
      g_navauto_u16_dir_level_root = g_navauto_u16_dir_level;
      //g_navauto_u16_dir_level  = pos;
      // Restore index
      nav_gotoindex(&index);

      g_navauto_u16_nb = 0xFFFF;

      if( NAVAUTO_RAND_OFF == navauto_getrand() )
        navauto_rand_init();

      if( nav_file_checkext( g_navauto_filter ))
      {
        // Valid file then update position with the first position but it is not the first !
        g_navauto_u16_pos = 1;
        return true;
      }
#endif
   }
   // Find first file or use the random feature
   state = navauto_mov(FS_FIND_NEXT, NAVAUTO_MOV_OPTS_NONE);
   if((NAVAUTO_MOV_OK_LOOP != state.status)
   && (NAVAUTO_MOV_OK      != state.status) )
      return false;  // List empty
   return true;
}
コード例 #6
0
ファイル: play_list.c プロジェクト: AndreyMostovov/asf
//! This function creates a copy of the play list in case of a restore action
//!
//! @return    false in case of error, see global value "fs_g_status" for more detail
//! @return    true otherwise
//!
bool   pl_main_modify( void )
{
   _MEM_TYPE_SLOW_ uint8_t name_copyfile[]="~copy.m3u";
   _MEM_TYPE_SLOW_ Fs_index index;
   uint8_t nav_id_save;
   uint16_t u16_pos;
   uint8_t status;
   bool b_copy_finish = false;

   if( !pl_main_isopen() )
      return false;
   if( pl_g_list_is_modify )
      return true;
   // If an error occurs during copy process then the play list file is set in read only mode
   fs_g_status = FS_ERR_PL_READ_ONLY;
   if( pl_g_list_is_readonly )
      return false;
   if( !pl_g_list_undo )
   {
      pl_g_list_is_modify = true;
      return true;
   }

   // Save information about current play list file
   nav_id_save = nav_get();
   nav_select( FS_NAV_ID_PLAYLIST );
   u16_pos = pl_g_u16_list_sel;           // Save position in play list
   file_close();                          // Close list
   pl_g_list_is_open = false;
   index = nav_getindex();                // Get pointer on play list

   // Copy play list file in a temporary file
#if( (FS_ASCII == true) && (FS_UNICODE == true) )
   nav_string_ascii();                    // copy file name stored in ASCII
#endif
   if( !nav_file_copy())
      goto pl_main_modify_end;
   if( !nav_file_paste_start( name_copyfile ) )
   {
      if( FS_ERR_FILE_EXIST != fs_g_status)
         goto pl_main_modify_end;
      // File exist then delete
      if( !nav_file_del(true) )
         goto pl_main_modify_end;
      // Retry paste
      if( !nav_file_paste_start( name_copyfile ) )
         goto pl_main_modify_end;
   }
   // Run paste
   do{
      status = nav_file_paste_state(false);  // Copy running
   }while( COPY_BUSY == status );
   if( COPY_FINISH != status )
      goto pl_main_modify_end;
   // Save pointer on copy file
   copyfile_index = nav_getindex();
   b_copy_finish = true;

pl_main_modify_end:
   // Restore the play list file
#if( (FS_ASCII == true) && (FS_UNICODE == true) )
   nav_string_unicode();
#endif
   nav_gotoindex( &index );               // Go to original play list file
   pl_main_open( true );                  // Re open play list file
   pl_g_list_is_modify = b_copy_finish;
   nav_select( nav_id_save );
   pl_nav_setpos(u16_pos);                // Restore position in play list
   return pl_g_list_is_modify;
}