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

📄 filemode_pub.c

📁 dvd里面的一个文件系统的代码
💻 C
📖 第 1 页 / 共 4 页
字号:
#ifdef FILE_MODE_WRITE
#include "user_init.h"
#include "global.h"
#include "kinf.h"
#include "osd.h"
#include "fs96602.h"
#include "fsNAV.h"
#include "cardfs.h"
#include "memmap0.h"
#include "util.h"
#include "playmode.h"

//for USB & CARD information
UINT32 uiUsedCapacity;
UINT32 uiRemainCapacity;
UINT32 uiTotalCapacity;
extern UINT8  MaxLUN;
extern UINT32 zeroFAT_cnt;
BYTE   copy_dir_or_file;//copy dir or file,COPY_DIR or COPY_FILE
UINT64  current_dir_size;//selected dir size,in sector,added by wangwei,2005-1-21 10:50
UINT64  dir_copied_size;//copied size of current dir.

//functions
extern UINT32 UsbTestReady(void);
extern int FSSearchFile(UINT32, char*);
extern int DetectUdiskIsProtect(void);

CARD_INFO  *cardDes;
extern CARD_INFO       cardP;
extern CARD_FILE       cardFile;

#ifndef DVDRELEASE
#define FILE_MODE_WRITE_DBG  1
#endif

#define	D	printf("INFO: __%d__(%s:%s)\n",__LINE__,__FILE__,__FUNCTION__);

#ifndef FILE_MODE_WRITE_DBG
    #undef printf
    #undef print_block
    #define printf(f, a...) do {} while (0)
    #define print_block(x,y) do {} while (0)
#endif

/****************************************************************************************\
 *                                                                                       *
 *  Function Name : AddDesFileStru                                                       *
 *                                                                                       *
 *  Purposes      : add the copied file struction                                        *
 *                                                                                       *
 *  Descriptions  :                                                                      *
 *                                                                                       *
 *  Arguments     : (none)                                                               *
 *                                                                                       *
 *  Returns       : (none)                                                               *
 *                                                                                       *
 *  See also      :                                                                      *
 *                                                                                       *
\****************************************************************************************/
void AddDesFileStru(UINT32 lba, UINT16 iParentDir, UINT16 iSrcFileIndex)
{
    printf("=================AddDesFileStru======================\n");     
    int i,file_type;
    char name[12];
    char *pFileName;
    UINT16 file_index;
    UINT32 file_size;
    
    //switch to src pFsJpeg,fs9660dir and fs9660file buf         
    Switch2SrcDesBuf(SRCE);
    
    pFileName = FS_GetFileProperty(iSrcFileIndex,FILE_PROPERTY_NAME);
    for(i=0;i<12;i++)
        name[i]=pFileName[i];
    file_type = FS_GetFileProperty(iSrcFileIndex,FILE_PROPERTY_FILE_TYPE);
    //file_type = iso9660_file[iSrcFileIndex].file_type;
    file_size = FS_GetFileProperty(iSrcFileIndex,FILE_PROPERTY_SIZE);
    //file_size = iso9660_file[iSrcFileIndex].size;
    
    //switch to des pFsJpeg,fs9660dir and fs9660file buf      
    Switch2SrcDesBuf(DEST);
    
    printf("======pFsJpeg->iso9660_file_cnt=%d=========\n",pFsJpeg->iso9660_file_cnt);
    printf("======DirFileCount2[0]=%d=========\n",DirFileCount2[0]);
    printf("======DirFileCount2[1]=%d=========\n",DirFileCount2[1]);
    printf("======pFsJpeg->file_count_in_dir=%d=========\n",pFsJpeg->file_count_in_dir);
   
    if(pFsJpeg->iso9660_file_cnt==0)
    {
        file_index = 0;
    }   
    else
    {
        printf("====i:%d==DirFileCount2[pFsJpeg->file_count_in_dir-1]===%d======\n",pFsJpeg->file_count_in_dir-1,DirFileCount2[pFsJpeg->file_count_in_dir-1]);
        file_index = DirFileCount2[pFsJpeg->file_count_in_dir-1]+1;
        if(file_index>ISO_FILE_MAX)
        {
            file_index-=ISO_FILE_MAX;
        } 
        printf("======file_index===%d======\n",file_index);    
    }
    pFsJpeg->iso9660_file_cnt++;
    
    for(i= pFsJpeg->iso9660_file_cnt-1;i>file_index;i--)
        memcpy(FS_GetFilePropertyEntry(i),FS_GetFilePropertyEntry(i-1),sizeof(DIR_REC))
        //iso9660_file[i]=iso9660_file[i-1];
        
        
    pFsJpeg->file_count_in_dir++;
    DirFileCount2[pFsJpeg->file_count_in_dir-1]=file_index;
    
    iso9660_file[file_index].loc = lba;            
    iso9660_file[file_index].dir = 0;
    iso9660_file[file_index].parent_dir = iParentDir;
    iso9660_file[file_index].size = file_size;
    pFileName = FS_GetFileProperty(file_index, FILE_PROPERTY_NAME);
    for(i=0;i<12;i++)
        pFileName[i] = name[i];
    iso9660_file[file_index].file_type = file_type;
}
/****************************************************************************************\
 *                                                                                       *
 *  Function Name : AddDesDirStru                                                        *
 *                                                                                       *
 *  Purposes      : Add des dir structure                                                *
 *                                                                                       *
 *  Descriptions  :                                                                      *
 *                                                                                       *
 *  Arguments     : (none)                                                               *
 *                                                                                       *
 *  Returns       : (none)                                                               *
 *                                                                                       *
 *  See also      :                                                                      *
 *                                                                                       *
\****************************************************************************************/
UINT16 AddDesDirStru(UINT32 lba, UINT16 iParentDir, char name[12])
{
    printf("=================AddDesDirStru======================\n");     
    UINT16 dir;
    int i;
    //switch to des pFsJpeg,fs9660dir and fs9660file buf      
    Switch2SrcDesBuf(DEST);
        
    pFsJpeg->iso9660_dir_cnt++;
    iso9660_dir[pFsJpeg->iso9660_dir_cnt-1].loc = lba;
    iso9660_dir[pFsJpeg->iso9660_dir_cnt-1].dir = 0;
    iso9660_dir[pFsJpeg->iso9660_dir_cnt-1].parent_dir = iParentDir;
    
    for(i=0;i<12;i++)
        iso9660_dir[pFsJpeg->iso9660_dir_cnt-1].name[i] = name[i];
    
    dir = pFsJpeg->iso9660_dir_cnt-1;
    return dir;
}
/****************************************************************************************\
 *                                                                                       *
 *  Function Name : SrcCopyFile2Des                                                      *
 *                                                                                       *
 *  Purposes      : Copy file from source media to destination media.                    *
 *                                                                                       *
 *  Descriptions  :                                                                      *
 *                                                                                       *
 *  Arguments     : (none)                                                               *
 *                                                                                       *
 *  Returns       : (none)                                                               *
 *                                                                                       *
 *  See also      :                                                                      *
 *                                                                                       *
\****************************************************************************************/
extern char    OriFileName[200][12];
void SrcCopyFile2Des(UINT16 iSrcFileIndex, UINT16 iDesDirIndex)
{
    UINT32	lba;
    UINT32 filelen,fileloc;
    char *filename;
    //int i;
    
    //get the location and length of selected file from src
    fileloc  = FS_GetFileProperty(iSrcFileIndex, FILE_PROPERTY_LOCATION);
    //fileloc = iso9660_file[ iSrcFileIndex ].loc;
    filelen  = FS_GetFileProperty(iSrcFileIndex, FILE_PROPERTY_SIZE);
    //filelen = iso9660_file[ iSrcFileIndex ].size;
    filename = FS_GetFileProperty(iSrcFileIndex, FILE_PROPERTY_NAME);
    //filename = iso9660_file[ iSrcFileIndex ].name;
    
    //init current file (des)information 
    cardFile.stLBA = msf2l(fileloc);
    cardFile.stClus = FSLBA2Clus(cardFile.stLBA);
    cardFile.iFileSize = filelen;
    cardFile.curLBA = cardFile.stLBA;
    cardFile.curClus = cardFile.stClus;
    cardFile.iLeaveSize = cardFile.iFileSize;
    #if 0
    printf("Copy file from Src to Des:\n");
    printf("---------the file location in Src is 0x%x\n",cardFile.stLBA);
    printf("---------the file size in Src is 0x%x\n",filelen);
    #endif
    
    //switch to des pFsJpeg,fs9660dir and fs9660file buf      
    Switch2SrcDesBuf(DEST);
    
    lba=FSGetRoot();
    //*cardDes = cardP;//important!
    
    //if copy to dir in HDD,get the dir's location
    if(iDesDirIndex != 0)
    {
        lba = msf2l(iso9660_dir[iDesDirIndex].loc);
    }

    if(FSSearchFile(lba,filename))
    {        
        ShowWarning("THE DIR IS ALREADY EXISTED.");       
        return;
    }
    else
    {
        if(copy_dir_or_file == COPY_FILE)
        {
            DrawProgressBarInit(); 
        }

    //switch to src pFsJpeg,fs9660dir and fs9660file buf         
    Switch2SrcDesBuf(SRCE);
    //wanghaoying delete the block 2005-7-13 16:25, for no name copied file
    //for(i=0;i<12;i++)
    //{
    //    iso9660_file[iSrcFileIndex].name[i]=OriFileName[iSrcFileIndex+1][i];
    //}
    //printf("===============iso9660_file[iSrcFileIndex].name%s=====================================\n",iso9660_file[iSrcFileIndex].name );
    
    //write file and get the file loc 
    lba = FSCopyFile(lba,FS_GetFilePropertyEntry(iSrcFileIndex));
    //lba = FSCopyFile(lba,&(iso9660_file[iSrcFileIndex]));
    printf("===============lba %d=====================================\n",lba );
  
    AddDesFileStru(l2msf(lba), iDesDirIndex, iSrcFileIndex);
}
}
/****************************************************************************************\
 *                                                                                       *
 *  Function Name : GetParentDir                                                       *
 *                                                                                       *
 *  Purposes      : Get parent dir of sub dir.                                           *
 *                                                                                       *
 *  Descriptions  :                                                                      *
 *                                                                                       *
 *  Arguments     : (none)                                                               *
 *                                                                                       *
 *  Returns       : (none)                                                               *
 *                                                                                       *
 *  See also      :                                                                      *
 *                                                                                       *
\****************************************************************************************/
UINT16 GetParentDir(UINT16 sub_dir)
{
    UINT16 parent_dir;
    parent_dir=iso9660_dir[sub_dir].parent_dir;
    return parent_dir;
}
/****************************************************************************************\
 *                                                                                       *
 *  Function Name : SrcCopyDir2Des                                                       *

⌨️ 快捷键说明

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