Advertisement
TheOddByte

Hunest

Dec 28th, 2016
454
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.06 KB | None | 0 0
  1. --[[
  2.     [Tool/Patch] Hunest
  3.     @version 1.0, 2016-12-28
  4.     @author TheOddByte
  5. --]]
  6.  
  7.  
  8. local function yield()
  9.     os.queueEvent( "yield" )
  10.     coroutine.yield( "yield" )
  11. end
  12.  
  13. local function fixNesting( sPath )
  14.     local paths = {}
  15.     local name  = fs.getName( sPath )
  16.     local path  = name
  17.     print( "[*] Scanning nested folders.." )
  18.     while fs.exists( fs.combine( path, name ) ) and fs.isDir( fs.combine( path, name ) ) do
  19.         path = fs.combine( path, name )
  20.         table.insert( paths, path )
  21.         yield()
  22.     end
  23.     print( "[*] Scanning done, found " .. tostring( #paths ) .. " nested folder(s)" )
  24.     print( "[*] Deleting.." )
  25.     for i = #paths, 1, -1 do
  26.         fs.delete( paths[i] )
  27.         yield()
  28.     end
  29.     print( "[*] Done :D" )
  30. end
  31.  
  32.  
  33. local function main( ... )
  34.  
  35.     local args = { ... }
  36.     if #args < 1 then
  37.         error( "Usage: hunest <path>", 0 )
  38.     end
  39.  
  40.     local path = args[1]
  41.     if not fs.exists( path ) then
  42.         error( "Path does not exist", 0 )
  43.     end
  44.  
  45.     fixNesting( path )
  46. end
  47.  
  48. main( ... )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement