f_blobtofile.srf 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. $PBExportHeader$f_blobtofile.srf
  2. global type f_blobtofile from function_object
  3. end type
  4. forward prototypes
  5. global function integer f_blobtofile (string arg_filepathname, blob arg_blobdata, ref string arg_msg)
  6. end prototypes
  7. global function integer f_blobtofile (string arg_filepathname, blob arg_blobdata, ref string arg_msg);//blob转文件
  8. long rslt=1,fend,fend_t
  9. blob b_dtdata, b_dtdata_p
  10. long li_FileNum,ls_i,ls_jh
  11. string tmpfilepathname
  12. tmpfilepathname=arg_filepathname
  13. b_dtdata=arg_blobdata
  14. fend=len(b_dtdata)
  15. if fend<=32765 then
  16. fend_t=1
  17. else
  18. fend_t=fend/32765
  19. if mod(fend,32765)<>0 then
  20. fend_t=fend_t+1
  21. end if
  22. end if
  23. li_FileNum = FileOpen( tmpfilepathname,StreamMode!, Write!, LockWrite!)
  24. if li_FileNum<=0 then
  25. arg_msg="打开文件"+tmpfilepathname+"失败"
  26. rslt=0
  27. fileclose(li_FileNum)
  28. goto ext
  29. end if
  30. for ls_i = 1 to fend_t
  31. b_dtdata_p=blobmid(b_dtdata,1+(ls_i - 1 )*32765,32765)
  32. ls_jh=FileWrite(li_FileNum, b_dtdata_p)
  33. if ls_jh<=0 then
  34. arg_msg="写文件"+tmpfilepathname+"失败"
  35. rslt=0
  36. fileclose(li_FileNum)
  37. goto ext
  38. end if
  39. next
  40. fileclose(li_FileNum)
  41. ext:
  42. return rslt
  43. end function