www.pudn.com > cwin.rar > DIRMENU.C


    /*----------------------------------------------------------- 
        函数 dirmenu : 文件目录选择菜单 
    -----------------------------------------------------------*/ 
    #include  
    #include  
    #include  
    #include  
    #include  
 
    /*---------- Static function _TranFilename. ---------------*/ 
    static void _TranFileitem(char *dest,struct ffblk f,int full_width) 
    { 
        char *point = strchr(f.ff_name,'.'); 
 
        /*---------- Initial destin string. -------------------*/ 
        memset(dest,' ',14); 
        dest[14]    = 0; 
 
        /*------- Copy filename to destin string. -------------*/ 
        if(point) 
        { 
            memcpy(dest+1,f.ff_name,point-f.ff_name); 
            memcpy(dest+10,point+1,strlen(point+1)); 
        } 
        else 
            memcpy(dest+1,f.ff_name,strlen(f.ff_name)); 
 
        /*------ Copy file size, date, time to destin. --------*/ 
        if(full_width) 
        { 
            int year   = (f.ff_fdate>>9)+80; 
            int month  = (f.ff_fdate>>5)&0x1f; 
            int day    = f.ff_fdate&0x1f; 
            int hour   = (f.ff_ftime>>11)&0x1f; 
            int minate = (f.ff_ftime>>5)&0x1f; 
            int noon   = hour>12?'p':'a'; 
 
            hour       = hour>12?hour-12:hour; 
            sprintf(dest+14,"%8ld %02d-%02d-%02d %02d:%02d%c ",f.ff_fsize,month,day,year,hour,minate,noon); 
        } 
    } 
 
    /*----------------------------------------------------------- 
        Function dir_menu. 
    -----------------------------------------------------------*/ 
    unsigned _Cdecl dir_menu(col,line,high,path,attrib,full_width,fun,multiselect) 
    int col;           /* 目录选择菜单左上角列坐标(单位为字节) */ 
    int line;          /* 目录选择菜单左上角行坐标(单位为象素) */ 
    int high;          /* 目录选择菜单高度(单位为正文行)       */ 
    char *path;        /* 备选文件路径(可使用通配符)           */ 
    int attrib;        /* 备选文件属性                         */ 
    int full_width;    /* 是否显示文件长度、日期等             */ 
    void (*fun)();     /* 指向处理被选中的文件的函数指针       */ 
    int multiselect;   /* 是否允许选择多个文件                 */ 
    { 
        unsigned key; 
        struct ffblk ffblk; 
        char   **dir_list; 
        char     filename[MAXPATH]; 
        char     drive[MAXDRIVE]; 
        char     dir[MAXDIR]; 
        char    *nameptr = filename; 
        int      i; 
        int      dir_count = 1; 
        int      no        = 0; 
        int      width     = full_width?40:14; 
 
        /*----------- 如果没有符合条件的文件则退出 ------------*/ 
        if(findfirst(path,&ffblk,attrib)) 
            return NULL; 
 
        /*--------------- 取符合条件的文件数目 ----------------*/ 
        while(findnext(&ffblk)==0) 
            dir_count++; 
 
 
        fnsplit(path,drive,dir,NULL,NULL); 
        if(drive[0]) 
        { 
            sprintf(nameptr,"%s",drive); 
            nameptr += strlen(drive); 
        } 
        if(dir[0]) 
        { 
            sprintf(nameptr,"%s",dir); 
            nameptr += strlen(dir); 
        } 
 
        /*------------------ 构造文件目录表 -------------------*/ 
        if(coreleft()