Getting started with Dokan -- CreateFile

516 views
Skip to first unread message

noah

unread,
Dec 2, 2009, 11:11:13 PM12/2/09
to Dokan
I'm just getting started with Dokan and have spent the last week just
trying to get up and running. I've got the basic gist down of how
things should work and have gotten a single feature working: directory
listing (at least on the root directory). The next feature on my list
is creating files and I'm having a hell of a time figuring it out.

I mount my Dokan drive as Z:, open notepad, click Save, and try to
save to a file named Test3.txt. I keep getting an error "There are no
more files".

I have logging enabled via Log4net, and I have an Info entry for each
method of my DokanOperations subclass that's getting called, so I can
see the flow of how things get called. The funny thing is I see no
entry for CreateFile with filename parameter "Test3.txt -- it seems
like something is failing even before it gets to that point.

Here's the last number of lines from the log (after clicking "Save"
and receiving that "There are no more files" error):

2009-12-02 23:06:10,169 CreateFile \ with mode Open options None
2009-12-02 23:06:10,169 FindFiles \
2009-12-02 23:06:10,170 File found \AutoRun.inf
2009-12-02 23:06:10,170 File found \autorun.inf
2009-12-02 23:06:10,170 File found \desktop.ini
2009-12-02 23:06:10,170 File found \test
2009-12-02 23:06:10,170 File found \test.txt
2009-12-02 23:06:10,170 File found \test2
2009-12-02 23:06:10,170 File found \test2.txt
2009-12-02 23:06:10,171 Cleanup \
2009-12-02 23:06:10,184 CloseFile \
2009-12-02 23:06:10,184 CreateFile \ with mode Open options None
2009-12-02 23:06:10,185 FindFiles \
2009-12-02 23:06:10,185 File found \AutoRun.inf
2009-12-02 23:06:10,185 File found \autorun.inf
2009-12-02 23:06:10,185 File found \desktop.ini
2009-12-02 23:06:10,185 File found \test
2009-12-02 23:06:10,185 File found \test.txt
2009-12-02 23:06:10,185 File found \test2
2009-12-02 23:06:10,382 File found \test2.txt
2009-12-02 23:06:10,383 Cleanup \
2009-12-02 23:06:10,383 CloseFile \
2009-12-02 23:06:10,384 CreateFile \ with mode Open options None
2009-12-02 23:06:10,384 FindFiles \
2009-12-02 23:06:10,384 File found \AutoRun.inf
2009-12-02 23:06:10,384 File found \autorun.inf
2009-12-02 23:06:10,384 File found \desktop.ini
2009-12-02 23:06:10,384 File found \test
2009-12-02 23:06:10,384 File found \test.txt
2009-12-02 23:06:10,582 File found \test2
2009-12-02 23:06:10,582 File found \test2.txt
2009-12-02 23:06:10,583 Cleanup \
2009-12-02 23:06:10,583 CloseFile \

Any idea what's going on here?

My implementation of Cleanup and CloseFile just return 0.
My implementation of CreateFile is the following:

public int CreateFile(string filename, System.IO.FileAccess access,
System.IO.FileShare share, System.IO.FileMode mode,
System.IO.FileOptions options, DokanFileInfo info)
{
_Log.Info(string.Format("CreateFile {0} with mode {1}
options {2}", filename, mode, options));

if (filename == "\\")
return DokanNet.DOKAN_SUCCESS;
try
{
var file = _Proxy.Create(filename, mode);
if (!info.IsDirectory)
info.IsDirectory = file.IsDirectory;
info.Context = file;
return DokanNet.DOKAN_SUCCESS;
}
catch (FileNotFoundException ex)
{
_Log.Warn("File " + filename + " not found");
return -DokanNet.ERROR_FILE_NOT_FOUND;
}
catch (PathTooLongException ex)
{
_Log.Error("Path too long " + filename, ex);
return -DokanNet.ERROR_INVALID_NAME;
}
catch (IOException ex)
{
_Log.Error("File exists", ex);
return -DokanNet.ERROR_FILE_EXISTS;
}
}

noah

unread,
Dec 3, 2009, 1:12:07 PM12/3/09
to Dokan
After lots and lots of head banging I figured out what the problem is
(and in retrospect I should have tried this before). The problem?
64bit windows. Maybe it's all 64bit, maybe it's just 64bit Windows 7,
but the Dokan driver really sucks in my environment. I tried this
same code in Windows Vista 32bit and it worked fine. It would have
saved me tons of time if I had known that beforehand.

So now that I know what the issue is I'll post a bug report, but
there's a bigger question: should I use Dokan. Can I rely on the fact
that bug fixes will be posted in the next couple months to address the
64bit issues? Because if so I'll develop on my VM and deploy to my
main machine when the fixes are out. If not, there's really no point,
huh?

cleversight

unread,
Dec 3, 2009, 1:51:04 PM12/3/09
to Dokan
Have you tested http://dokan-dev.net/wp-content/uploads/dokan-0401223x64.zip
? It's the 64 bits version of dokan.
Let me know if it works.

noah

unread,
Dec 4, 2009, 9:37:30 AM12/4/09
to Dokan
That's what I've been using. I doubt the 32bit driver would work at
all on 64bit Windows.

I did have to run my app (which mounts the drive) in 32bit mode
because otherwise the app couldn't find dokan.dll.


On Dec 3, 1:51 pm, cleversight <nfigles...@gmail.com> wrote:
> Have you testedhttp://dokan-dev.net/wp-content/uploads/dokan-0401223x64.zip
Reply all
Reply to author
Forward
0 new messages