2973|4

73

帖子

0

TA的资源

一粒金砂(初级)

楼主
 

怎样读取一个目录下特定类型的所有文件? [复制链接]

如题

最新回复

我的意思是先opendir然后readdir的时候只要特定的扩展名的文件,把其他的过滤掉,请问可以实现么?  详情 回复 发表于 2007-10-4 10:28
点赞 关注

回复
举报

77

帖子

0

TA的资源

一粒金砂(初级)

沙发
 
/* File attribute byte values */

#define DOS_ATTR_RDONLY         0x01            /* read-only file */
#define DOS_ATTR_HIDDEN         0x02            /* hidden file */
#define DOS_ATTR_SYSTEM         0x04            /* system file */
#define DOS_ATTR_VOL_LABEL      0x08            /* volume label (not a file) */
#define DOS_ATTR_DIRECTORY      0x10            /* entry is a sub-directory */
#define DOS_ATTR_ARCHIVE        0x20            /* file subject to archiving */

请参考Stat.h, dirLib, dosfsLib
struct stat中的成员UINT8        st_attrib;        /* file attribute byte (dosFs only) */

/*******************************************************************************
*
* stat - get file status information using a pathname (POSIX)
*
* This routine obtains various characteristics of a file (or directory).
* This routine is equivalent to fstat(), except that the of the file
* is specified, rather than an open file descriptor.
*
* The parameter is a pointer to a `stat' structure (defined
* in stat.h).  This structure must have already been allocated before
* this routine is called.
*
* NOTE: When used with netDrv devices (FTP or RSH), stat() returns the size
* of the file and always sets the mode to regular; stat() does not distinguish
* between files, directories, links, etc.
*
* Upon return, the fields in the `stat' structure are updated to
* reflect the characteristics of the file.
*
* RETURNS: OK or ERROR.
*
* SEE ALSO:
* fstat(), ls()
*/

STATUS stat
    (
    char        *name,                  /* name of file to check */
    struct stat *pStat                  /* pointer to stat structure */
    );
 
 

回复

63

帖子

0

TA的资源

一粒金砂(初级)

板凳
 
FILE ATTRIBUTES
Directory entries on dosFs volumes contain an attribute byte consisting of bit-flags which specify various characteristics of the entry. The attributes which are identified are: read-only file, hidden file, system file, volume label, directory, and archive. The VxWorks symbols for these attribute bit-flags are:


DOS_ATTR_RDONLY
File is write-protected, can not be modified or deleted.
DOS_ATTR_HIDDEN
this attribute is not used by VxWorks.
DOS_ATTR_SYSTEM
this attribute is not used by VxWorks.
DOS_ATTR_VOL_LABEL
directory entry describes a volume label, this attribute can not be set or used directly, see ioctl( ) command FIOLABELGET and FIOLABELSET below for volume label manipulation.
DOS_ATTR_DIRECTORY
directory entry is a subdirectory, this attribute can not be set directly.
DOS_ATTR_ARCHIVE
this attribute is not used by VxWorks.

All the flags in the attribute byte, except the directory and volume label flags, may be set or cleared using the ioctl( ) FIOATTRIBSET function. This function is called after opening the specific file whose attributes are to be changed. The attribute byte value specified in the FIOATTRIBSET call is copied directly. To preserve existing flag settings, the current attributes should first be determined via fstat( ), and the appropriate flag(s) changed using bitwise AND or OR operations. For example, to make a file read-only, while leaving other attributes intact:

    struct stat fileStat;

    fd = open ("file", O_RDONLY, 0);     /* open file          */
    fstat (fd, &fileStat);               /* get file status    */

    ioctl (fd, FIOATTRIBSET, (fileStat.st_attrib | DOS_ATTR_RDONLY));
                                         /* set read-only flag */
    close (fd);                          /* close file         */

See also the reference manual entry for attrib( ) and xattrib( ) for user-level utility routines which control the attributes of files or file hierarchy.


 
 
 

回复

68

帖子

0

TA的资源

一粒金砂(初级)

4
 
好像我说的不清楚,是读取特定“扩展名”的所有文件。
 
 
 

回复

64

帖子

0

TA的资源

一粒金砂(初级)

5
 
我的意思是先opendir然后readdir的时候只要特定的扩展名的文件,把其他的过滤掉,请问可以实现么?
 
 
 

回复
您需要登录后才可以回帖 登录 | 注册

查找数据手册?

EEWorld Datasheet 技术支持

相关文章 更多>>
关闭
站长推荐上一条 1/10 下一条

 
EEWorld订阅号

 
EEWorld服务号

 
汽车开发圈

About Us 关于我们 客户服务 联系方式 器件索引 网站地图 最新更新 手机版

站点相关: 国产芯 安防电子 汽车电子 手机便携 工业控制 家用电子 医疗电子 测试测量 网络通信 物联网

北京市海淀区中关村大街18号B座15层1530室 电话:(010)82350740 邮编:100190

电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号 Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved
快速回复 返回顶部 返回列表