Misuri Posted February 26, 2019 Posted February 26, 2019 Help! I need to create a script that will delete the file that the user will select! Thanks in advance!
TopGEOYT Posted March 14, 2019 Posted March 14, 2019 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
CmP Posted February 26, 2019 Posted February 26, 2019 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'))
bukandewa Posted February 26, 2019 Posted February 26, 2019 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?
Administrators Enyby Posted February 26, 2019 Administrators Posted February 26, 2019 @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?
CmP Posted February 26, 2019 Posted February 26, 2019 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.
Misuri Posted February 27, 2019 Author Posted February 27, 2019 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.
Question
Misuri
Help! I need to create a script that will delete the file that the user will select! Thanks in advance!
6 answers to this question
Recommended Posts
Archived
This topic is now archived and is closed to further replies.