Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
BUG Adir with 2 Gb files
Message
 
To
24/06/2004 08:57:31
General information
Forum:
Visual FoxPro
Category:
Visual FoxPro Beta
Miscellaneous
Thread ID:
00916783
Message ID:
00916826
Views:
8
>Adir does not work with files biger than 2 GB
>It presents size negative.

VFP's ability to deal with sizes greater than 2 gb is limited by the fact that 32 bit integers are signed. Try the following to resolve this:
* lnsize is the value to convert
SET PROCEDURE TO Con_int.prg ADDIVITIVE
oConvert = CREATEOBJECT('ConvertInt')
lcsize = oConvert.IntegerToString(lnsize)
? oConvert.StringToInteger(lcsize)
DEFINE CLASS ConvertInt AS CUSTOM

  FUNCTION IntegerToString
    
    LPARAMETER pnInteger, pnbytes
    
    LOCAL lcresult, lnbytes, lnmask,;
      lninteger, lni, lnchar
    lcresult = ""
    IF PCOUNT() = 2
      lnbytes = pnbytes
    ELSE
      * Default to DWORD
      lnbytes = 4
    ENDIF
    lninteger = pnInteger
    lnmask = 255
    FOR lni = 1 TO lnbytes
      lnchar = BITAND(lninteger, lnmask)
      lcresult = lcresult + CHR(lnchar)
      lninteger = BITRSHIFT(lninteger, 8)
    NEXT
    RETURN lcresult
  ENDFUNC
  
  FUNCTION StringToInteger
    
    LPARAMETER pcstring, plsigned
    
    LOCAL lnresult, lnlast, lni, llsigned,;
      lnmsb, lnmax
    lnresult = 0
    lnlast = LEN(pcstring)
    * Return Signed Integer?
    IF PCOUNT() = 2
      llsigned = plsigned
    ELSE
      llsigned = .F.
    ENDIF
    FOR lni = 1 TO lnlast
      lnresult = lnresult + ASC(SUBSTR(pcstring, lni, 1)) * (256 ^ (lni - 1))
    NEXT
    IF llsigned
      lnmsb = (lnlast * 8) - 1
      IF BITTEST(lnresult, lnmsb)
        lnmax = (2 ^ (lnmsb + 1))
        lnresult = lnresult - lnmax
      ENDIF
    ENDIF
    RETURN lnresult
  ENDFUNC
ENDDEFINE
George

Ubi caritas et amor, deus ibi est
Previous
Reply
Map
View

Click here to load this message in the networking platform