EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Order of OnRead file events

Also by EldoS: SecureBlackbox
200+ components and classes for digital security, signing, encryption and secure networking.
#23956
Posted: 03/06/2013 04:19:49
by Davide Baccaglini (Standard support level)
Joined: 11/19/2012
Posts: 48

Hi everyone, I've a question about opening / reading file.

In my project I would like to show a custom dialog box, containing a ProgressBar, when user open a file (double-click on it).

I tried to manage the percentage of increment of ProgressBar according to Position value in OnReadFile event, but I noticed a strange behavior during reading file.
It seems that reading file does not proceed in an orderly manner on the basis of Position value and in fact this is the debug trace of reading a file of 1,47 MB :
OnReadFile [\MyFile.doc] Position [0] BytesToRead [4096]
OnReadFile [\MyFile.doc] - END DOWNLOAD
OnReadFile [\MyFile.doc] Position [1541632] BytesToRead [4096]
OnReadFile [\MyFile.doc] Position [0] BytesToRead [4096]
OnReadFile [\MyFile.doc] Position [0] BytesToRead [4096]
OnReadFile [\MyFile.doc] Position [1543168] BytesToRead [2560]
OnReadFile [\MyFile.doc] Position [1543680] BytesToRead [2048]
OnReadFile [\MyFile.doc] Position [0] BytesToRead [4096]
OnReadFile [\MyFile.doc] Position [1541632] BytesToRead [4096]
OnReadFile [\MyFile.doc] Position [0] BytesToRead [4096]
OnReadFile [\MyFile.doc] Position [0] BytesToRead [4096]
OnReadFile [\MyFile.doc] Position [1543168] BytesToRead [2560]
OnReadFile [\MyFile.doc] Position [1543680] BytesToRead [2048]
OnReadFile [\MyFile.doc] Position [1544192] BytesToRead [1536]
OnReadFile [\MyFile.doc] Position [1523200] BytesToRead [4096]
OnReadFile [\MyFile.doc] Position [1523200] BytesToRead [4096]
OnReadFile [\MyFile.doc] Position [1523200] BytesToRead [4096]
OnReadFile [\MyFile.doc] Position [1523200] BytesToRead [4096]
OnReadFile [\MyFile.doc] Position [1527296] BytesToRead [4096]
OnReadFile [\MyFile.doc] Position [1523200] BytesToRead [4096]
OnReadFile [\MyFile.doc] Position [1527296] BytesToRead [4096]
OnReadFile [\MyFile.doc] Position [1527296] BytesToRead [4096]
OnReadFile [\MyFile.doc] Position [1523200] BytesToRead [4096]
OnReadFile [\MyFile.doc] Position [0] BytesToRead [4096]
OnReadFile [\MyFile.doc] Position [1541632] BytesToRead [4096]
OnReadFile [\MyFile.doc] Position [0] BytesToRead [4096]
OnReadFile [\MyFile.doc] Position [1541632] BytesToRead [4096]
OnReadFile [\MyFile.doc] Position [0] BytesToRead [4096]
OnReadFile [\MyFile.doc] Position [1541632] BytesToRead [4096]
OnReadFile [\MyFile.doc] Position [0] BytesToRead [32768]
OnReadFile [\MyFile.doc] Position [1540096] BytesToRead [5632]
OnReadFile [\MyFile.doc] Position [1527808] BytesToRead [17920]
OnReadFile [\MyFile.doc] Position [0] BytesToRead [4096]
OnReadFile [\MyFile.doc] Position [1541632] BytesToRead [4096]
OnReadFile [\MyFile.doc] Position [0] BytesToRead [24]
OnReadFile [\MyFile.doc] Position [0] BytesToRead [4096]
OnReadFile [\MyFile.doc] Position [1541632] BytesToRead [4096]
OnReadFile [\MyFile.doc] Position [1486848] BytesToRead [32768]
OnReadFile [\MyFile.doc] Position [53248] BytesToRead [32768]
OnReadFile [\MyFile.doc] Position [1519616] BytesToRead [26112]
OnReadFile [\MyFile.doc] Position [32768] BytesToRead [20480]
OnReadFile [\MyFile.doc] Position [421888] BytesToRead [32768]
OnReadFile [\MyFile.doc] Position [1454080] BytesToRead [32768]
OnReadFile [\MyFile.doc] Position [389120] BytesToRead [32768]
OnReadFile [\MyFile.doc] Position [1396736] BytesToRead [32768]
OnReadFile [\MyFile.doc] Position [86016] BytesToRead [32768]
OnReadFile [\MyFile.doc] Position [118784] BytesToRead [32768]
OnReadFile [\MyFile.doc] Position [151552] BytesToRead [32768]
OnReadFile [\MyFile.doc] Position [184320] BytesToRead [32768]
OnReadFile [\MyFile.doc] Position [217088] BytesToRead [32768]
OnReadFile [\MyFile.doc] Position [249856] BytesToRead [32768]
OnReadFile [\MyFile.doc] Position [282624] BytesToRead [32768]
OnReadFile [\MyFile.doc] Position [315392] BytesToRead [32768]
OnReadFile [\MyFile.doc] Position [348160] BytesToRead [32768]
OnReadFile [\MyFile.doc] Position [380928] BytesToRead [8192]
OnReadFile [\MyFile.doc] Position [1314816] BytesToRead [32768]
OnReadFile [\MyFile.doc] Position [471040] BytesToRead [32768]
OnReadFile [\MyFile.doc] Position [503808] BytesToRead [32768]
OnReadFile [\MyFile.doc] Position [536576] BytesToRead [32768]
OnReadFile [\MyFile.doc] Position [622592] BytesToRead [32768]
OnReadFile [\MyFile.doc] Position [667648] BytesToRead [32768]
OnReadFile [\MyFile.doc] Position [790528] BytesToRead [32768]
OnReadFile [\MyFile.doc] Position [901120] BytesToRead [32768]
OnReadFile [\MyFile.doc] Position [999424] BytesToRead [32768]
OnReadFile [\MyFile.doc] Position [1085440] BytesToRead [32768]
OnReadFile [\MyFile.doc] Position [1196032] BytesToRead [32768]
OnReadFile [\MyFile.doc] Position [1257472] BytesToRead [32768]
OnReadFile [\MyFile.doc] Position [1429504] BytesToRead [24576]
OnReadFile [\MyFile.doc] Position [454656] BytesToRead [16384]
OnReadFile [\MyFile.doc] Position [569344] BytesToRead [32768]
OnReadFile [\MyFile.doc] Position [602112] BytesToRead [20480]
OnReadFile [\MyFile.doc] Position [655360] BytesToRead [12288]
OnReadFile [\MyFile.doc] Position [700416] BytesToRead [32768]
OnReadFile [\MyFile.doc] Position [733184] BytesToRead [32768]
OnReadFile [\MyFile.doc] Position [765952] BytesToRead [24576]
OnReadFile [\MyFile.doc] Position [823296] BytesToRead [32768]
OnReadFile [\MyFile.doc] Position [856064] BytesToRead [32768]
OnReadFile [\MyFile.doc] Position [888832] BytesToRead [12288]
OnReadFile [\MyFile.doc] Position [933888] BytesToRead [32768]
OnReadFile [\MyFile.doc] Position [966656] BytesToRead [32768]
OnReadFile [\MyFile.doc] Position [1032192] BytesToRead [32768]
OnReadFile [\MyFile.doc] Position [1064960] BytesToRead [20480]
OnReadFile [\MyFile.doc] Position [1118208] BytesToRead [32768]
OnReadFile [\MyFile.doc] Position [1150976] BytesToRead [32768]
OnReadFile [\MyFile.doc] Position [1183744] BytesToRead [12288]
OnReadFile [\MyFile.doc] Position [1228800] BytesToRead [28672]
OnReadFile [\MyFile.doc] Position [1290240] BytesToRead [24576]
OnReadFile [\MyFile.doc] Position [1347584] BytesToRead [32768]
OnReadFile [\MyFile.doc] Position [1380352] BytesToRead [16384]
OnReadFile [\MyFile.doc] Position [0] BytesToRead [4096]
OnReadFile [\MyFile.doc] Position [1541632] BytesToRead [4096]

After the first read (start correctly to Position 0) I download file from server and read it (chunked read) in next N OnReadFile events.
I expected that subsequent readings only increase the Position to start read but it's not right : the second OnReadFile event read the last part of file and so on.

So, there is a way to recognize the correct order (by Position rising) of reading file to manage the percentuage of reading file?

Thanks in advance,
Davide
#23957
Posted: 03/06/2013 04:42:47
by Volodymyr Zinin (EldoS Corp.)

It depends on an application which performs file reading during its opening. Maybe the app doesn't require some parts of the file data or the file format (.doc in your case) maybe requires to read some metadata (or "directives") at the end of the file first.

Quote
Davide Baccaglini wrote:
So, there is a way to recognize the correct order (by Position rising) of reading file to manage the percentuage of reading file?

Perhaps to investigate the algorithm how a specific program opens a specific type of a file. Or rather to show a progress of the file downloading from the server instead of its opening.
You can use Process Monitor from sysinternals.com to see what I/O operations occur when a file is being opened.

Reply

Statistics

Topic viewed 585 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!