This sample demonstrates how to obtain and modify file attributes with functions NWIntScanFileInformation2() and NWSetFileInformation2(). It just clears attributes of a file, although could set them if you modify the line info.fileAttributes = 0. As with NWSetFileAttributes(), you cannot obtain or modify NetWare-specific attributes with these functions.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef __MWERKS__
#pragma ANSI_strict off
#endif
#include <nwcalls.h>
#ifdef __MWERKS__
#pragma ANSI_strict reset
#endif
int main( int argc, char* argv[]) {
NWCCODE ccode;
NWCONN_HANDLE conn;
NWDIR_HANDLE dirHandle;
nstr8 newPath[ 256];
nuint8 iter[ 9] = { 0xFF, 0xFF, 0xFF, 0xFF };
NW_FILE_INFO2 info;
if ( argc != 2) {
puts( "Usage: SetFInf2 <filename>");
return EXIT_FAILURE;
}
ccode = NWParseNetWarePath( argv[ 1], &conn, &dirHandle, newPath);
if ( ccode != 0) {
printf( "NWParseNetWarePath failed, ccode = %x\n", ccode);
return EXIT_FAILURE;
}
ccode = NWIntScanFileInformation2( conn, dirHandle, newPath, FA_HIDDEN | FA_SYSTEM, iter, &info, 0);
if ( ccode != 0) {
printf( "NWIntScanFileInformation2 failed, ccode = %x\n", ccode);
return EXIT_FAILURE;
}
info.fileAttributes = 0;
ccode = NWSetFileInformation2( conn, dirHandle, newPath, FA_HIDDEN | FA_SYSTEM, &info);
if ( ccode != 0) {
printf( "NWSetFileInformation2 failed, ccode = %x\n", ccode);
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
© 2009 Novell, Inc. All Rights Reserved.