?? fatmisc.c
字號:
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// FAT32 File IO Library Linux Test Version
// V1.0L
// Rob Riglar
// Copyright 2003,2004
//
// Email: admin@robs-projects.com
//
// Compiled and tested on Redhat 'Shrike' with GNU gcc
//-----------------------------------------------------------------------------
//
// This file is part of FAT32 File IO Library.
//
// FAT32 File IO Library is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// FAT32 File IO Library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with FAT32 File IO Library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "../IDE/IDE_Access.h"
#include "../FAT/FAT32_Definitions.h"
#include "../FAT/FAT32_Base.h"
#include "fatmisc.h"
//-----------------------------------------------------------------------------
// FATMisc_cacheLFN - Function extracts long file name text from sector
// at a specific offset
//-----------------------------------------------------------------------------
void FATMisc_cacheLFN(word recordoffset)
{
byte 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, byte 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 + -