Jump to content
Misuri

Help...

Recommended Posts

Help! I need to create a script that will delete the file that the user will select! Thanks in advance!

Share this post


Link to post
Share on other sites

To ask user to select a file you can use prompt function with "file" type.

Example:

local t = gg.prompt({'Select a file'}, nil, {'file'})

To delete a file you can use remove function from standard operating system library provided by Lua.

Example:

print(os.remove('/storage/emulated/0/Downloads/test.txt'))

 

Edited by CmP

Share this post


Link to post
Share on other sites
1 hour ago, CmP said:

To ask user to select a file you can use prompt function with "file" type.

Example:


local t = gg.prompt({'Select a file'}, nil, {'file'})

To delete a file you can use remove function from standard operating system library provided by Lua.

Example:


print(os.remove('/storage/emulated/0/Downloads/test.txt'))

 

I think os.remove need to confirmation with pop up alert if scripts try to use os.remove to remove any files. Because this function can be used for evil purposes, of course it can be called malicious activity. do you agree with this?

Share this post


Link to post
Share on other sites

@bukandewa

Script create temp file on each run for store some data. After that remove it. And do it 100 times per run. Or 10 times per second. Need confirmation?

Script store some config in file for each run. And now want delete file with that config. Need confirmation?

Evil script want remove file, but know about confirmation. So just open for write and close it. It is truncate file without delete. Confirmation help?

Share this post


Link to post
Share on other sites
39 minutes ago, bukandewa said:

I think os.remove need to confirmation with pop up alert if scripts try to use os.remove to remove any files.

Using similar approach as in Script compiler, it's possible to redefine potentially harmful functions for them to display an alert containing info about passed arguments and options either to allow function execution or not. It can be even extended to simulate successful call to a function, so that if script checks returned result, it will "think" that harmful action has been done successfully. This will allow to examine all potentially harmful actions script tries to perform, because it will not crash/exit after first try of opening/removing a file.

 

Share this post


Link to post
Share on other sites
15 hours ago, CmP said:

To ask user to select a file you can use prompt function with "file" type.

Example:


local t = gg.prompt({'Select a file'}, nil, {'file'})

To delete a file you can use remove function from standard operating system library provided by Lua.

Example:


print(os.remove('/storage/emulated/0/Downloads/test.txt'))

 

Thanks, I understood how to make it so that the user chooses a file, but now I need to make it so that the script deletes the file that the user chooses, and not the one to which the path to be pre-written in the script.

Share this post


Link to post
Share on other sites
On 2/26/2019 at 5:38 PM, Misuri said:

Help! I need to create a script that will delete the file that the user will select! Thanks in advance!

Simple File Remover . not encypted so you can see code (#5eyf9ujq)

It is example of remove file :

local last = gg.getFile()
local info = gg.prompt({'Select a file'},{last}, {'file'})
if info == nil then return end
last = info[1]
os.remove(''..info[1]..'') 
--example : os.remove(/storage/sdcard0/Download/script.lua)
--you can not remove this script using itself

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...