⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 iso9660.c

📁 基于UCOS-II制作的MP3
💻 C
📖 第 1 页 / 共 3 页
字号:



/*F**************************************************************************
* NAME: iso_goto_next
*----------------------------------------------------------------------------
* PARAMS:
*
* return:
*   - OK: next file available
*   - KO: last file reached
*   - KO: low_level memory error
*----------------------------------------------------------------------------
* PURPOSE:
*   Fetch the next dir/file info in cache
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*----------------------------------------------------------------------------
* REQUIREMENTS:
*****************************************************************************/ 
bit iso_goto_next(void)
{
  if (iso_file_index < (iso_file_max_index - 1))
  {
    iso_file_index++;
    iso_dseek(iso_current_dir_file[iso_file_index]);
    iso_fetch_directory_info(&iso_file_cache.info);
    return OK;
  }
  return KO;
}

/*F**************************************************************************
* NAME: iso_goto_prev
*----------------------------------------------------------------------------
* PARAMS:
*
* return:
*   - OK: previous file available
*   - KO: first file reached
*   - KO: low_level memory error
*----------------------------------------------------------------------------
* PURPOSE:
*   Fetch the previous directory info in cache
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*----------------------------------------------------------------------------
* REQUIREMENTS:
*****************************************************************************/ 
bit iso_goto_prev(void)
{
  if (iso_file_index != 2)            /* first file of the directory? */
  {
    iso_dseek((Int16) (-iso_current_dir_file[iso_file_index]));
    iso_file_index--;
    iso_fetch_directory_info(&iso_file_cache.info);
    return OK;
  }
  else
    return KO;  
}



/*F**************************************************************************
* NAME: iso_goto_parent_dir
*----------------------------------------------------------------------------
* PARAMS:
*
* return:
*   - OK: there is a selected file in the parent dir
*   - KO: there is not a selected file in the parent dir
*----------------------------------------------------------------------------
* PURPOSE:
*   go to the parent directory (equivalent to a cd ..)
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*----------------------------------------------------------------------------
* REQUIREMENTS:
*****************************************************************************/ 
bit iso_goto_parent_dir(void)
{
  iso_dir_current_sect = iso_file_cache.parent.extend_location;
  iso_dir_size = iso_file_cache.parent.extend_size / iso_header.logical_block_size;

  iso_dir_start_sect = iso_dir_current_sect;
  iso_dir_byte_count = 0;
  Hard_iso_read_open(iso_dir_current_sect);
  iso_get_file_dir();

  iso_dir_current_sect = iso_dir_start_sect;
  iso_dir_byte_count = 0;
  Hard_iso_read_open(iso_dir_current_sect);
  iso_dseek(iso_current_dir_file[0]);
  iso_fetch_directory_info(&iso_file_cache.parent);         /* the . dir */

  iso_dseek(iso_current_dir_file[1]);
  iso_fetch_directory_info(&iso_file_cache.parent);         /* the .. dir */

  iso_file_index = 1;

  return iso_goto_next();
}



/*F**************************************************************************
* NAME: iso_get_name
*----------------------------------------------------------------------------
* PARAMS:
*
* return:
*----------------------------------------------------------------------------
* PURPOSE:
*   Return the address of the file name string
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*----------------------------------------------------------------------------
* REQUIREMENTS:
*****************************************************************************/
char pdata * iso_get_name(void)
{
  return (lfn_name);
}


/*F**************************************************************************
* NAME: iso_check_ext
*----------------------------------------------------------------------------
* PARAMS:
*
* return:
*----------------------------------------------------------------------------
* PURPOSE:
*   Return the type of the file
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*----------------------------------------------------------------------------
* REQUIREMENTS:
*****************************************************************************/
Byte iso_check_ext(void)
{
 if ((iso_file_cache.info.attributes & ATTR_ISO_DIR) == ATTR_ISO_DIR)
  {
    return FILE_DIR;
  }
  else
  {
    if ( (ext[0] == 'M')
        && (ext[1] == 'P')
        && (ext[2] == '3'))
    {
      return FILE_MP3;
    }
    else
    if ((ext[0] == 'W')
        && (ext[1] == 'A')
        && (ext[2] == 'V'))
    {
      return FILE_WAV;
    }
    else
    if ((ext[0] == 'S')
        && (ext[1] == 'Y')
        && (ext[2] == 'S'))
    {
      return FILE_SYS;
    }
    else
    {
      return FILE_XXX;
    }
  }
}

/*F**************************************************************************
* NAME: iso_fopen
*----------------------------------------------------------------------------
* PARAMS:
*  
* return:
*   - OK: file opened
*   - KO: file not opened: low level read error
*                          
*----------------------------------------------------------------------------
* PURPOSE:
*   Open the file in read or write mode
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*----------------------------------------------------------------------------
* REQUIREMENTS:
*****************************************************************************/
bit iso_fopen(void)
{
  iso_f_current_sect = iso_file_cache.info.extend_location;
  iso_current_byte_counter = 0;
  iso_f_max_sector = (Uint16 )((iso_file_cache.info.extend_size / 2048) + 1);
  iso_f_nb_sector = 0;
  return (Hard_iso_read_open(iso_f_current_sect));
}


/*F**************************************************************************
* NAME: iso_fgetc
*----------------------------------------------------------------------------
* PARAMS:
*
* return:
*   byte read
*----------------------------------------------------------------------------
* PURPOSE:
*   Read one byte from file
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*   As this function is called very often it must be short and optimized
*   in execution time
*----------------------------------------------------------------------------
* REQUIREMENTS:
*****************************************************************************/
Byte iso_fgetc(void)
{

  if (((Byte*)&iso_current_byte_counter)[0] == 0x08)
  { 
    iso_f_current_sect++;
    iso_f_nb_sector++;
    iso_current_byte_counter = 0;
  }
  iso_current_byte_counter++;
  return Hard_iso_read_byte();
}


/*F**************************************************************************
* NAME: iso_dgetw
*----------------------------------------------------------------------------
* PARAMS:
*
* return:
*   word read
*----------------------------------------------------------------------------
* PURPOSE:
*   Read one word from directory
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*   
*----------------------------------------------------------------------------
* REQUIREMENTS:
*****************************************************************************/
Uint16 iso_dgetw(void)
{
  if (((Byte*)&iso_dir_byte_count)[0] == 0x08)
  {
    iso_dir_current_sect++;
    iso_dir_byte_count = 2;
    Hard_iso_read_open(iso_dir_current_sect);
  }
  else
  {
    iso_dir_byte_count += 2;
  }
  return Hard_iso_read_word();
}



/*F**************************************************************************
* NAME: iso_feof
*----------------------------------------------------------------------------
* PARAMS:
*
* return:
*----------------------------------------------------------------------------
* PURPOSE:
*   Return the file end flag
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*----------------------------------------------------------------------------
* REQUIREMENTS:
*****************************************************************************/
bit iso_feof(void)
{
  if (iso_f_nb_sector > iso_f_max_sector)
  {
    return OK;
  }
  if (iso_f_nb_sector == iso_f_max_sector)
  {
    if (iso_current_byte_counter >= (iso_file_cache.info.extend_size & 0x7FF) )
      return OK;
  }
  return KO;
}


/*F**************************************************************************
* NAME: iso_feob
*----------------------------------------------------------------------------
* PARAMS:
*
* return:
*   - TRUE : B position have been reached
*   - FALSE : B position have not benn reached
*----------------------------------------------------------------------------
* PURPOSE:
*   Determine if B position have been reached in mode repeat A/B
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*----------------------------------------------------------------------------
* REQUIREMENTS:
*****************************************************************************/
bit iso_feob(void)
{
  if (iso_f_nb_sector > iso_f_nb_sector_save)
  {
    return OK;
  }
  if (iso_f_nb_sector == iso_f_nb_sector_save)
    if (iso_current_byte_counter > iso_f_nb_byte_save)
      return OK;

  return KO;
}


/*F**************************************************************************
* NAME: iso_fclose
*----------------------------------------------------------------------------
* PARAMS:
*
* return:
*----------------------------------------------------------------------------
* PURPOSE:
*   Close opened file
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*----------------------------------------------------------------------------
* REQUIREMENTS:
*****************************************************************************/
void iso_fclose(void)
{
  Hard_iso_read_close();
}



/*F**************************************************************************
* NAME: iso_save_file_pos
*----------------------------------------------------------------------------
* PARAMS:
*   
*
* return:
*----------------------------------------------------------------------------
* PURPOSE:
*   Save in locale variables cluster information for the current opened file
*   - cluster index
*   - number of the cluster 
*   - number of bytes in the cluster
*
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*----------------------------------------------------------------------------
* REQUIREMENTS:
*****************************************************************************/
void iso_save_file_pos(void)
{
  iso_f_nb_sector_save = iso_f_nb_sector;
  iso_f_nb_byte_save = iso_current_byte_counter;
}


/*F**************************************************************************
* NAME: iso_file_get_pos
*----------------------------------------------------------------------------
* PARAMS:
*
* return:
*   current file position in bytes
*----------------------------------------------------------------------------
* PURPOSE:
*   Calculate the current file position
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*----------------------------------------------------------------------------
* REQUIREMENTS:
*****************************************************************************/
Uint32 iso_file_get_pos(void)
{
  return ( ((Uint32)(iso_f_nb_sector) * 2048) + (Uint32)(iso_current_byte_counter));
}




⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -