⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 filemode_pub.c

📁 dvd里面的一个文件系统的代码
💻 C
📖 第 1 页 / 共 4 页
字号:
    uiRemainCapacity = (zeroFAT_cnt * cardP.secPerClus * 512) / 1024000;
    #endif
    
    uiUsedCapacity = uiTotalCapacity - uiRemainCapacity;//in Mega
    
    #ifdef FILE_MODE_WRITE_DBG
    printf("zeroFAT_cnt     =%dCluster\n",zeroFAT_cnt);
    printf("cardP.secPerClus=%dSector/Cluster\n",cardP.secPerClus);
    printf("total capacity  =%dM\n",uiTotalCapacity);
    printf("used capacity   =%dM\n",uiUsedCapacity);
    printf("uiRemainCapacity=%dM\n",uiRemainCapacity);
    #endif
}
/****************************************************************************************\
 *                                                                                       *
 *  Function Name : CreateDir                                                            *
 *                                                                                       *
 *  Purposes      : Create Dir                                                           *
 *                                                                                       *
 *  Descriptions  :                                                                      *
 *                                                                                       *
 *  Arguments     : (none)                                                               *
 *                                                                                       *
 *  Returns       : (none)                                                               *
 *                                                                                       *
 *  See also      :                                                                      *
 *                                                                                       *
\****************************************************************************************/
void CreateDir(void)
{
    printf("==================== CreateDir IN!!!===================^\n");

    UINT32 lba;
    UINT16 des_dir_index;

    //switch to destination related buffer
    Switch2SrcDesBuf(DEST);

    des_dir_index = pFsJpeg->dir_current;
    printf("+++++++++ pFsJpeg->dir_current = %x+++++++++\n",pFsJpeg->dir_current);

    //root dir's lba
    lba = FSGetRoot();

    //selected dir's lba
    if(des_dir_index != 0)// ! root dir
    {
        lba = msf2l(iso9660_dir[des_dir_index].loc);
        printf("+++++++++++++++ iso9660_dir[des_dir_index].name = %s +++++++++++++++++\n",iso9660_dir[des_dir_index].name);
        printf("+++++++++++++++ lba = %x +++++++++++++++++\n",lba);
    }

    printf("+++++++++++++++ created dir name = %s +++++++++++++++++\n",GetString);

    if(FSSearchDir(lba, GetString))//check same name dir
    {
        //ShowWarning("THE DIR IS ALREADY EXISTED.");
        printf("================= THE DIR IS ALREADY EXISTED.===============\n");
        return;
    }
    else//create the new dir
    {
        lba = FSCreateDir(lba, GetString);
        AddDesDirStru(l2msf(lba), des_dir_index, GetString);
        printf("+++++++++++++++ des_dir_index = %x +++++++++++++++++\n",des_dir_index);
    }
}
/****************************************************************************************\
 *                                                                                       *
 *  Function Name : RenameFileDir                                                        *
 *                                                                                       *
 *  Purposes      : Rename file or dir                                                   *
 *                                                                                       *
 *  Descriptions  :                                                                      *
 *                                                                                       *
 *  Arguments     : (none)                                                               *
 *                                                                                       *
 *  Returns       : (none)                                                               *
 *                                                                                       *
 *  See also      :                                                                      *
 *                                                                                       *
\****************************************************************************************/
void RenameFileDir(void)
{
    UINT32 lba;
    UINT16 index, des_dir_index;

    //switch to destination related buffer
    Switch2SrcDesBuf(DEST);

    index = pFsJpeg->file_current_in_page + PER_PAGE*( pFsJpeg->file_page_index);
    index = DirFileCount2[index];

    des_dir_index = pFsJpeg->dir_current;
    
    //root dir's lba
    lba = FSGetRoot();

    //selected dir's lba
    if(des_dir_index != 0)// ! root dir
    {
        lba = msf2l(iso9660_dir[des_dir_index].loc);
    }

    if(index > ISO_FILE_MAX)
    {
        ShowWarning("RENAMING DIR...");
        if(FSSearchDir(lba, GetString))//check same name dir
        {
            ShowWarning("THE DIR IS ALREADY EXISTED.");
            //printf("<<<<<<<<<<<<<<<<<<<<<<<<<<< THE DIR IS ALREADY EXISTED.>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n");
            return;
        }
        else//rename dir
        {
            RenameFile(GetString,&(iso9660_dir[index - ISO_FILE_MAX]));
            strcpy(iso9660_dir[index - ISO_FILE_MAX].name, GetString);
        }
        ShowWarning("DIR IS RENAMED.");
    }
    else if(index < ISO_FILE_MAX)
    {
        ShowWarning("RENAMING FILE...");
        if(FSSearchFile(lba, GetString))//check same name dir
        {
            ShowWarning("THE FILE IS ALREADY EXISTED.");
            //printf("<<<<<<<<<<<<<<<<<<<<<<<<<<< THE FILE IS ALREADY EXISTED.>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n");
            return;
        }
        else//rename file
        {
            RenameFile(GetString,FS_GetFilePropertyEntry(index));
            //RenameFile(GetString,&(iso9660_file[index]));
            strcpy(iso9660_file[index].name, GetString);
        }
        ShowWarning("FILE IS RENAMED.");
    }
    else if(index == ISO_FILE_MAX)
    {
        invalid_key();
        return;   
    }
}
/****************************************************************************************\
 *                                                                                       *
 *  Function Name : RenameFile                                                           *
 *                                                                                       *
 *  Purposes      : Rename file or dir                                                   *
 *                                                                                       *
 *  Descriptions  :                                                                      *
 *                                                                                       *
 *  Arguments     : (none)                                                               *
 *                                                                                       *
 *  Returns       : (none)                                                               *
 *                                                                                       *
 *  See also      :  only for develope use.                                              *
 *                                                                                       *
\****************************************************************************************/
void RenameFile(char *foldername, DIR_REC *OriFileInfo)
{
	BYTE	assignName[12];
	UINT32	lba, fileloc, assignlba, filelba, nextLBA;
	UINT32	index=0;
	UINT32  iRes;
	BYTE	FileName[12];
	BYTE	srcFDB[33];
	UINT32	startClus;
	BYTE 	i;
	BYTE	*dstpwb= (BYTE *)(SDRAM_BASE + (167+1242) * 1024); //pointer address

	printf("foldername = '%s'\n",foldername);//jerry

	fileloc = OriFileInfo->loc;
	assignlba = msf2l(fileloc);
	strcpy(assignName, OriFileInfo->name); //get the user input file name!!!

	lba = msf2l(iso9660_dir[ OriFileInfo->parent_dir ].loc);

	nextLBA = lba;
	do{
		iRes=FSGetFDB(lba, index++, srcFDB);
		iso9660_assign_name(srcFDB, FileName, 8, 0);
		if(cardP.typeFAT==CARD_FAT32){//liweihua 2004-8-4 17:50
		    startClus=(getBiUINT16(srcFDB+26))|(getBiUINT16(srcFDB+20)<<16);
		}
		else
		{
		    startClus=getBiUINT16(srcFDB+26);
		}
		filelba=FSClus2LBA(startClus);

		if((assignlba==filelba) && (strcmp(assignName, FileName)==0)) //add condition
		{
			index=(index-1)%(cardP.bytePerSec/FDBSIZE); 	//get the offset of n-th FDB in LBA
			FSReadSector(nextLBA, 1, dstpwb);
			for(i=0; i<8; i++)//give the assigned name to the current file.
				dstpwb[(index)*FDBSIZE+i]=foldername[i];
			FSWriteSector(nextLBA, 1, dstpwb);
			return ;
		}
		else
		{
			nextLBA=iRes;
		}
	}while(iRes);
}

/****************************************************************************************\
 *                                                                                       *
 *  Function Name : FileModeGetInfo                                                      *
 *                                                                                       *
 *  Purposes      : Get information of Card & Hard Disc                                  *
 *                                                                                       *
 *  Descriptions  :                                                                      *
 *                                                                                       *
 *  Arguments     : (none)                                                               *
 *                                                                                       *
 *  Returns       : (none)                                                               *
 *                                                                                       *
 *  See also      :                                                                      *
 *                                                                                       *
\****************************************************************************************/
void FileModeGetInfo(void)
{
    if(1)//(pFsJpeg->ControlArea == CNT_AREA_DEST)
    {
        FSGetRoot();
    }
}
/****************************************************************************************\
 *                                                                                       *
 *  Function Name : SwitchSrcDesBuffer                                                   *
 *                                                                                       *
 *  Purposes      : Switch to destination's buffer of source's buffer                    *
 *                                                                                       *
 *  Descriptions  :                                                                      *
 *                                                                                       *
 *  Arguments     : SrcOrDes :                                                           *
 *                             SRCE : source                                             *
 *                             DEST : destination                                        *
 *                                                                                       *
 *  Returns       : (none)                                                               *
 *                                                                                       *
 *  See also      :                                                                      *
 *                                                                                       *
\****************************************************************************************/
void Switch2SrcDesBuf(BYTE SrcOrDes)
{
    if(SrcOrDes == SRCE)//switch to source's pFsJpeg,fs9660dir and fs9660file buffer
    {
        pFsJpeg = &(share_data.JPEG);
        _fs9660_buf = iso9660buf_src;
    }
    else if(SrcOrDes == DEST)//switch to destination's pFsJpeg,fs9660dir and fs9660file buffer
    {
        pFsJpeg = pFsJpeg_des_buf;
        _fs9660_buf = iso9660buf_des;   
    }
}
/****************************************************************************************/
#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -