Jump to content
  • 0

Help...


Misuri

Question

6 answers to this question

Recommended Posts

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

Link to comment
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'))

 

Link to comment
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?

Link to comment
Share on other sites

  • Administrators

@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?

Link to comment
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.

 

Link to comment
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.

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.