Skip to content

Commit daa5128

Browse files
chore: autopublish 2024-10-09T20:19:52Z
1 parent 9b1f034 commit daa5128

2 files changed

Lines changed: 50 additions & 1 deletion

File tree

docs/library/utils.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ A library of general Lua utility functions.
2323
- [rethrow_placeholder()](#rethrow_placeholder)
2424
- [show_notes_dialog(parent, caption, width, height)](#show_notes_dialog)
2525
- [win_mac(windows_value, mac_value)](#win_mac)
26+
- [split_file_path(full_path)](#split_file_path)
27+
- [eachfile(directory_path)](#eachfile)
2628

2729
### copy_table
2830

@@ -373,3 +375,50 @@ Returns the winval or the macval depending on which operating system the script
373375
| Return type | Description |
374376
| ----------- | ----------- |
375377
| `any` | The windows_value or mac_value based on finenv.UI()IsOnWindows() |
378+
379+
### split_file_path
380+
381+
```lua
382+
utility_functions.split_file_path(full_path)
383+
```
384+
385+
[View source](https://github.com/finale-lua/lua-scripts/tree/refs/heads/master/src/library/utils.lua#L480)
386+
387+
Splits a file path into folder, file name, and extension.
388+
389+
| Input | Type | Description |
390+
| ----- | ---- | ----------- |
391+
| `full_path` | `string` | The full file path in a Lua string. |
392+
393+
| Return type | Description |
394+
| ----------- | ----------- |
395+
| `string` | the folder path always including the final delimeter slash (macOS) or backslash (Windows). This may be an empty string. |
396+
| `string` | the filename without its extension |
397+
| `string` | the extension including its leading "." or an empty string if no extension. |
398+
399+
### eachfile
400+
401+
```lua
402+
utility_functions.eachfile(directory_path)
403+
```
404+
405+
[View source](https://github.com/finale-lua/lua-scripts/tree/refs/heads/master/src/library/utils.lua#L522)
406+
407+
Iterates a file path using lfs and feeds each directory and file name to a function.
408+
The directory names fed to the iterator function always contain path delimeters at the end.
409+
The following are skipped.
410+
411+
- "." and ".."
412+
- any file name starting withn "._" (These are macOS resource forks and can be seen on Windows as well when searching a macOS shared drive.)
413+
414+
Generates a runtime error for plugin versions before RGP Lua 0.68.
415+
416+
@ [recursive)] (boolean) true if subdirectories should always be searched. Defaults to false.
417+
418+
| Input | Type | Description |
419+
| ----- | ---- | ----------- |
420+
| `directory_path` | `string` | the directory path to search, encoded utf8. |
421+
422+
| Return type | Description |
423+
| ----------- | ----------- |
424+
| `function` | iterator function to be used in for loop. |

src/lib/lib/script-data.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)