polypush135
I’m looking to learn the File module and was trying to think of a pet project for doing so.
I have a huge dir full of mp3 files that I want to organize.
Given the nature of music Artist → Album → Track.
I figured I would be building a possibly big list of folders and files into memory.
So naturally the first thing that comes to mind is streams.
Is there something like File.ls but for streams?
Or maybe a better question. What kind of limits are there to the number of folders and files that can be made in any one folder on today’s OS systems?
How does File.ls handle large lists in other words?
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #ai
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming











Showing Posts 1 to 6- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
D4no0
I’m not sure about that, however I remember reading something about the possibility of implementing a custom file server, there you should be able to run custom logic.
al2o3cr
I’m not aware of anything built-in, but there’s
erlang-dirent:https://github.com/team-telnyx/erlang-dirent
You’d likely want to wrap this in a module that does a couple things:
translates the input from a binary to a charlist
uses
Stream.resourceetc to produce aStreamof matchestransforms the elements of the stream back into binaries from charlists
polypush135
This is great thank you!
polypush135
Forgive me for the naive question.
If I understand this correctly this lib in short before it gives you a full list of the folders/files it can instead give you the folder/file in question as readdir is reading the thing which I assume is how the filesystem builds the full list in the first place? Thus I could chunck that out via Stream.resource
al2o3cr
Here’s a standalone demo:
Followup thoughts in no particular order:
This uses
:dirent.readdir_typesince the first question that code that consumes the stream is likely to ask is “is this a directory?”The error handling is somewhat inconsistent; a failure in
opendirwill crash but a failure when iterating through the results will put{:error, reason}in the output stream. Your application may have different needs.the situation with filenames that can’t be represented in UTF8 is complicated so this code completely ignores it. That may not be sufficient depending on your specific filesystem.
polypush135
I ran into a little issue compiling to otp 26 and drop backed to 25 and it worked fine.
Something to do with IO something or other at build
Any how this is great and works nicely. Thank you.
I can see myself using this along with flow to do the job I’m looking at.