Jump to content
  • 0

LUA API Feature Request - Get/List files of current script directory


Blackn

Question

Hello GG Team,

thank a lot for your great App, it helps a lot, and the Lua API is a very useful Feature to automate the daily tasks 🙂

I have a feature request for the API as i don't see any chance to do it.
I want to get get all files of the directory where the current script is.

For example the script run in this directory:
/storage/0/Notes

and the script name is
myscript.lua

I want to get at the script myscript.lua all files which matches this pattern:
myscript_PluginName1.lua
myscript_PluginName2.lua
myscript_PluginName3.lua

Of course, PluginName can be every name, so there is no way to assume a specific Plugin file exists.

I tried to list files of a directory though lua with os.execute and io.popen, but it's disabled due to security reasons.

Is there a way to get file files a wrote above? If yes, how to do it? If no, can the feature implemented to GG ?

Thank you in advance,

Blackn

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • Administrators
5 minutes ago, Blackn said:

I want to get get all files of the directory where the current script is.

No. Many script writers sleep and see to get a list of files, and then delete all the files there.

[added 2 minutes later]
7 minutes ago, Blackn said:

I want to get at the script myscript.lua all files which matches this pattern:
myscript_PluginName1.lua
myscript_PluginName2.lua
myscript_PluginName3.lua

use some convention for naming files and then check it in loop.

For example always name it as myscript_Plugin_%d.lua

Number unique for each plugin. In script check first 500 numbers. If file exists - load and execute.

Inside file you can store meaningful name on first line as comment. You can read it if you want some human readable name.

 

[added 4 minutes later]

I think 500 plugin it is enough for very long time. If you need more - you can use more later.

If you worried about performance - create some cache file with list found plugins and date last scan. If date less from now on hour or more - rescan plugins.

Link to comment
Share on other sites

Hello Enyby,
thank you for your comments and idea's.

The Plugin can come from other people, not me, and it would be great if the filename of the plugin contains a useful name so if you want to edit a specific plugin you know fast which file to edit.

I understand that GG don't want to list files of any directory due to the script writer could then delete files.

Is it maybe possible to get the files which begin with the same name as the script (without the file-extension .lua)
So if the new function is called at the Main Script:
/storage/0/Notes/Main.lua

it would list this files, and only this:
/storage/0/Notes/Main_residential.lua
/storage/0/Notes/Main_factory.lua

Then GG deny/keeps the security to list any files of a directory with the possibility to get the plugin-files ?

Thank you in advance,
Blackn

Link to comment
Share on other sites

  • Administrators

In this case, it is enough to create files with a single-letter name, or without a name at all, to get a list of all files.

You can design your installation system. Give the user the option to select a file on disk. then write the name of this file in the config and use it.

[added 1 minute later]
2 hours ago, Blackn said:

The Plugin can come from other people, not me, and it would be great if the filename of the plugin contains a useful name so if you want to edit a specific plugin you know fast which file to edit.

You can add special command for list installed plugins and files where it is located.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.