This code demonstrates how to get the space actually allocated by the data stream of a given file with NWGetNSEntryInfo()
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef __MWERKS__
#pragma ANSI_strict off
#endif
#include <nwcalls.h>
#include <nwclxcon.h>
#include <nwnamspc.h>
#ifdef __MWERKS__
#pragma ANSI_strict reset
#endif
#if defined( __MWERKS__) && !defined( N_PLAT_NLM)
#define strupr(s) (_strupr(s),s)
#endif
int main( int argc, char* argv[]) {
char const* server_name;
char const* file_name;
NWRCODE rcode;
NWCCODE ccode;
NWCONN_HANDLE conn_handle;
NW_ENTRY_INFO ns_entry_info;
if ( argc != 3) {
printf( "Usage: %s <servername> <filename>\n", *argv);
return EXIT_FAILURE;
}
ccode = NWCallsInit( NULL, NULL);
if ( ccode != 0) {
printf( "NWCallsInit failed, ccode = %x", ccode);
return EXIT_FAILURE;
}
server_name = strupr( *++argv);
file_name = strupr( *++argv);
rcode = NWCCOpenConnByName( 0,
server_name,
NWCC_NAME_FORMAT_BIND,
NWCC_OPEN_LICENSED,
NWCC_TRAN_TYPE_WILD,
&conn_handle);
if ( rcode != 0) {
printf( "NWCCOpenConnByName failed, rcode = %x", rcode);
NWCallsTerm( NULL);
return EXIT_FAILURE;
}
ccode = NWGetNSEntryInfo( conn_handle, 0, file_name, NW_NS_LONG, NW_NS_LONG, SA_NORMAL, IM_SPACE_ALLOCATED, &ns_entry_info);
if ( ccode != 0) {
printf( "NWGetNSEntryInfo failed, ccode = %x", ccode);
NWCCCloseConn( conn_handle);
NWCallsTerm( NULL);
return EXIT_FAILURE;
}
printf( "ns_entry_info.spaceAlloc = %d\n", ns_entry_info.spaceAlloc);
NWCCCloseConn( conn_handle);
NWCallsTerm( NULL);
return EXIT_SUCCESS;
}
© 2008 Novell, Inc. All Rights Reserved.