file read while writing

  • Thread starter Thread starter gagan goel
  • Start date Start date
G

gagan goel

How can i read file (for watching movie) while it is
getting written (downloading)? Hopefuly it should be
possible in windows as it is very much possible in Linux
 
Sure it's possible.

But it requires the 'permission' of the program that is writing the file.
The program that is writing the file specifies the sharing options when
calling CreateFile(). If the program writing the file doesn't grant
FILE_SHARE_READ, then no other program can open the file for reading while
the first program is writing it.

See the documentation for CreateFile() in the SDK
(http://msdn.microsoft.com) for more information.

-Matt
 
If the program writing the file doesn't grant
FILE_SHARE_READ, then no other program can open the file for reading while
the first program is writing it.

Also note that the player should adhere to this and open the file as
FILE_READ. Most compilers open files in read/write mode unless otherwise
specified. If it does, it' quite normal to not be able to open it. No sane
program will write a file allowing others to write to it. If you have a
well-known and reliable player, it will adhere to this. Winamp, e.g., does.
I think WMP does too.

If one tags an MP3 file while it is downloaded, the tag is inserted to the
end of the current file size, not et the end of the final file and the tag
would end up in the middle. For that reason, the download manager will not
allow writing to file to take place while downloading. If the player does
not promise to not write to the file, it will not be allowed to open it.

To preview, you need a good downloader that denies write but allows read
while downloading and a good player that doesn't request write rights unless
needed. File rights do not fall back, if you request R/W and only read is
available, you get an error instead of file being opened read-only.

Try to open the file with Notepad. If the download manager has denied
READ, Notepad will give an error that the file cannot be accessed. In that
case, the downloader does not allow read. If it can be opened and read, it
means that the player is bad and tries a read/write access.

Notepad always request READ only when opening a file. That's why the "view
log" in the scheduler works. While scheduler is running, file is open with
SHARE_DENY_WRITE.
 
Back
Top