c语言中的文件属性
请问,c语言中更改已经存在文件属性的函数是什么? 问题点数:100、回复次数:8Top
1 楼chenghl(程门立雪)回复于 2002-11-27 11:07:15 得分 0
SetStatus(LPCTSTR lpszFileName, const CFileStatus& status )Top
2 楼chenghl(程门立雪)回复于 2002-11-27 11:13:38 得分 80
sorry,that's C++;
to change file permission, use
int _chmod( const char *filename, int pmode );
int _wchmod( const wchar_t *filename, int pmode );
to change the file size,use
_int _chsize( int handle, long size );
Top
3 楼Behard(我爱天安门)回复于 2002-11-27 11:24:19 得分 20
试一试以下函数:
fstat
setftime
fblk
ffblk <DIR.H>
哌哌哌?
DOS file control block structure.
struct ffblk {
char ff_reserved[21]; /* reserved by DOS */
char ff_attrib; /* attribute found */
int ff_ftime; /* file time */
int ff_fdate; /* file date */
long ff_fsize; /* file size */
char ff_name[13]; /* found file name */
};
Remarks:
ff_ftime and ff_fdate are 16-bit structures divided into bit fields for
referring to the current date and time.
ff_ftime ?5.....11?0........5?.......0?
苘苘苘苘 掏淹淹淹淹瓮淹淹淹淹淹瓮淹淹淹淹?
韧贤贤贤贤释贤贤贤贤贤释贤贤贤贤?
Hours Minutes Seconds/2
ff_fdate ?5..........9?.....5?.......0?
苘苘苘苘 掏淹淹淹淹淹淹瓮淹淹淹瓮淹淹淹淹?
韧贤贤贤贤贤贤释贤贤贤释贤贤贤贤?
Years since Month Day
1980
The structure of these fields was established by DOS.
See Also:
findfirst ftime structure find_t structure
Top
4 楼Behard(我爱天安门)回复于 2002-11-27 11:25:29 得分 0
应该是 ffblk 吧。Top
5 楼Behard(我爱天安门)回复于 2002-11-27 11:36:29 得分 0
DOS file attributes
Constant ?Description
屯屯屯屯屯拓屯屯屯屯屯屯屯屯屯屯?
FA_RDONLY ?Read-only attribute
FA_HIDDEN ?Hidden file
FA_SYSTEM ?System file
FA_LABEL ?Volume label
FA_DIREC ?Directory
FA_ARCH ?Archive
For more detailed information about these attributes, refer to your DOS
reference manuals.
Top
6 楼crazy_diablo(狂暴)回复于 2002-11-27 11:46:15 得分 0
解决了,使用_chmod()这个函数
谢谢各位Top
7 楼Behard(我爱天安门)回复于 2002-11-27 12:02:04 得分 0
捱哌哌哌哌哌哌哌哌哌哌哌哌哌哌哌哌哌咻
?_chmod, ? <IO.H>
?_dos_getfileattr, _dos_setfileattr ? <DOS.H>
捃苘苘苘苘苘苘苘苘苘苘苘苘苘苘苘苘苘茌
Gets or sets file attributes
Declaration:
?int _chmod(const char *path, int func [ , int attrib ] );
?int _dos_getfileattr(const char *path, unsigned *attribp);
?int _dos_setfileattr(const char *path, unsigned attrib);
Remarks:
These functions get and/or set the DOS file attributes of the file given by
*path:
?_chmod gets or sets the attributes
?_dos_getfileattr gets the attributes
?_dos_setfileattr sets the attributes
Argument ?What It Is/Does
屯屯屯屯屯赝屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯?
path ?Points to a string that names the file whose attributes are
?fetched or set; *path = first character of that string
func ?Specifies whether _chmod gets or sets attributes of the file
?*path:
? ?If func = 0, _chmod returns the current DOS attributes
? ?If func = 1, _chmod sets the attributes to attrib
attrib ?One of the DOS file-attribute symbolic constants defined
?in DOS.H.
attribp ?Points to location where _dos_getfileattr stores attributes
Return Value:
?On success,
?_chmod returns file attribute word
?_dos_getfileattr and _dos_setfileattr return 0
?On error,
?_chmod returns -1 and sets errno to one of the following:
ENOENT (Path or file name not found)
EACCES (Permission denied)
?_dos_getfileattr returns the DOS error code and sets errno to
ENOENT or EACCES
?_dos_setfileattr returns the DOS error code and sets errno to
ENOENT
Portability:
?DOS ?UNIX ?Windows ?ANSI C ?C++ Only ?
?Yes ? ? Yes ? ? ?
韧屯屯贤屯屯拖屯屯屯屯拖屯屯屯屯贤屯屯屯屯图
See Also:
chmod _creat stat
Examples:
_chmod example _dos_getfileattr example
_dos_setfileattr example
FA_RDONLY //?Read-only attribute
FA_HIDDEN //?Hidden file
FA_SYSTEM //?System file
FA_LABEL //?Volume label
FA_DIREC //?Directory
FA_ARCH //?Archive
Top
8 楼Behard(我爱天安门)回复于 2002-11-27 12:27:32 得分 0
要给分呀!Top




