dokan-dev / dokany

User mode file system library for windows with FUSE Wrapper
http://dokan-dev.github.io
5.31k stars 668 forks source link

C example #33

Closed Kleak closed 9 years ago

Kleak commented 9 years ago

Is there a C example somewhere because i would like to port dokan in another high-level language but i can't find example :/

thanks

sherter commented 9 years ago

That would be mirror.c ...

Liryna commented 9 years ago

What do you mean by port dokan in another high-level language ? Wrapping dokan api like https://github.com/dokan-dev/dokan-dotnet for C# ?

Or mirror.c like @sherter told :+1:

Kleak commented 9 years ago

It's for wrapping dokan api :)

Liryna commented 9 years ago

https://github.com/dokan-dev/dokany/wiki/API#api-wrapping

Kleak commented 9 years ago

And you don't have a example how to use dokan in C.

Liryna commented 9 years ago

mirror.c is a simple example of dokan in C using the C API.

Kleak commented 9 years ago

ok I think i can close this thread if i have question i will re-open it :) thanks

Kleak commented 9 years ago

I have installed the latest release but when i launch mirror.exe nothings happen, is it normal?

Liryna commented 9 years ago

No, What is the command line that you are using ? could you give us more informations ?

Kleak commented 9 years ago

oups i have found sorry :) i haven't seen that mirror.exe need some parameters

Kleak commented 9 years ago

I really don't know where start to wrap dokan so if you can take a look :) Actually the drive appear and disappear instantly because the vm is stopped but i don't know why :/

https://github.com/Rollercops/Dart-Dokany

thanks a lot

Liryna commented 9 years ago

Could you give us more informations ? "the vm is stopped" do you mean that DokanStart return ? what is the return value ? Have you enabled debug output ? What is the result ?

It looks like you have only implement one DokanOperation.

Please look at https://github.com/dokan-dev/dokany/wiki/API If you see something missing please tell me and I will add it.

Mirror.c is enough to understand how dokan work and with the different wrapper as exemples, it is going to be very easy.

Kleak commented 9 years ago

yes i have implement only one DokanOperation because i have try in c to just malloc an empty structure and the disk appear until i Ctrl+C the program so i would like, for the beginning just start correctly and after implement all the operation.

If i put 0 in the variable ThreadCount DokanStart (so DokanMain because DokanStart return value is the value that DokanMain return) is -6 (DOKAN_MOUNT_POINT_ERROR). and if i put 1 in the variable ThreadCount the program create the drive and crash after, and sometime crash windows entirely (aka bluescreen)

Debug mode is enable but nothing appear on the output when I put something else than 0 in ThreadCount

Liryna commented 9 years ago

https://github.com/dokan-dev/dokany/blob/master/dokan/dokan.c#L142 You should begin to make it work with 1.

https://github.com/dokan-dev/dokany/blob/22cf77c32594ec74e12038e9bc470e57524b8e9e/dokan/dokan.c#L111 If your CreateFile fail, you will get this error.

There is no default routine for the operations, so if you do not implement them, it is normal that it doesn't work.

Kleak commented 9 years ago

It don't work but the drive appear in the explorer for the moment i just want this happen :)

This launch with : dokanOptions->Version 730 dokanOptions->ThreadCount 1 dokanOptions->Options 11 dokanOptions->GlobalContext 0 dokanOptions->MountPoint m

I have this return value : Mount point error

It's at me to implement CreateFile?

Liryna commented 9 years ago

https://github.com/Rollercops/Dart-Dokany/blob/master/example/extension.dart#L10 Try to simply implement all Operations and simplify print the name of functions called.

It's at me to implement CreateFile? Your dart wrapper no, but the example that use your wrapper, yes. As Mirror.c does with the C API!

Kleak commented 9 years ago

So CreateFile is part of dokan operations?

Liryna commented 9 years ago

https://github.com/dokan-dev/dokan-java/blob/master/src/main/java/com/github/dokandev/dokanjava/DokanOperations.java#L24 https://github.com/dokan-dev/dokan-delphi/blob/master/Mirror.dpr#L704 https://github.com/dokan-dev/dokan-dotnet/blob/master/DokanNet/DokanOperationProxy.cs#L13

https://github.com/dokan-dev/dokany/wiki/API#how-to-create-your-file-systems

Please.

Private joke: OK, l'année à l'international on glande pendant 1 an, mais ce n'est pas une excuse pour oublier ce que tu as appris pendant les piscines ! :smile:

Kleak commented 9 years ago

ahah I didn't forget !

Mais je vois pas ce que ca à avoir avec ceci ?

Kleak commented 9 years ago

I have implement all the dokan operation in my .cc file and i have the same problem DokanMain return DOKAN_MOUNT_POINT_ERROR

Kleak commented 9 years ago

found ^^ After my drive start correctly what is the best way? to do inside the dokan operations function call the dart methods? or there is a better way?

Liryna commented 9 years ago

About your wrapper, dokan operations should stay abstract and force the user to implement it. When the drive start correctly, it should call every endpoint of your wrapper (CreateFile, Cleanup, close,...). You probably want that Dart C code forwards the operation to javascript no ?

Kleak commented 9 years ago

No. I have, not for the moment after, to abstract all the thinks because i need the same things on linux (with fuse) and macos (with osxfuse). So the best way will be implement all the things in dart and less as possible in C?

suy commented 9 years ago

I've been doing my application with Dokan and OSXFUSE at the same time, and it's not an easy task. They have different semantics for some thing (e.g., in Dokan, CreateDirectory implies creating a directory and opening a file handle, while in FUSE the mkdir operation just creates it).

Look at things one step at a time. Understand the Dokan API first. Try to create a simple file system where everything is in memory or hardcoded in the application (there is a "hello world" example for FUSE that fakes a file system with just one file hardcoded, and is really simple: very few operations are needed).

Later on you can read how other bindings for FUSE or Dokan are done. Oh, and there is also the dokan-fuse bridge, but I haven't tried how well it works.

Kleak commented 9 years ago

Thanks, i will begin with Dokan and after try to add fuse in my library