Jump to content




How to blacklist certain items


  • You cannot reply to this topic
4 replies to this topic

#1 _removed

  • Members
  • 262 posts

Posted 17 December 2014 - 06:12 PM

Hello everyone,


I've been working on an OS thats going to be published soon but I need some help with fs.delete(). I am making a systemWipe program that wipes all the files and folders on the system but I need to blacklist certain items like the "rom" directory and other things. This is my code so far:

[attachment=2012:postImg.JPG]

I have the blacklist table, but I don't know how to implement it. I was looking at the OneOS blacklist but that never worked and I wanted some help of you guys so I can get this bleedin systemWipe program sorted.

Your most and humble servant,

smigger22

#2 SquidDev

    Frickin' laser beams | Resident Necromancer

  • Members
  • 1,427 posts
  • LocationDoes anyone put something serious here?

Posted 17 December 2014 - 06:28 PM

My suggestion would be to use the blacklist as a lookup stead:

local blacklist = {
  ['rom'] = true,
}

This means you can do this:
for _, file in ipairs(files) do
  if not blacklist[file] and not blacklist['/'..file] then
    fs.delete(file)
  end
end

This will only work if the path exactly the same (so thing/rom will still be deleted).

#3 _removed

  • Members
  • 262 posts

Posted 17 December 2014 - 06:51 PM

Thx SquidDev, been waiting a long time for an answer while working on the other aspects of my OS

#4 MKlegoman357

  • Members
  • 1,170 posts
  • LocationKaunas, Lithuania

Posted 17 December 2014 - 09:18 PM

You should also check if the folder or file you are trying to delete is read-only or not. That actully would save you from trouble adding rom to the whitelist and trying to figure out if there is a disk drive connected.

#5 _removed

  • Members
  • 262 posts

Posted 19 December 2014 - 09:49 PM

Thx for the feedback, the OS will now be published soon!!!





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users