Advertisement
Guest User

wipe

a guest
May 6th, 2015
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.16 KB | None | 0 0
  1. --The program still does not work.
  2. --Made by Dimon6,
  3.  
  4. --input[1] will be the path.
  5. local input = { ... }
  6.  
  7. ---------------------------------------
  8. --This part checks if the parameter passed is a string
  9.  
  10. function isValidPath(path)
  11.   if fs.exists(path) == true and fs.isDir(path) == false and fs.isReadOnly(path) == false then
  12.     return true
  13.   else
  14.     return false
  15.   end
  16. end
  17. --End of function isValidPath()
  18.  
  19. ------------------------
  20.  
  21. if #input > 1 or #input == 0 then
  22.   print("Invalid number arguments.You must enter only the path of the file you with to wipe.");
  23.  
  24. elseif #input == 1 and isValidPath(input[1]) == true then
  25.  
  26.   local size = fs.getSize(input[1]);
  27.  
  28.   --Set to 4 passes.
  29.   for k=1,4,1 do
  30.     local file = fs.open(input[1], "wb");
  31.  
  32.     --The file will always be overwritten with
  33.     --same size.
  34.     for i=1,size,1 do
  35.  
  36.       local num = math.random();
  37.    
  38.       file.write(math.random(0x00,0xFF));
  39.    
  40.       sleep(0.1);
  41.     end
  42.  
  43.     file.close();
  44.   end
  45.   fs.delete(input[1]);
  46.   print("Finished");
  47.  
  48. elseif isValidPath(input[1]) == false then
  49.   print("The path is not valid or it might be read only.");
  50. end
  51. --End of program
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement