1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- $PBExportHeader$f_getblobfromfile.srf
- global type f_getblobfromfile from function_object
- end type
- forward prototypes
- global function integer f_getblobfromfile (ref blob arg_bdata, string arg_filename, ref string arg_msg)
- end prototypes
- global function integer f_getblobfromfile (ref blob arg_bdata, string arg_filename, ref string arg_msg);//f_getblobfromfile(arg_bdata,arg_filename,arg_msg)
- Long rslt = 1
- Long flen,li_FileNum,loops,ls_i,bytes_read,new_pos
- Blob b_dtdata_p,tot_b
- SetPointer(HourGlass!)
- // Get the file length, and open the file
- flen = FileLength(arg_filename)
- li_FileNum = FileOpen(arg_filename, StreamMode!, Read!, LockRead!)
- IF li_FileNum = -1 THEN
- rslt = 0
- arg_msg = '打开文件'+arg_filename+'操作失败!'
- FileClose(li_FileNum)
- GOTO ext
- END IF
- // Determine how many times to call FileRead
- IF flen > 32765 THEN
- IF Mod(flen, 32765) = 0 THEN
- loops = flen/32765
- ELSE
- loops = (flen/32765) + 1
- END IF
- ELSE
- loops = 1
- END IF
- // Read the file
- new_pos = 1
- FOR ls_i = 1 To loops
- bytes_read = FileRead(li_FileNum, b_dtdata_p)
- IF bytes_read = 0 THEN
- rslt = 0
- arg_msg = '读取文件'+arg_filename+'操作失败!'
- FileClose(li_FileNum)
- GOTO ext
- END IF
- tot_b = tot_b + b_dtdata_p
- NEXT
- arg_bdata = tot_b
- FileClose(li_FileNum)
- ext:
- RETURN rslt
- end function
|