-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lv_fs
Some Logic Needs Adjusting for WIN32?
#7432
Comments
I'm also confused about this design, this is how I use it currently. This is my configuration on Windows.
/** API for fopen, fread, etc. */
#define LV_USE_FS_STDIO 1
#if LV_USE_FS_STDIO
#define LV_FS_STDIO_LETTER '/' /**< Set an upper cased letter on which the drive will accessible (e.g. 'A') */
#define LV_FS_STDIO_PATH "" /**< Set the working directory. File/directory paths will be appended to it. */
#define LV_FS_STDIO_CACHE_SIZE 4096 /**< >0 to cache this number of bytes in lv_fs_read() */
#endif A feasible way
Is there a better way to do this without adding the |
Seems like we didn't think about Windows drive names conflicting with LVGL virtual drive letters. Does it work to set
Be careful that the dependents of
Linux and Mac don't use drive letters :-). I can't think of any platforms other than Windows that use drive letters. LVGL interprets a leading If you were to make the modification in your proposal and make @cheungxiongwei that looks correct to me. Does it work? You're using LVGL's support for " |
It just occurred to me what the problem is here. I see that you have to do what cheungxiongwei did or else you cannot access different Windows drives with the win32 driver. At least there is a way to do it: cheungxiongwei's method. Edit: You can also make the drive letter a normal letter like |
@liamHowatt @cheungxiongwei My LV_FS_WIN32_LETTER is left at its default Another thought is if the
call-back passed the whole The more natural solution seems to be to NOT REMOVE the drive letter from the path in the
should not CHANGE the path, but only capture the drive letter. The only burning question left is what was the designer's original design intention for Kind regards, |
To your point here, that calls for the DIFFERENCE in behavior then to ONLY be in the
Indeed, the design intention for that also should come into play, since it appears to be intended to be an "access limiter" for the Edit:
I feel hesitant about that not knowing what a "virtual drive letter" is, but.... Perhaps this will help clarify: What Windows (and DOS) does is that it keeps this data relationship: Default DRIVE goes somewhere in the execution environment (not an environment variable, but certainly part of the environment), and then each DRIVE in the environment has its own default directory and remembers it. So you can be on drive E: and issue these commands:
and your current working directory is still the same directory on E, but the default directories on C: and D: did change, so when you do this:
your new current working directory is now: |
You should be getting an error. It's an error to set the drive letter to something other than lvgl/src/libs/fsdrv/lv_fs_win32.c Lines 21 to 23 in 2209e3a
Lines 4161 to 4162 in 2209e3a
|
Sorry for not describing it clearly. |
Interesting.... I want to say, "Where I can learn about the design intention for Edit: I stand corrected: the |
Okay, so now that I think I understand that these two fields:
are meant to be a letter that represents the entire file system represented by the registered If that is the case, then how to represent a path in the context of
where Am I correct? Either way, please steer me, because these understandings need to be carried into the documentation I am editing. Also, the examples for the Kind regards, |
P.S. I am suspecting the trouble I am having is that I erroneously conflated the meaning of Edit: If this is the case, then it would seem that
should instead both be called "identifier" or "virtual_drive_identifer" or something with a similar concept, or something that would help it to not be confused with Windows/DOS drive letters, would you agree? |
Okay -- I think this is becoming clear now. The correct set of lines for the #if LV_USE_FS_WIN32
lv_file_explorer_open_dir(file_explorer, "Z:C:/");
#if LV_FILE_EXPLORER_QUICK_ACCESS
lv_file_explorer_set_quick_access_path(file_explorer, LV_EXPLORER_HOME_DIR, "Z:C:/Users/Public/Desktop");
lv_file_explorer_set_quick_access_path(file_explorer, LV_EXPLORER_VIDEO_DIR, "Z:C:/Users/Public/Videos");
lv_file_explorer_set_quick_access_path(file_explorer, LV_EXPLORER_PICTURES_DIR, "Z:C:/Users/Public/Pictures");
lv_file_explorer_set_quick_access_path(file_explorer, LV_EXPLORER_MUSIC_DIR, "Z:C:/Users/Public/Music");
lv_file_explorer_set_quick_access_path(file_explorer, LV_EXPLORER_DOCS_DIR, "Z:C:/Users/Public/Documents");
lv_file_explorer_set_quick_access_path(file_explorer, LV_EXPLORER_FS_DIR, "Z:C:/");
#endif
#else
... where So if #if LV_USE_FS_WIN32
lv_file_explorer_open_dir(file_explorer, "/:C:/");
#if LV_FILE_EXPLORER_QUICK_ACCESS
lv_file_explorer_set_quick_access_path(file_explorer, LV_EXPLORER_HOME_DIR, "/:C:/Users/Public/Desktop");
lv_file_explorer_set_quick_access_path(file_explorer, LV_EXPLORER_VIDEO_DIR, "/:C:/Users/Public/Videos");
lv_file_explorer_set_quick_access_path(file_explorer, LV_EXPLORER_PICTURES_DIR, "/:C:/Users/Public/Pictures");
lv_file_explorer_set_quick_access_path(file_explorer, LV_EXPLORER_MUSIC_DIR, "/:C:/Users/Public/Music");
lv_file_explorer_set_quick_access_path(file_explorer, LV_EXPLORER_DOCS_DIR, "/:C:/Users/Public/Documents");
lv_file_explorer_set_quick_access_path(file_explorer, LV_EXPLORER_FS_DIR, "/:C:/");
#endif
#else
... And given these understandings, the (changed) examples are now working. Okay -- I can document that. |
@liamHowatt I updated the statement of the problem and the proposal accordingly. |
Correct.
The part after the
I agree 😅
Updating that name would require a lot of config names to change and I think it would break a lot of projects. I could see it happening in a new major release (v10). That's just my opinion though.
Nice, that looks correct to me. Is everything clear?
RE your new proposal: how exactly do you want to change the examples? I don't know if using these code snippets is a good idea because it's a very niche example. It's on Windows and they use the Windows root as the mount point. |
FYI I think a typical use case is to set I realize this contradicts #7431 (comment) 😆 |
Good morning, Liam! ( @liamHowatt )
Interestingly it turns out that What doesn't work (thankfully) turns out to be an internal field name ( The one weird one that is misleading (leads to wrong train of thought and lost time digging in C code) is the macro name
Good question. Answer: with good, clear documentation and an explanatory comment in the code (since that is what I would need in order to not be led astray or think seeing "C:C:/Users..." is is a bug). There is a block of code that only applies to Windows and so simply inserting the "virtual" drive letters in front of the existing path makes it work, and the comment directs the user to the documentation for more details. Thank YouThank you for hanging in there with me on this one. :-) I appreciate the steering, and it puts it on record that there was something confusing that needed to be remedied. Edit: For whatever reason, your mermaid diagram is working, which makes me wonder if it has something to do with the version of the |
I probably should add this to the documentation.... |
I don't know why but for some reason I thought you wanted to rename Re Kconfig, good catch! Re the clear documentation, looks really solid at a glance! This will help a lot of people 😌 And thank you for not giving up while decrypting the meaning of all the FS details!
I began to fix it and saw it working locally for me too, but not remotely here: https://docs.lvgl.io/master/details/main-components/fs.html Here is my local version of the extension: I believe we can simply do this diff --git a/docs/requirements.txt b/docs/requirements.txt
index 138de0cec..c0774c1ad 100644
--- a/docs/requirements.txt
+++ b/docs/requirements.txt
@@ -10,7 +10,7 @@ sphinxcontrib-htmlhelp
sphinxcontrib-jsmath
sphinxcontrib-qthelp
sphinxcontrib-serializinghtml
-sphinxcontrib-mermaid
+sphinxcontrib-mermaid==0.9.2
sphinx-design
sphinx-rtd-dark-mode
typing-extensions Or I will figure out what's not compliant about my Mermaid code in the latest version and correct it. I think that may be a better approach. |
Good find, sir! Indeed, the one I have here locally is also sphinxcontrib-mermaid v0.9.2.
Let me know if/when you succeed! It will enable me to remove it from a list of things pending. |
I used |
Well done. |
Introduce the problem
The 3 examples in
./examples/others/file_explorer/
use incorrect path strings for the Windows platform, thus causing the examples to fail with run underlv_port_pc_visual_studio
.The Error
lv_file_explorer.*
useslv_fs.*
internally, and so the driver-identifier-letter that it uses to prefix paths was (apparently) confused with the Windows drive letter, and so paths like "C:/Users/Public/Documents" were being passed duringlv_file_explorer
initialization, and if the program happened to be running on a different drive (other than C:), it didn't work because the initial "C:" in the path is in fact a driver-identifier-letter, and what follows it is the path passed to functions likelv_file_explorer_open_dir()
=>show_dir()
=>lv_fs_dir_open()
=>drv->dir_open_cb(drv, resolved_path.real_path)
, which only passed the "/Users/Public/Documents" to the function that actually opens the directory.What they should have been passing is paths that looked like this: "C:C:/Users/Public/Documents" where the initial C is the driver-identifier-letter and the 2nd "C:" is part of the Windows path.
This confusion was probably brought about by the various places in the documentation and code where the driver-identifier-letter was erroneously being called the "drive letter" — which has very different meaning in a Windows, DOS, FAT or FAT32 context.
Proposal
Correct the path strings in the 3
lv_file_explorer
examples, the mis-named code elements that cause confusion in Windows/DOS platform, as well as the mis-named macros in thelv_conf.h
file.The text was updated successfully, but these errors were encountered: