emojicode / emojicode

πŸ˜€πŸ˜œπŸ”‚ World’s only programming language that’s bursting with emojis

Home Page:https://emojicode.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Get directory contents using β—πŸ“‚ filesπŸ“‘

joeskeen opened this issue Β· comments

⭐️ Proposed change

Introduce a new method for getting a list of files in a given directory.

Parameters:

  • directoryPathπŸ”‘

Returns:

πŸ¨πŸšπŸ”‘πŸ†

πŸ€” Rationale

The πŸ“‘ can do the following:

  • create directory
  • delete file
  • delete directory (empty or non-empty)
  • create symbolic link
  • test for file existence (optionally checking for read, write, execute)
  • get file size
  • resolve absolute path

Yet there is no way to determine what files and/or folders exist in a folder without knowing their names.

πŸ•Ί Example

πŸ“‚πŸ‡πŸ“‘ πŸ”€~πŸ”€ ❗ ➑️ dirContents
πŸ”‚ item dirContents πŸ‡
  πŸ˜€ item ❗
πŸ‰

Outputs something like:

Documents
Downloads
Pictures
Videos

Do you see this as recursively searching, or just finding the top files in the directory?

I was thinking the equivalent of readdir in NodeJS, which just does one level deep. If we had that, we could implement our own recursive operation, but right now it's just not possible with the files package.

commented

I agree this would be very useful. Feel free to open a pull request.