How to know when a file will be opened

110 views
Skip to first unread message

Michael

unread,
Mar 9, 2010, 8:33:20 AM3/9/10
to Dokan
Hello,

I am currently developing a WebDAV-FileSystem with Dokan.
First everything went really well, but then I encountered a problem:
When I single-click on a file in the Windows Explorer it not only
wants to open it, but read the file. That means I have to download the
whole file when I single-click it. I already have mounted the FS as a
Network File System.

Does anyone know which information the explorer wants when he reads
the file on a single-click?

Is there a way to differentiate whether the explorer only wants to
read the first few bytes (as I have notived in my research) or the
whole file because someone wants to open it (some flags could be
different)?
I also stumbled upon the Flag FILE_ATTRIBUTE_OFFLINE which did not
bring the hoped-use.

Maybe I did not implement a function in the right way (i.e.
GetFileInformation) so Dokan has to get this information from the file
itself, is this possible?

Thanks a lot
Michael

Thomas

unread,
Mar 12, 2010, 7:20:36 AM3/12/10
to Dokan
Windows explorer tries to read at least part of a file to show a
preview, etc., as soon as you touch it. It's fucking stupid, that's
the only way I can put it. Also, there is no real architecutre to
allow for providing the necessary metadata for a given file (it's all
based on file types, not where the file is located). What exactly
explorer is trying to read depends on the file type.

When you implement the read callback, you get the range that is being
read, no? The best bet is to continue downloading the file content in
the background as soon as windows starts asking for the first couple
of bytes.

If you want to get a feel for what you can do here, download Wuala and
try the file system implementation. Your usecase is very similar to
what we do.

Thomas

Michael schrieb:

Michael

unread,
Mar 18, 2010, 10:24:30 AM3/18/10
to Dokan
Hello Thomas,

thank you very much for you answer.

I tried a slightly different approach. If ReadFile is called with an
Offset of 0 I read the first BufferLength Bytes from the WebDAV-Folder
and after that I stop.
If it is called with an Offset greater than 0 I download the whole
file and read from it.


Michael

Kevin Heeney

unread,
Mar 18, 2010, 2:22:04 PM3/18/10
to do...@googlegroups.com, Dokan
I would suggest returning the requested bytes though before
downloading the whole file. Otherwise the dokan call could timeout.

Kevin

Sent from my iPhone

> --
> You received this message because you are subscribed to the Google
> Groups "Dokan" group.
> To post to this group, send email to do...@googlegroups.com.
> To unsubscribe from this group, send email to dokan+un...@googlegroups.com
> .
> For more options, visit this group at http://groups.google.com/group/dokan?hl=en
> .
>

Joe Burmeister

unread,
Mar 19, 2010, 5:41:30 AM3/19/10
to do...@googlegroups.com
Hi,

Parts of my filesystem is similar, in that some files are pulled down from a database on demand.
(The whole thing is kind of like a TortoiseSVN on top a virtual on demand filesystem of the database. Can't open source it as the version control database is internal, and uses miles and miles of internal code. Though as the whole thing is a bit of meta filesystem, with different mounts, I have published this meta filesystem framework as it's part of PlisgoFSLib.)

I don't actually pull down the file until it is read. So read can be >slow<, Dokan does timeout then try again. What I do to stop this causing any issue is to have a map of currently downloading files. When a request for a file to download happens, I check if it's downloading already, if it is, wait for that download. So each fresh Dokan read call ends up waiting for the same download. It's not perfect, but it does work. I've not yet got round to looking at the latest Dokan with it's timeout control stuff.


The FILE_ATTRIBUTE_OFFLINE does cause explorer to pull down files in less cases.

As my filesystem is used only with Plisgo (which is what does the TortoiseSVN like part). Extra columns, overlays, icons, menu items I add through Plisgo, so I'm controlling quite a bit of how explorer uses my filesystem.

Hope this is of interest to anyone else doing on demand type filesystems.

Joe
Reply all
Reply to author
Forward
0 new messages