Products > Programming

FatFS sorted directory listing, but without needing a large RAM buffer

<< < (5/5)

Thank you all for your ideas.

I don't personally code in JS so have passed this on to the guy doing that part.

I want the JS sorting option to be entirely optional, so the basic project makes no JS assumption in the browser. The reason for this is not trivial; basically it is to make sure that all current and future browsers will function adequately. The product is serving HTTP, not HTTPS, which generates dire warnings to the user, and even if HTTPS the certificate would have to be self signed and that is something browsers increasingly really dislike and emit ever more dire warnings over :) So one day the only clients which will work with such a product may be some oddball stuff.

Or I could have just written the C code to sort the listing in the product, but that is less flexible if you want to sort by name, by size, etc. In most applications there will be only a few files actually so this won't be an issue, but it might be, hence the extra flexibility of client side sorting is probably a good way to do it.

One often finds that the original idea is not all that great and there is a much better way, coming out of a discussion :)

Nominal Animal:

--- Quote from: peter-h on June 28, 2022, 10:52:53 am ---if you want to sort by name, by size, etc.
--- End quote ---
Yup; I personally often do (even in desktop environments I prefer to see folder contents as lists, instead of as icons, if possible), so that's why my C implementation takes a separate sort function pointer.

Note that in the HTML+JS approach I showed, JS support is mandatory, but all JS is embedded in the same HTML file, not as external files.  This makes JS support pretty solid in my experience.  To add plain HTML listing, you need to split the HTML index page into at least three static parts: header, middle, and footer.  I would put these as "hidden" (specially named, filtered out in the file list and file access functions) files in the root directory.  The JS directory entry list would be emitted between header and middle, and the initial HTML table rows between middle and footer (within the <tbody id="listparent"> and </tbody> elements).

It would be very interesting and nice if you could afterwards post a summary of the solution, and the reasons why you ended up with that, and if possible, what you would have done differently if you were to start the project from scratch.  ^-^


[0] Message Index

[*] Previous page

There was an error while thanking
Go to full version