📄 iso9660.c
字号:
}
while ((tmp_word == 0) && (!no_more_entry));
if (!no_more_entry)
{
/* Byte 1 : length of directory record */
/* Byte 2 : Extended attibute record length */
entry_len = tmp_word & 0xFF;
byte_to_read = entry_len;
/* Byte 3 - 10 : location of extent : Logical Block Number of the first Logical Block affected to the file */
iso_dgetw(); /* Byte 3 - 4 */
iso_dgetw(); /* Byte 5 - 6 */
iso_dgetw(); /* Byte 7 - 8 */
iso_dgetw(); /* Byte 9 - 10 */
/* Byte 11 - 18 : Data Length : Length of the file section in bytes */
iso_dgetw(); /* Byte 11 - 12 */
iso_dgetw(); /* Byte 13 - 14 */
iso_dgetw(); /* Byte 15 - 16 */
iso_dgetw(); /* Byte 17 - 18 */
/* Byte 19 - 25 : Recording Time and Date */
iso_dgetw(); /* Byte 19 - 20 */
iso_dgetw(); /* Byte 21 - 22 */
iso_dgetw(); /* Byte 23 - 24 */
/* Byte 26 : File flags :
bit 0 : Hidden file
bit 1 : Directory entry
bit 2 : Associated file
bit 3 : extend attribute
bit 4 : extend attribute
bit 5 : reserved
bit 6 : reserved
bit 7 : file has more than one directory record
*/
attributes = (Byte) (iso_dgetw() >> 8); /* Byte 25 - 26 */
/* Byte 27 : File Unit Size */
/* Byte 28 : Interleave Gap */
iso_dgetw(); /* Byte 27 - 28 */
/* Byte 29 - 32 : Volume Sequence Number*/
iso_dgetw(); /* Byte 29 - 30 */
iso_dgetw(); /* Byte 31 - 32 */
/* Byte 33 : Length of File Identifier (LEN_FI) in byte */
tmp_word = iso_dgetw(); /* Byte 33 - 34 */
len = tmp_word & 0xFF;
byte_to_read -= 34;
byte_to_read >>= 1;
if (iso_cd == 0)
len = len >> 1;
end_of_name = FALSE;
for (i = 0; i < byte_to_read; i++)
{
if (iso_cd)
{
if ( (i & 0x01) == 1) /* iso data extraction */
{
tmp_word = iso_dgetw();
tmp_byte = ((Byte*)&tmp_word)[1];
}
else
{
tmp_byte = ((Byte*)&tmp_word)[0];
}
}
else
{
tmp_byte = iso_dgetw() & 0xFF; /* joliet data extraction */
}
switch (tmp_byte)
{
case 0x2E: /* SEPARATOR 1 */
j = 0;
break;
case 0x00:
case 0x3B: /* SEPARATOR 2 */
end_of_name = TRUE;
k = i;
break;
default:
{
if (j < 3)
{
if ((tmp_byte <= 'z') && (tmp_byte >= 'a'))
{
tmp_byte = tmp_byte - ('a' - 'A');
}
ext[j] = tmp_byte;
j++;
}
break;
}
}
}
iso_file_cache.info.attributes = attributes;
padding_byte--;
if ((iso_check_ext() & current_ext) == FILE_XXX)
{
entry_rel += (entry_len + padding_byte);
}
else
{
iso_current_dir_file[fat_dir_list_index] = entry_rel + (padding_byte << 1);
fat_dir_list_index++;
entry_rel = entry_len;
}
}
}
while (no_more_entry == FALSE);
iso_file_max_index = fat_dir_list_index;
}
/*F**************************************************************************
* NAME: iso_fetch_directory_info
*----------------------------------------------------------------------------
* PARAMS:
* entry: directory entry structure
*
* return:
*----------------------------------------------------------------------------
* PURPOSE:
* Get information about a directory or file entry
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*
*----------------------------------------------------------------------------
* REQUIREMENTS:
*****************************************************************************/
void iso_fetch_directory_info (iso_file *entry)
{
Byte i;
Byte len;
Byte j;
Byte k;
Byte tmp_byte;
bdata bit flag;
Uint16 tmp_word;
Uint16 entry_len;
bdata bit end_of_name;
tmp_word = Hard_iso_read_word();
/* Byte 1 : length of directory record */
/* Byte 2 : Extended attibute record length */
entry->entry_len = tmp_word & 0xFF;
entry_len = entry->entry_len;
/* Byte 3 - 10 : location of extent : Logical Block Number of the first */
/* Logical Block affected to the file */
entry->extend_location = Hard_iso_read_word();
entry->extend_location += (Uint32) ((Uint32)(Hard_iso_read_word()) << 16);
Hard_iso_read_word();
Hard_iso_read_word();
/* Byte 11 - 18 : Data Length : Length of the file section in bytes */
entry->extend_size = Hard_iso_read_word();
entry->extend_size += ((Uint32) (Hard_iso_read_word())) << 16;
Hard_iso_read_word();
Hard_iso_read_word();
/* Byte 19 - 25 : Recording Time and Date */
Hard_iso_read_word();
Hard_iso_read_word();
Hard_iso_read_word();
/* Byte 26 : File flags :
bit 0 : Hidden file
bit 1 : Directory entry
bit 2 : Associated file
bit 3 : extend attribute
bit 4 : extend attribute
bit 5 : reserved
bit 6 : reserved
bit 7 : file has more than one directory record
*/
entry->attributes = (Byte) (Hard_iso_read_word() >> 8);
/* Byte 27 : File Unit Size */
/* Byte 28 : Interleave Gap */
Hard_iso_read_word();
/* Byte 29 - 32 : Volume Sequence Number*/
Hard_iso_read_word();
Hard_iso_read_word();
/* Byte 33 : Length of File Identifier (LEN_FI) in byte */
tmp_word = Hard_iso_read_word();
len = tmp_word & 0xFF;
/* clear the name buffer */
for (i = 0; i < MAX_FILENAME_LEN; i++)
lfn_name[i] = 0;
flag = 0;
end_of_name = FALSE;
if (iso_cd == 0)
len = len >> 1;
for (i = 0; i < len; i++)
{
if (iso_cd)
{
if ( (i & 0x01) == 1) /* iso data extraction */
{
tmp_word = Hard_iso_read_word();
tmp_byte = ((Byte*)&tmp_word)[1];
}
else
{
tmp_byte = ((Byte*)&tmp_word)[0];
}
}
else
{
tmp_byte = Hard_iso_read_word() & 0xFF; /* joliet data extraction */
}
switch (tmp_byte)
{
case 0x2E: /* SEPARATOR 1 */
j = i + 1;
lfn_name[i] = tmp_byte;
break;
case 0x00:
case 0x3B: /* SEPARATOR 2 */
end_of_name = TRUE;
k = i;
break;
default:
{
if (!end_of_name)
lfn_name[i] = tmp_byte;
break;
}
}
}
/* extension : last time we found 0x2E : j position */
if (end_of_name) i = k;
if (len < 14)
{
for (; i < 14; i++)
{
lfn_name[i] = ' '; /* append spaces for display reason */
}
}
else
{
lfn_name[i++] = ' ';
lfn_name[i++] = ' ';
lfn_name[i++] = lfn_name[0];
lfn_name[i++] = lfn_name[1];
lfn_name[i++] = lfn_name[2];
lfn_name[i++] = lfn_name[3];
lfn_name[i++] = lfn_name[4];
lfn_name[i++] = lfn_name[5];
lfn_name[i++] = lfn_name[6];
lfn_name[i++] = lfn_name[7];
lfn_name[i++] = lfn_name[8];
lfn_name[i++] = lfn_name[9];
lfn_name[i++] = lfn_name[10];
lfn_name[i++] = lfn_name[11];
lfn_name[i++] = lfn_name[12];
}
lfn_name[i] = '\0';
for (i = 0; i < 3; i++)
{
if (j + i <= len)
{
tmp_byte = lfn_name[i + j];
if ((tmp_byte <= 'z') && (tmp_byte >= 'a'))
{
tmp_byte = tmp_byte - ('a' - 'A');
}
ext[i] = tmp_byte;
}
}
Hard_iso_read_close();
}
/*F**************************************************************************
* NAME: iso_get_directory
*----------------------------------------------------------------------------
* PARAMS:
* id: file extension to select
* root : root directory or sub-directory
* return:
* - OK: file available
* - KO: no requested file found
* - KO: low_level memory error
*----------------------------------------------------------------------------
* PURPOSE:
* Select first available file/dir in any diretory
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
* Fill all the cache information for the first time
*----------------------------------------------------------------------------
* REQUIREMENTS:
*****************************************************************************/
bit iso_get_directory(Byte id, bit root)
{
current_ext = id;
if (root == TRUE)
{
iso_dir_current_sect = iso_header.root.extend_location;
iso_dir_size = iso_header.root.data_length / iso_header.logical_block_size;
}
else
{
if ((iso_file_cache.info.attributes & ATTR_ISO_DIR) == ATTR_ISO_DIR)
{
iso_dir_current_sect = iso_file_cache.info.extend_location;
iso_dir_size = iso_file_cache.info.extend_size / iso_header.logical_block_size;
}
else
{
return KO;
}
}
iso_dir_start_sect = iso_dir_current_sect;
iso_dir_byte_count = 0;
Hard_iso_read_close();
Hard_iso_read_open(iso_dir_current_sect);
iso_get_file_dir();
Hard_iso_read_close();
if (iso_file_max_index == 0)
{
iso_goto_parent_dir();
return KO;
}
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_goto_first
*----------------------------------------------------------------------------
* PARAMS:
*
* return:
* - OK: first file found
* - KO: low level error
*----------------------------------------------------------------------------
* PURPOSE:
* Fetch the first directory info in cache
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*----------------------------------------------------------------------------
* REQUIREMENTS:
*****************************************************************************/
bit iso_goto_first(void)
{
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_goto_last
*----------------------------------------------------------------------------
* PARAMS:
*
* return:
* OK: last file available
* KO: low level error
*----------------------------------------------------------------------------
* PURPOSE:
* Fetch the last directory info in cache
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*----------------------------------------------------------------------------
* REQUIREMENTS:
*****************************************************************************/
bit iso_goto_last (void)
{
Uint16 gl_offset;
Uint16 i;
for (i = iso_file_index + 1, gl_offset = 0; i < fat_dir_list_last; iso_file_index++, i++)
gl_offset += iso_current_dir_file[i];
if (iso_dseek(gl_offset) == OK)
iso_fetch_directory_info(&iso_file_cache.info);
return OK;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -