void _reentrant ConvName(_packed BYTE *fname, int DeviceNumber)
{
    INT i,byte;
    INT off0 = 0, off1 = 0;
    _memset(namebuffer,0, 86);  // 86*3 = 258
    byte = FSGetByte(fname,0,Y_MEMORY);
    if (byte == 0x2f)
    {
        namebuffer[0] = 0x2f3a00 | DriveLetter[DeviceNumber];
        off0 = 1;
        off1 = 3;
    }
    for (i = 0; i < 253; i++)
    {
        byte = FSGetByte(fname,i+off0,Y_MEMORY);
        PutByte(namebuffer,byte,i+off1,Y_MEMORY);
    }
}
Exemple #2
0
/*----------------------------------------------------------------------------
>  Function Name: RtStatus_t FileRemove(int32_t RecordNumber,int32_t HandleNumber)

   FunctionType:  Reentrant

   Inputs:        1) Record Number
                  2) Handle Number  

   Outputs:       Returns SUCCESS on success else an Error Code 
                   
   Description:   Updates the handle to associate with the file to be deleted and
                  deletes the contents of the file i.e. marks all the clusters occupied by 
	              the file as zero in FAT Table.

<
----------------------------------------------------------------------------*/
RtStatus_t FileRemove(int32_t RecordNumber, int32_t HandleNumber)
{
    RtStatus_t RetValue = SUCCESS;
    uint8_t Buffer[32];
    int32_t ClusterNumber = 0, FileSize;
    HandleTable_t Temp;
    //  int64_t lTemp;

    Temp = Handle[HandleNumber];

    if (Handle[HandleNumber].StartingCluster != 0) {
        if ((RetValue = Fseek(HandleNumber, -DIRRECORDSIZE, SEEK_CUR)))
            return RetValue;
    }

    if (ReadDirectoryRecord(HandleNumber, RecordNumber, Buffer) < 0)
        return ERROR_OS_FILESYSTEM_NO_MATCHING_RECORD;

    if (Handle[HandleNumber].StartingCluster != 0) {
        if ((RetValue = Fseek(HandleNumber, -DIRRECORDSIZE, SEEK_CUR)))
            return RetValue;
    }

    if ((RetValue = DeleteRecord(HandleNumber, RecordNumber)) < 0)
        return RetValue;

    /* Set the Handle to original position */
    if ((RetValue = Fseek(HandleNumber, (RecordNumber * DIRRECORDSIZE), SEEK_SET)) < 0)
        return RetValue;

    FileSize = FSGetDWord(Buffer, DIR_FILESIZEOFFSET);

    // sdk2.6 changed this to left shift instead of right shift. 
    ClusterNumber =
        ((FSGetWord(Buffer, DIR_FSTCLUSLOOFFSET)) | (FSGetWord(Buffer, DIR_FSTCLUSHIOFFSET) << 16));

    if (((FSGetByte(Buffer, DIR_ATTRIBUTEOFFSET)) & DIRECTORY_MODE) == DIRECTORY_MODE)
        FileSize = 0x7fffffff;

    if ((ClusterNumber != 0) && (FileSize) != 0) {
        /* update the handle to associate with the file to be deleted */
        UpdateHandle(HandleNumber, ClusterNumber);

        /* Delete the contents of the file (i.e. Mark all the clusters occupied by 
           the file as zero in FAT Table) */
        if ((RetValue = DeleteContent(HandleNumber, 0)) < 0)
            return RetValue;
    }
    Handle[HandleNumber] = Temp;

    return SUCCESS;
}
Exemple #3
0
/*----------------------------------------------------------------------------
>  Function Name: RtStatus_t DelGetRecordNumber(int32_t HandleNumber,int32_t StartingCluster)

   FunctionType:  Reentrant

   Inputs:        1) Handle Number
                  2) Starting Cluster  

   Outputs:       Updated Record number else an Error 
                   
   Description:   Updates Record Number as per deleted directory record
<
----------------------------------------------------------------------------*/
RtStatus_t DelGetRecordNumber(int32_t HandleNumber, int32_t StartingCluster)
{

    int32_t RecordNumber = 0;
    uint8_t Buffer[32];
    int32_t Byte1, Byte2;
    int32_t ClusterNumber;
    //int64_t lTemp;

    while (1) {
        if (ReadDirectoryRecord(HandleNumber, RecordNumber, Buffer) < 0)
            return ERROR_OS_FILESYSTEM_NO_MATCHING_RECORD;

        if ((Byte1 = FSGetByte(Buffer, 0)) == 0)
            return ERROR_OS_FILESYSTEM_FS_ERROR;

        if (Byte1 == 0x2e) {
            RecordNumber++;
            continue;
        }

        if ((Byte2 = FSGetByte(Buffer, DIR_ATTRIBUTEOFFSET)) == LONGDIRATTRIBUTE) {
            RecordNumber++;
            continue;
        }
        // sdk2.6 changed this from a right shift to a left shift.
        ClusterNumber =
            ((FSGetWord(Buffer, DIR_FSTCLUSLOOFFSET)) |
             (FSGetWord(Buffer, DIR_FSTCLUSHIOFFSET) << 16));

        if ((Byte1 != 0xe5) && ((Byte2 & DIRECTORY) == DIRECTORY)
            && (StartingCluster == ClusterNumber))
            break;

        RecordNumber++;
    }
    return (RtStatus_t) RecordNumber;
}