This repository has been archived on 2024-12-16. You can view files and clone it, but cannot push or open issues or pull requests.
CodeBlocksPortable/WATCOM/samples/clibexam/getfattr.c

29 lines
598 B
C
Raw Normal View History

#include <stdio.h>
#include <dos.h>
void print_attribute()
{
unsigned attribute;
_dos_getfileattr( "file", &attribute );
printf( "File attribute is %d\n", attribute );
if( attribute & _A_RDONLY ) {
printf( "This is a read-only file.\n" );
} else {
printf( "This is not a read-only file.\n" );
}
}
void main()
{
int handle;
if( _dos_creat( "file", _A_RDONLY, &handle ) != 0 ) {
printf( "Error creating file\n" );
}
print_attribute();
_dos_setfileattr( "file", _A_NORMAL );
print_attribute();
_dos_close( handle );
}