Stream: beginners

Topic: FileMetadata in basic-cli


view this post on Zulip Ben Thomas (enkidatron) (Apr 03 2025 at 14:46):

Hello all! I am trying to query for file metadata using basic-cli, such as size, creation/modified timestamps, permission, and the like. In basic-cli, I see the FileMetadata module (is that the correct noun?), which has some things like bytes : FileMetadata -> U64 where I can get some basic metadata if I had a value of this FileMetadata type. But I don't see how to get such a value. When I search the docs for FileMetadata, I only get this one module with no functions that return this data type. Am I missing something?

view this post on Zulip Anton (Apr 03 2025 at 15:29):

Hi @Ben Thomas (enkidatron),

is that the correct noun?

Yes :)

Am I missing something?

That looks like an oversight, I can take care of that next week. If you're in a hurry, you can use Cmd.

view this post on Zulip Ben Thomas (enkidatron) (Apr 03 2025 at 17:35):

Thanks! No need to rush on my account. I will check out Cmd, thanks for the pointer :)

view this post on Zulip Anton (Apr 12 2025 at 17:27):

I can take care of that next week

I hope to finish this next week.

view this post on Zulip Anton (Apr 19 2025 at 17:49):

File.size_in_bytes! has been merged, I'm working on permissions now.

view this post on Zulip Anton (Apr 23 2025 at 17:07):

File permissions functions have been merged: https://github.com/roc-lang/basic-cli/pull/349

view this post on Zulip Anton (Apr 25 2025 at 18:04):

File.time_accessed!, File.time_modified! and File.time_created! have been merged: https://github.com/roc-lang/basic-cli/pull/350

view this post on Zulip Tobias (Jun 09 2025 at 01:14):

How do I get the names of files in a directory? The documentation for Path.display mentions toStrUsingCharset, but the compiler can't find it.

For that matter, how do I rename a file?

view this post on Zulip Luke Boswell (Jun 09 2025 at 01:33):

Does this help? https://roc-lang.github.io/basic-cli/0.19.0/Dir/#list!

view this post on Zulip Anton (Jun 09 2025 at 09:27):

For that matter, how do I rename a file?

I've made a good first issue to add a function for this.
For now, you can do:

Cmd.exec!("mv", [Path.display(old_path), Path.display(new_path)]) ? |err| RenameCmdFailed(err)

view this post on Zulip Anton (Jun 09 2025 at 09:29):

The documentation for Path.display mentions toStrUsingCharset, but the compiler can't find it.

The documentation needs to be updated, I've added it to my TODO list. Path.display should work for most cases.


Last updated: Jul 05 2025 at 12:14 UTC