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

📄 enhanced_selector_next_for_ape.c

📁 MP3 整个 SDK
💻 C
📖 第 1 页 / 共 2 页
字号:
    char *ext;
    WORD  total;
    BYTE extno;
    long    lEntry;
    lEntry = FS_GetCurDirEntry();    
    extno = fselExtNo;
    fselExtNo = 0;
    total = 0;    
    do {
#ifdef __APE_SUPPORT
        if( !memcmp(ext = GetExtBuf(), APEExt2,3))
        {
            total += GetFileTotalCur_Ape();
            goto APE_Exit;
        }
#else
        ext = GetExtBuf();
#endif
        if (FS_Dir(m_szTemp,  ext, FS_DIR_FILE))
        {
            total ++;
            if( bCheckValidDir)
                break;

            while ( FS_Dir(m_szTemp,  ext, FS_DIR_FILE_CONT) &&(total < FSEL_MAX_FILENUM))
            {
                output8(REG4E_RTC_WATCH_DOG, input8(REG4E_RTC_WATCH_DOG) | 0x08);
                total ++;    
            }
        }
APE_Exit:
		;
    }while( (total < FSEL_MAX_FILENUM)&&ToNextExt());

    fselExtNo = extno;

    if(total > FSEL_MAX_FILENUM)
        total = FSEL_MAX_FILENUM;
    FS_SetCurDirEntry(lEntry);
    return total;
}
/********************************************************************************
* Description : Seek to the next file 
*
* Arguments  : 
        strFile:output file name
* Returns     :
            TRUE: Successful
            FALSE: fail.
* Notes       :  目录树查找,先检查父目录再检查子目录(子目录1 -- 子目录99)
*
********************************************************************************/
BOOL SelectNext_8Layer(char *strFile)
{
    //在当前目录向下找文件
    fselError = 0;
    if (fselTotal == 0)
        fselTotal=GetFileTotalCur(FALSE);
    if ( !SelectNext(strFile) )
    {
        //寻找当前目录下的所有目录
CurrentDiragain:
        output8(REG4E_RTC_WATCH_DOG, input8(REG4E_RTC_WATCH_DOG) | 0x08);
        if ( FS_Dir(m_szTemp,  IgnoreExt2, FS_DIR_DIR) )
        {
CurrentDiragainNext:                                                 
            if ( FS_CD(m_szTemp) )
            {
                fselTotal=GetFileTotalCur(FALSE);
                if( fselDirNo[fselDirLayer]!=0 )
                {
                    fselDirLayer++;
                }
                
                if (fselDirLayer > 7 )
                {
                    fselDirLayer--;
                    FS_CD("\\");
                    goto ParentDiragainNext;
                }
                       
                fselFileNo = 0;
                fselExtNo = 0;
#ifdef __APE_SUPPORT
                fselFileNo_APE = 0;
                CurApe_TotalNo = 0;
#endif

                fselDirNo[fselDirLayer] = 1;  //第一个子目录
                   
                // 检查当前目录是否有合适的文件.            
                if ( SelectNext(strFile) )
                {
                    fselError = 0;
                    return TRUE;
                }
                else //子目录下的子目录循环查找
                {
                    goto CurrentDiragain;
                }    
            }
            else    //出错了
            {
                fselInit(fselType, fselMode,0,fselDiskLetter);
                fselError = FSEL_ERR_OUTOF;
                return FALSE;    
            }
        }
        else    //寻找当前目录的下一个目录(平级寻找)
        {
ParentDiragainNext:
            output8(REG4E_RTC_WATCH_DOG, input8(REG4E_RTC_WATCH_DOG) | 0x08);              
            if ( FS_CD("\\"))
            {
                if ( fselDirLayer > 7 )
                {
                    fselInit(fselType, fselMode,0,fselDiskLetter);
                    fselError = FSEL_ERR_OUTOF;     //已经返回到根目录,重新初始化
                    return FALSE;
                }
                //寻找当前目录的下一个目录(平级寻找)
                if ( fselNextDir(m_szTemp) )
                {   // 检查目录下是否有合适的文件.
                    FS_CD(m_szTemp);
                    fselTotal=GetFileTotalCur(FALSE);
                    fselFileNo = 0;
                    fselExtNo = 0;
#ifdef __APE_SUPPORT
                    fselFileNo_APE = 0;
                    CurApe_TotalNo = 0;
#endif
                    if ( SelectNext(strFile) )
                    {
                        fselError = 0;
                        return TRUE;
                    }
                    // 检查子目录.
                    goto CurrentDiragain;
                }
                else    //到上一级目录
                {
                    if(fselDirLayer < 8)
                        fselDirNo[fselDirLayer] = 0;
                    fselDirLayer --;
                    goto ParentDiragainNext;
                }
            }   
            else
            {
                fselInit(fselType, fselMode,0,fselDiskLetter);
                fselError = FSEL_ERR_OUTOF;
                return FALSE;    
            }
        }
    }        
    return TRUE;
}
/********************************************************************************
* Description : Select the next file according to type & mode, then get the name of file.
*
* Arguments  : 
*            strFile:  msdos 8.3  file name of next file
* Returns     :
*            TRUE: Successful
*            FALSE: Fail, detail information in fselError
* Notes       :  None
*
********************************************************************************/

BOOL fselGetNext( char *strFile)
{
    WORD num;

    //weng, use switch...case
    switch(fselMode)
    {
        case FSEL_ALL_REPEATONE:
        { // handle the case of repeat one 
            if((0==fselFileNo)&&(0!=fselTotal))
                fselFileNo = 1;
            return fselGetByNO(strFile, fselFileNo);
        }
        case FSEL_DIR_RANDOM:
        {   // handle the case of random
            num = (Random()%fselTotal)+1;
        
            /*if (num == fselFileNo) 
            {
                if (num == fselTotal )
                    num = 1;
                else
                    num = fselTotal;
            }*/
            return fselGetByNO( strFile, num);
        }
        case FSEL_DIR_SEQUENCE:
        case FSEL_DIR_INTRO:
        { 
            return SelectNext(strFile);
        }
        case FSEL_ALL_SEQUENCE:
        {
            return SelectNext_8Layer(strFile);
        }
        case FSEL_ALL_REPEATALL:
        {
            if (SelectNext_8Layer(strFile))
                return TRUE;
            else
            {
                fselInit(fselType, fselMode,0,fselDiskLetter);
                return SelectNext_8Layer(strFile);
            }
        }
        case FSEL_DIR_REPEATALL:
        {
            if (SelectNext(strFile ))
                return TRUE;
            fselFileNo = 0;
            fselExtNo = 0;
#ifdef __APE_SUPPORT
            fselFileNo_APE = 0;
            CurApe_TotalNo = 0;
#endif
            return SelectNext(strFile);
        }
        default:
            return FALSE;
    }//switch
}
/********************************************************************************
* Description : Select  the file name according to number in current directory
*
* Arguments  : 
*            strFile:  file name
*            Num  : File number in currect directory
* Returns     :
*            TRUE: Successful
*            FALSE: Fail, detail information in fselError.
* Notes       :  None
*
********************************************************************************/
BOOL fselGetByNO( char *strFile, const WORD Num)
{
    if( (Num > fselTotal)||(Num == 0))
    {
        fselError = FSEL_ERR_OUTOF;
        return FALSE;
    }

    fselFileNo = 0;
    fselExtNo = 0;
#ifdef __APE_SUPPORT
    fselFileNo_APE = 0;
    CurApe_TotalNo = 0;
#endif
    while (Num>fselFileNo)
    {
        output8(REG4E_RTC_WATCH_DOG, input8(REG4E_RTC_WATCH_DOG) | 0x08);    
        if(!SelectNext(strFile))
        {
            return FALSE;
        }
    }
    return TRUE;
}

/********************************************************************************
* Description : enter the current directory
*
* Arguments : 
*         strDir:output parent directory name
* Returns   : 
*           TRUE:  success.
*           FALSE: fail, detail info store in fselError.
* Notes     : 
*
********************************************************************************/
BOOL    fselEntCurrentDir(char *strDir)
{
    WORD total;
    if ( fselDirLayer < TOTALDIRLAYER )
        fselDirLayer ++;
    else
    {
        fselError = FSEL_ERR_OUTOF;
        return FALSE;
    }
        
    total=GetFileTotal(strDir, FALSE);  //get the parement
    if (!FS_CD(strDir)) //enter the current dir
    {
        fselDirLayer --;
        fselError = FSEL_ERR_FS;
        return FALSE;
    }
    
    fselTotal = total;
    if(fselDirLayer < TOTALDIRLAYER)
        fselDirNo[fselDirLayer] = 0;
    fselFileNo = 0;
    fselExtNo = 0;
#ifdef __APE_SUPPORT
    fselFileNo_APE = 0;
    CurApe_TotalNo = 0;
#endif
    return TRUE;
}

/********************************************************************************
* Description : return the parent directory
*
* Arguments : 
*         strDir:output parent directory name
* Returns   : 
*           TRUE:  success.
*           FALSE: fail, detail info store in fselError.
* Notes     : 
*
********************************************************************************/
BOOL    fselRetParentDir(char *strDir)
{
    WORD  total;
    
    if ( (fselDirNo[fselDirLayer] == 0) && (fselDirLayer > 0) )
    {
        fselDirLayer --;
     }   
    else
    {
        fselError = FSEL_ERR_OUTOF;
        return FALSE;
    }
           
    if ( !FS_CD("\\") )  //return parent directory
    {
        fselError = FSEL_ERR_FS;
        return FALSE;
    }        
    
    if ( !ToDirEntry(strDir, fselDirNo[fselDirLayer]) ) //get the parent direcory name
    {
        return FALSE;
    }
    
    total=GetFileTotalCur(FALSE);  //get the parament    
    fselFileNo = 0;
    fselTotal = total;
    fselExtNo = 0;
#ifdef __APE_SUPPORT
    fselFileNo_APE = 0;
    CurApe_TotalNo = 0;
#endif
    return TRUE;
}

    
/********************************************************************************
* Description : Get the total of files in the current directory entry
*
* Arguments  : 
*            strDir: Dos 8.3 directory name
*            bCheckValidDir: if check valid directory only
* Returns     :
*            The file total of current directory when bCheckValidDir = FALSE
            or Vaild BOOL flag when bCheckValidDir = TRUE
* Notes       : None
*
********************************************************************************/
WORD  GetFileTotal(char *strDir,  BOOL bCheckValidDir)
{
    char *ext;
    WORD  total;
    BYTE extno;
    
    if( !FS_CD(strDir))
    {
        fselError = FSEL_ERR_FS;
        return 0;
    }
    extno = fselExtNo;
    fselExtNo = 0;
    total = 0;    
    do {
#ifdef __APE_SUPPORT
        if( !memcmp(ext = GetExtBuf(), APEExt2,3))
        {
            total += GetFileTotalCur_Ape();
            goto APE_Exit2;
        }
#else
        ext = GetExtBuf();
#endif
        if (FS_Dir(m_szTemp,  ext, FS_DIR_FILE))
        {
            total ++;
            if( bCheckValidDir)
                break;
            while ( FS_Dir(m_szTemp,  ext, FS_DIR_FILE_CONT) &&(total < FSEL_MAX_FILENUM))
            {
                output8(REG4E_RTC_WATCH_DOG, input8(REG4E_RTC_WATCH_DOG) | 0x08);
                 total ++; 
             }   
        }
APE_Exit2:
	;
    }while( (total < FSEL_MAX_FILENUM)&&ToNextExt());

    fselExtNo = extno;
    
    if ( !FS_CD("\\") )
    {
        fselError = FSEL_ERR_FS;
        return total;
    }
    return total;

}

⌨️ 快捷键说明

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