📄 mem-ffs.c
字号:
{
################ = #;
}
//Does the file name match?
### (#### = #; #### < #; ####++)
{
## ((###################[####] != '?') && (*(############## + ####) != ###################[####]))
################ = #;
}
//Does file extension match?
### (#### = #; #### < #; ####++)
{
## ((########################[####] != '?') && (*(################### + ####) != ########################[####]))
################ = #;
}
//Is attribute byte for a file?
## (*############## & ####) //Not valid if the 'volume' bit is set
################ = #;
## (*############## & ####) //Not valid if the 'directory' bit is set
################ = #;
## (*############## & ####) //Not valid if the 'hidden' bit is set
################ = #;
//----- IS THIS THE FILE? -----
## (################)
{
//THIS IS THE FILE
###### = #; //Deselect the card
######(###################);
}
}
}
//*******************************************************************
//*******************************************************************
//********** CONVERT FILE NAME TO 8 CHARACTER DOS FILENAME **********
//*******************************************************************
//*******************************************************************
//Source filename is a case insensitive string with between 1 and 8 filename characters, a period (full stop) character, between 1 and 3 extension characters and a terminating null.
//Returns:
// 1 if the filename contained any wildcard characters, 0 if not (this allow calling functions to detect invalid names if they are creating a new file)
BYTE ffs_convert_filename_to_dos (const char *source_filename, BYTE *dos_filename, BYTE *dos_extension)
{
#### ####;
#### #################;
#### ######################## = #;
#### #####################;
//----- DO THE FILENAME -----
################# = #;
##################### = #;
### (#### = #; #### < #; ####++)
{
//Flag if filename contains a wildcard character (for return)
## ((*############### == '?') || (*############### == '*'))
######################## = #;
//Check for asterix wildcard character
## (*############### == '*')
##################### = #;
//Check for terminating '.'
## (*############### == '.')
################# = #;
//COPY THE CHARACTER
## (#####################)
{
//Doing asterix wildcard replace
*############++ = '?';
## (#################)
*###############++;
}
#### ## (#################)
{
//Copy the character
*############++ = *###############++;
}
####
{
//Pad rest of name with spaces as characters are unused
*############++ = ####; //0x20 is used for unused trailing characters
}
}
//DUMP THE '.'
*###############++;
//----- DO THE EXTENSION -----
################# = #;
##################### = #;
### (#### = #; #### < #; ####++)
{
//Flag if filename contains a wildcard character (for return)
## ((*############### == '?') || (*############### == '*'))
######################## = #;
//Check for asterix wildcard character
## (*############### == '*')
##################### = #;
//Check for terminating null
## (*############### == ####)
################# = #;
//COPY THE CHARACTER
## (#####################)
{
//Doing asterix wildcard replace
*#############++ = '?';
## (#################)
*###############++;
}
#### ## (#################)
{
//Copy the character
*#############++ = *###############++;
}
####
{
//Pad rest of name with spaces as characters are unused
*#############++ = ####; //0x20 is used for unused trailing characters
}
}
//----- CONVERT TO UPPERCASE -----
############ #= #;
############# #= #;
### (#### = #; #### < #; ####++)
{
## ((############[####] >= ####) && (############[####] <= ####))
############[####] #= ####;
}
### (#### = #; #### < #; ####++)
{
## ((#############[####] >= ####) && (#############[####] <= ####))
#############[####] #= ####;
}
######(########################);
}
//***********************************************
//***********************************************
//********** READ NEXT DIRECTORY ENTRY **********
//***********************************************
//***********************************************
//file_name
// 8 character array filename will be written to here
//file_extension
// 3 character array filename extension will be written to here
//attribute_byte
// file attribute byte will be written to here
//file_size
// file size will be written to here
//cluster_number
// start cluster for the file will be written to here
//start_from_beginning
// set to cause routine to start from 1st directory entry (must be set if the drivers data buffer has been modified since the last call)
//directory_entry_sector
// Sector that contains the files directory entry will be written to here
//directory_entry_within_sector
// The file directory entry number within the sector that contains the file will be written to here
//Returns
// 1 = file entry found
// 0 = not found = end of directory
BYTE ffs_read_next_directory_entry (BYTE *file_name, BYTE *file_extension, BYTE *attribute_byte,
##### *#########, ##### *##############, #### ####################,
##### *######################, #### *#############################)
{
#### ######;
#### ######;
##### #######;
#### *##############;
###### #### ############################;
###### ##### ###############;
//----- START FROM BEGINNING OF DIRECTORY? -----
## (####################)
{
## (##############)
{
//----- FAT32 -----
############################# = (###################### + ((################################### # #) * ###################) # #); //(For FAT32 it contains the start cluster)
############### = ###################################;
############################ = ###################;
}
####
{
//----- FAT16 -----
############################# = (################################### # #); //(For FAT16 it contains the start sector)
############################ = ################################;
}
############################### = ######; //Cause the next cluster to be read
}
//----- LOAD A NEW SECTOR OF THE DIRECTORY? -----
## (############################### >= ((#################### # ##) >> #)) // /32 as each directory entry is 32 bytes
{
#############################++; //Move to next sector
//----- CHECK FOR MOVE TO NEXT CLUSTER -----
## (############################ == #)
{
//----- NEED TO MOVE TO NEXT CLUSTER -----
## (##############)
{
//----- FAT32 -----
//Move to next cluster that contains the next part of the directory
############################ = ################### # #;
####### = #######################(###############);
## ((####### & ##########) >= ##########)
{
//DIRECTORY HAS NO MORE CLUSTERS - ADD A NEW CLUSTER
####### = #########################();
## (####### == ##########)
{
//No more space to extend the directory
###### = #; //Deselect the card
###### (#);
}
###############################(###############, #######);
###############################(#######, ##########);
############### = #######;
//SET THE CONTENTS OF THE NEW CLUSTER TO 0x00 = all entries unused
############## = &##############################[#];
### (###### = #; ###### < ###; ######++)
*##############++ = ####;
### (###### = #; ###### < ###################; ######++)
{
############################(
###################### + ((############### # #) * ###################) + ###### //(Data on a Partition starts with cluster number 2)
);
}
}
####
{
############### = #######;
}
//Set the address of the next sector we're going to read
############################# = ###################### + ((############### # #) * ###################);
}
####
{
//----- FAT16 -----
//We've reached the end of the root directory
###### = #; //Deselect the card
###### (#);
}
}
####
{
//----- GET NEXT SECTOR OF THIS CLUSTER -----
##############################;
}
//Read the next sector to our buffer
######################### (#############################);
############################### = ######;
}
//----- GET THE NEXT DIRECTORY ENTRY FROM THE BUFFER -----
###############################++;
//Offset to the start of the entry
############## = &##############################[#] + (############################### << #);
//GET FILE NAME [8]
#########[#] = *##############++;
#########[#] = *##############++;
#########[#] = *##############++;
#########[#] = *##############++;
#########[#] = *##############++;
#########[#] = *##############++;
#########[#] = *##############++;
#########[#] = *##############++;
//Convert to uppercase
### (###### = #; ###### < #; ######++)
{
## ((#########[######] >= ####) && (#########[######] <= ####))
#########[######] #= ####;
}
//GET FILENAME EXTENSION [3]
##############[#] = *##############++;
##############[#] = *##############++;
##############[#] = *##############++;
//Convert to uppercase
### (###### = #; ###### < #; ######++)
{
## ((##############[######] >= ####) && (##############[######] <= ####))
##############[######] #= ####;
}
//GET ATTRIBUTE BYTE [1]
//Bit 7-6 5 4 3 2 1 0
// Reserved, set to 0 | Archive | Directory | Volume Label | System | Hidden | Read Only
*############## = *##############++;
//GET NT [1]
//(Dump)
##############++;
//GET CREATED TIME (mS portion) [1]
//(Dump)
##############++;
//GET CREATED TIME (h + m) [2]
//(Dump)
##############++;
##############++;
//GET CREATED DATE [2]
//(Dump)
##############++;
##############++;
//GET LAST ACESSED DATE [2]
//(Dump)
##############++;
##############++;
//GET EXTENDED ATTRIBUTE [2]
//0x0000 for FAT16, high word of cluster number for FAT32
## (##############)
{
*############## = ((#####)*##############++ << ##);
*############## += ((#####)*##############++ << ##);
}
####
{
##############++;
##############++;
*############## = #;
}
//GET TIME [2]
//(Dump)
##############++;
##############++;
//GET DATE [2]
//(Dump)
##############++;
##############++;
//GET CLUSTER [2]
*############## += (#####)*##############++;
*############## += ((#####)*##############++ << #);
//GET FILE SIZE [4]
*######### = (#####)*##############++;
*######### += ((#####)*##############++ << #);
*######### += ((#####)*##############++ << ##);
*######### += ((#####)*##############++ << ##);
//Return the location of this directory entry
*###################### = #############################;
*############################# = ###############################;
###### = #; //Deselect the card
######(#);
}
//********************************************************
//********************************************************
//********** OVERWRITE LAST DIRECTORY FILE NAME **********
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -