Jump to content

Recommended Posts

Posted (edited)

I have this code, but FileRead() returns nothing after the page 20+ (or 30+).

I think the problem is with the FileSetPos().

Helpfile says for FileSetPos():

Parameters:

handle - A handle to a file previously opened with FileOpen().

If i use as FileSetPos(0,$iBufSize * $iPage + 1,$FILE_CURRENT) just works fine. Tell me what is the problem:)

$sFileLoc = @ScriptDir & '\Downloads\Movie.avi'
$iBufSize = 1024 * 1024 ;=1MB
$iMaxPage = Round(FileGetSize($sFileLoc) / $iBufSize)
$hFile = FileOpen($sFileLoc,16)
For $iPage = 0 To $iMaxPage
    FileSetPos($hFile,$iBufSize * $iPage + 1,$FILE_CURRENT)
    $iBuffer = FileRead($hFile,$iBufSize)
    ConsoleWrite($iPage & '/' & Round(FileGetSize($sFileLoc) / $iBufSize) & ' ' & BinaryLen($iBuffer) & @CRLF)
Next
FileClose($hFile)

Greetz, CyRius

Edited by CyRius

[font="Courier New"][size="3"]CyRius Developments[/size][/font][list][*]CO Proxy[*]CO Assembly tool[*]CO PacketSniffer[*]Larkinor proxy[*]BoIM Messenger[*]Encrypt/Decrypt[*]Hashtables[*]Slowest, but greatest skins ever xD[/list]

Posted

  On 2/13/2010 at 4:24 PM, 'MvGulik said:

1) Code is incomplete.

2) $sFileLoc, that better not contain a location like a folder spec.

1) It was incomplete because you must specify a file larger than 150MBs (I've added $sFileLoc)

2) I don't understand this. Why shouldn't contain a file location?

[font="Courier New"][size="3"]CyRius Developments[/size][/font][list][*]CO Proxy[*]CO Assembly tool[*]CO PacketSniffer[*]Larkinor proxy[*]BoIM Messenger[*]Encrypt/Decrypt[*]Hashtables[*]Slowest, but greatest skins ever xD[/list]

Posted

This works for me reading and writing a 60 mb jpg sample file:

#include <Constants.au3>

$sFileLoc = "M101.jpg"

$iBufSize = 1024 * 1024 ;=1MB
$iBuffer = 0
$iMaxPage = ceiling(FileGetSize($sFileLoc) / $iBufSize) - 1
$hFile = FileOpen($sFileLoc,0)
For $iPage = 0 To $iMaxPage
    FileSetPos($hFile, $iBufSize * $iPage, 0)
    $iBuffer &= FileRead($hFile, $iBufSize)
    ConsoleWrite($iPage & '/' & Ceiling(FileGetSize($sFileLoc) / $iBufSize) - 1 & ' ' & BinaryLen($iBuffer) & @CRLF)
Next
FileClose($hFile)

$hFile = FileOpen("test.jpg",1+16)
FileWrite($hFile, $iBuffer)
FileClose($hFile)
Posted (edited)

@MvGulik

OK, rename it to $sFolderFileSpec if you can't work with $sFileLoc variable.

I just asked you to solve the problem if you can, not to rename my variables, because those not solve the problem (as i see).

@KaFu

Thanks, your example works well, but my example why didn't work?:mellow:

I will try now your example using binary data. Maybe that causes problems for me.

Edit: Oh, i see.. So i must use $FILE_BEGIN instead of $FILE_CURRENT!

Edit2: Thank you guys the fast reply:)

Edited by CyRius

[font="Courier New"][size="3"]CyRius Developments[/size][/font][list][*]CO Proxy[*]CO Assembly tool[*]CO PacketSniffer[*]Larkinor proxy[*]BoIM Messenger[*]Encrypt/Decrypt[*]Hashtables[*]Slowest, but greatest skins ever xD[/list]

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...