📄 fatmisc.c
字号:
#include "fat_include.h"
//-----------------------------------------------------------------------------
// FATMisc_cacheLFN - Function extracts long file name text from sector
// at a specific offset
//-----------------------------------------------------------------------------
void FATMisc_cacheLFN(UI16 recordoffset)
{
UI8 LFNIndex, i;
LFNIndex = (IDE_SectorByte(recordoffset)&0x0F);
if (FAT32.no_of_strings==0)
{
FAT32.no_of_strings = LFNIndex;
}
FAT32.String[LFNIndex-1][0] = IDE_SectorByte(recordoffset+1);
FAT32.String[LFNIndex-1][1] = IDE_SectorByte(recordoffset+3);
FAT32.String[LFNIndex-1][2] = IDE_SectorByte(recordoffset+5);
FAT32.String[LFNIndex-1][3] = IDE_SectorByte(recordoffset+7);
FAT32.String[LFNIndex-1][4] = IDE_SectorByte(recordoffset+9);
FAT32.String[LFNIndex-1][5] = IDE_SectorByte(recordoffset+0x0E);
FAT32.String[LFNIndex-1][6] = IDE_SectorByte(recordoffset+0x10);
FAT32.String[LFNIndex-1][7] = IDE_SectorByte(recordoffset+0x12);
FAT32.String[LFNIndex-1][8] = IDE_SectorByte(recordoffset+0x14);
FAT32.String[LFNIndex-1][9] = IDE_SectorByte(recordoffset+0x16);
FAT32.String[LFNIndex-1][10] = IDE_SectorByte(recordoffset+0x18);
FAT32.String[LFNIndex-1][11] = IDE_SectorByte(recordoffset+0x1C);
FAT32.String[LFNIndex-1][12] = IDE_SectorByte(recordoffset+0x1E);
for (i=0; i<13; i++)
if (FAT32.String[LFNIndex-1][i]==0xFF) FAT32.String[LFNIndex-1][i] = 0x20; // Replace with spaces
}
//-----------------------------------------------------------------------------
// FATMisc_If_LFN_TextOnly: If LFN text entry found
//-----------------------------------------------------------------------------
int FATMisc_If_LFN_TextOnly(UI32 recordoffset)
{
if ((IDE_SectorByte(recordoffset+11)&0x0F)==FILE_ATTR_LFN_TEXT) return 1;
else return 0;
}
//-----------------------------------------------------------------------------
// FATMisc_If_LFN_Invalid: If SFN found not relating to LFN
//-----------------------------------------------------------------------------
int FATMisc_If_LFN_Invalid(UI32 recordoffset)
{
if ((IDE_SectorByte(recordoffset)==FILE_HEADER_BLANK)||(IDE_SectorByte(recordoffset)==FILE_HEADER_DELETED)||(IDE_SectorByte(recordoffset+11)==FILE_ATTR_VOLUME_ID)||(IDE_SectorByte(recordoffset+11)&FILE_ATTR_SYSHID))
return 1;
else return 0;
}
//-----------------------------------------------------------------------------
// FATMisc_If_LFN_Exists: If LFN exists and correlation SFN found
//-----------------------------------------------------------------------------
int FATMisc_If_LFN_Exists(UI32 recordoffset, UI8 LFNstrings)
{
if ((IDE_SectorByte(recordoffset+11)!=FILE_ATTR_LFN_TEXT) && (IDE_SectorByte(recordoffset)!=FILE_HEADER_BLANK) && (IDE_SectorByte(recordoffset)!=FILE_HEADER_DELETED) && (IDE_SectorByte(recordoffset+11)!=FILE_ATTR_VOLUME_ID) && (!(IDE_SectorByte(recordoffset+11)&FILE_ATTR_SYSHID)) && (LFNstrings))
return 1;
else
return 0;
}
//-----------------------------------------------------------------------------
// FATMisc_If_noLFN_SFN_Only: If SFN only exists
//-----------------------------------------------------------------------------
int FATMisc_If_noLFN_SFN_Only(UI32 recordoffset)
{
if ((IDE_SectorByte(recordoffset+11)!=FILE_ATTR_LFN_TEXT) && (IDE_SectorByte(recordoffset)!=FILE_HEADER_BLANK) && (IDE_SectorByte(recordoffset)!=FILE_HEADER_DELETED) && (IDE_SectorByte(recordoffset+11)!=FILE_ATTR_VOLUME_ID) && (!(IDE_SectorByte(recordoffset+11)&FILE_ATTR_SYSHID)))
return 1;
else
return 0;
}
//-----------------------------------------------------------------------------
// FATMisc_If_dir_entry: Returns 1 if a directory
//-----------------------------------------------------------------------------
int FATMisc_If_dir_entry(UI32 recordoffset)
{
if ((IDE_SectorByte(recordoffset+11))&FILE_TYPE_DIR) return 1;
else
return 0;
}
//-----------------------------------------------------------------------------
// FATMisc_If_file_entry: Returns 1 is a file entry
//-----------------------------------------------------------------------------
int FATMisc_If_file_entry(UI32 recordoffset)
{
if ((IDE_SectorByte(recordoffset+11))&FILE_TYPE_FILE) return 1;
else
return 0;
}
//-----------------------------------------------------------------------------
// FATMisc_ClusterReassemble: Take the record number and extract the
// start cluster number and reassemble.
//-----------------------------------------------------------------------------
UI32 FATMisc_ClusterReassemble(int recordoffset)
{
UI32 tempbyte_LC_H, tempbyte_LC_L, tempbyte_HC_H, tempbyte_HC_L, filestartcluster;
tempbyte_LC_H = IDE_SectorByte(27+recordoffset);
tempbyte_LC_L = IDE_SectorByte(26+recordoffset);
tempbyte_HC_H = IDE_SectorByte(21+recordoffset);
tempbyte_HC_L = IDE_SectorByte(20+recordoffset);
filestartcluster = (tempbyte_HC_H<<=26) + (tempbyte_HC_L<<=16) + (tempbyte_LC_H<<=8) + tempbyte_LC_L;
return filestartcluster;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -