of_FileRead


pfcapsrv.pbl   >   pfc_n_cst_filesrv   >   of_FileRead   

Full name pfc_n_cst_filesrv.of_FileRead
Access public
Extend of long
Return value long
Prototype public function long of_FileRead(string,ref blob)

Name Datatype
No Data

Name Datatype
lblb_Data blob
li_Cnt integer
li_FileNo integer
li_Reads integer
ll_FileLen long

public function long of_FileRead (string as_FileName, ref blob ablb_Data);//////////////////////////////////////////////////////////////////////////////
//	Public Function:  of_FileRead
//	Arguments:		as_FileName				The name of the file to read.
//						ablb_Data				The data from the file, passed by reference.
//	Returns:			Long - The size of the blob read, returns -1 if an error occurrs.
//	Description:	Open, read into a blob, and close a file.  Handles files > 32,765 bytes.
//////////////////////////////////////////////////////////////////////////////
//	Rev. History:	Version
//						5.0   Initial version
//////////////////////////////////////////////////////////////////////////////
//	Copyright © 1996-1999 Sybase, Inc. and its subsidiaries.  All rights reserved.  Any distribution of the 
// PowerBuilder Foundation Classes (PFC) source code by other than Sybase, Inc. and its subsidiaries is prohibited.
//////////////////////////////////////////////////////////////////////////////
integer		li_FileNo, li_Reads, li_Cnt
long			ll_FileLen
blob			lblb_Data

ll_FileLen = FileLength(as_FileName)

li_FileNo = FileOpen(as_FileName, StreamMode!, Read!)
If li_FileNo < 0 Then Return -1

// Determine the number of reads required to read the entire file
If ll_FileLen > 32765 Then
	If Mod(ll_FileLen, 32765) = 0 Then
		li_Reads = ll_FileLen / 32765
	Else
		li_Reads = (ll_FileLen / 32765) + 1
	End if
Else
	li_Reads = 1
End if

// Empty the blob argument
ablb_Data = lblb_Data

// Read the file and build the blob with data from the file
For li_Cnt = 1 to li_Reads
	If FileRead(li_FileNo, lblb_Data) = -1 Then
		Return -1
	Else
		ablb_Data = ablb_Data + lblb_Data
	End if
Next

FileClose(li_FileNo)

Return ll_FileLen
end function

     
Name Owner
pfc_n_cst_filesrv.of_FileCopy pfc_n_cst_filesrv

     
Name Owner
systemfunctions.fileclose systemfunctions
systemfunctions.filelength systemfunctions
systemfunctions.fileopen systemfunctions
systemfunctions.fileread systemfunctions
systemfunctions.mod systemfunctions

     
Full name
No Data

     
Name Scope
No Data