HP OpenVMS Systems

ask the wizard
Content starts here

Obtaining the size of a file?

» close window

The Question is:

I have been looking for a sys$ lib$ function i can call from a Vax Basic
 program, that will give me the size of a specified file.
Or even better would be a way to find out when a file has finished transfering
 to a nfs drive on our proxy server.
hope you can help

The Answer is :

 ! This example show two distinct methods of obtaining file sizes.
 ! - How the get teh ALLOCATED size Through the built-in function FSP$
 ! - How to exploit the basic provided RMS XABFHC from a useropen
    Common (File_Data) integer Used_Size
    record fsp_data
      	byte org                          ! these 2 are swapped
      	byte rat
      	word max_record_size
      	long file_size
      	word bucketsize_blocksize
      	word num_keys
      	long max_record_number
      	string ret_string=16              ! "string" missing
      end variant                         ! this line is missing too
    end record
    declare fsp_data file_chars
    open "test" for input as file #1, access read, allow modify, &
	recordtype any, useropen Size_Finder
    print "xabfhc ebk = "; Used_size; ", fsp size = "; file_chars::file_size
 2 Function Long Size_Finder (Fabdef Fab, Rabdef Rab, Long Channel)
    Option Type = Explicit
    %include "$FABDEF" %from %library "SYS$LIBRARY:BASIC$STARLET"
    %include "$RABDEF" %from %library "SYS$LIBRARY:BASIC$STARLET"
    External long constant xab$L_ebk            ! offset into fhc block
    External Long Function Sys$Open, Sys$Connect
    Common (File_Data) integer Used_Size
    Declare Long   Stat
    Stat = Sys$Open(fab)
    Stat = Sys$Connect(Rab) If (Stat And 1%) = 1%
    Size_Finder = Stat
    ! At this point we could/should really walk the XAB chain from the FAB
    ! Looking for XAB$B_COD = XAB$C_FHC. However, we _know_ this is the first
    ! XAB provided by Basic. Just copy the EBK field from it directly.
    call lib$movc3( 4% ,fab::fab$l_xab + xab$L_ebk by value, Used_size)
End Function

answer written or last revised on ( 4-JUL-2000 )

» close window