Sign in to follow this  
Followers 0
CyRius

FileRead() fails with 3.3.5.4 version (beta)

7 posts in this topic

#1 ·  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]

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

whatever Edited by MvGulik

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Share this post


Link to post
Share on other sites

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]

Share this post


Link to post
Share on other sites

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)

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

whatever Edited by MvGulik

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Share this post


Link to post
Share on other sites

#6 ·  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]

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

whatever Edited by MvGulik

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0