dokan-dev / dokany

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

Help | How to implement save in dokan #1229

Closed biplab5464 closed 4 weeks ago

biplab5464 commented 1 month ago

From my understanding of the documentation, it seems that for any save event, the create_file function is called first, followed by the write_file function. However, I’m not clear on the conditions under which the write_file function is invoked.

At present, I’m able to recursively list directories and open files. However, when I attempt to save a file, I encounter an error in VS Code: Failed to save 'test/c': Unable to write file 'm:\test\test.c' (Unknown (FileSystermError): Error: EINVAL: invalid argument, write).

Despite having implemented the write_file function, I’m still facing this issue. As I’m new to Windows development and still familiarizing myself with the Windows API, I’m finding it challenging to understand everything.

I was wondering if anyone could assist me with this issue, perhaps through a platform like Discord or Telegram, instead of creating an issue here. Any help would be greatly appreciated.

Liryna commented 1 month ago

Hi @biplab5464 , I would suggest implementing all dokan operations. Use Procmon to investigate where does the error comes from (create, write ...) and then look at your filesystem logs to determine the error.

You can also try testing tools like 1 and 2 to ensure your filesystem behaves as expected

biplab5464 commented 1 month ago

Logfile.CSV

when create file is called Desired access is : Read Attributes. is it the problem?

Liryna commented 1 month ago

if you execute the same operation on a normal NTFS filesystem, what is the difference ? Looks like all QueryAllInformationFile are failing withBUFFER OVERFLOW.

biplab5464 commented 1 month ago

for every process QueryAllInformationFile is failing with BUFFER OVERFLOW

For normal NTFS some have Read Attributes and some have Generic Read and write attributes and synchronization

biplab5464 commented 1 month ago

I also try implementing delete_file it is also not working, i mean i have unable to see the print statement inside delete_file not showing up in the console

is there is something that this function doesn't print to the console or this function is not being called

biplab5464 commented 1 month ago
                        ================>info<=============
trying to open file \build.rs\rust.rs\test.rtf
desired_access : 128
            file_attributes : 0
            sharePacces : 7
            create_disposition : 3
            create_option : 2097152
            flags_and_attributes; 2097152
            is_dir : false
desired access flags
FILE_READ_ATTRIBUTES access requested
file attribute falgs
FILE_FLAG_OPEN_REPARSE_POINT
open a fle Open existing

this is debug output from the create_file, when it is trying to open \build.rs\rust.rs\test.rtf this path while the acutal path is M:\test\test\test.rtf
while i am trying to safe it is also referring to this path but the file is opened

image

am i doing something wrong here

biplab5464 commented 1 month ago

one unique thing is both build.rs and rust.rs are the first file from after dir listing end

Liryna commented 1 month ago

Please see

biplab5464 commented 1 month ago

Thank you for the help. I am a beginner in Windows development. I have previously worked on Linux, so a lot of this is new to me, but I am making progress.

I am now able to write to a text file and the write_file function is working. However, I am having problems with docx or rtf files.

When I open any file with VS Code or Notepad++, even unsupported files like docx, it opens in the correct path. But with applications like WPS or WordPad, docx or rtf files are not opening in the correct path. image For example, the correct path should be M:\test\test.docx.

The same issue occurs when trying to delete a file. For instance, when I click on the file test.c and try to delete it from the context menu, the prompt asks me to delete build.rs instead." image

Liryna commented 1 month ago

Good progress!

The incorrect path must be due to an incorrect name returned during find files or get file info. Please check what your implementation returns and what the samples are returning (expectation).

Liryna commented 4 weeks ago

@biplab5464 have you been able to make progress? Can this be closed ?

biplab5464 commented 4 weeks ago

i am able to make lots of progress. thank you.

i am still not able to figure out the wrong path in some apps

like for a jpeg file, a file is opening it at the wrong path for windows photo app but at the same time it is opening correctly in vs code or other image viewer

i have looked at find_files and get_file_imformation several times as you have suggested and tweaked it like i have tried several ways to find unique number to file_index but still having the issue

and better we can close the issue and discuss this on some dokan-rust forum or discord.

if something like this exists can you please share it with me. so we can closed this issue

Thank you

biplab5464 commented 4 weeks ago

about the wrong path it is always returning the first file in the directory with alphabetically sort