-- $LastChangedDate: 2010-05-25 21:26:05 -0400 (Tue, 25 May 2010) $
-- LEGAL: COPYRIGHT (C) 2010 JIM E. BROOKS WWW.PALOMINO3D.ORG
-- Does "make realclean".
-- THIS IS NOT PERFECT.
-- DOS shell provides no delete-with-wildcard
-- so some *.dir subdirs will remain.

if ( (not os.getenv("windir")) and (not os.getenv("ProgramFiles")) ) then
    print( "clean.lua is for Windows and imperfect.  Use clean.sh on UNIX." )
    os.exit(1)
end

function DelFile( file )
    os.execute( "del /q " .. file )
end

function DelDir( dir )
    os.execute( "rmdir /s /q " .. dir )
end

function CleanDir( dir, dir2 )
    local slash = "\\"
    if not dir2 then
        dir2 = ""
        slash = ""
    end
    DelFile( dir .. slash .. dir2 .. "\\*Cache*" )
    DelFile( dir .. slash .. dir2 .. "\\CMakeFiles" )
    DelFile( dir .. slash .. dir2 .. "\\*vcproj*" )
    DelFile( dir .. slash .. dir2 .. "\\*.sln" )
    DelFile( dir .. slash .. dir2 .. "\\cmake_install.cmake" )
    DelFile( dir .. slash .. dir2 .. "\\*.ncb" )
    DelFile( dir .. slash .. dir2 .. "\\Makefile" )
    DelDir(  dir .. slash .. dir2 .. "\\CMakeFiles" )
    DelDir(  dir .. slash .. dir2 .. "\\bin" )
    DelDir(  dir .. slash .. dir2 .. "\\lib" )
    DelDir(  dir .. slash .. dir2 .. "\\ALL_BUILD.DIR" )
    DelDir(  dir .. slash .. dir2 .. "\\DIR ZERO_CHECK.DIR" )
    -- Delete base/base.dir
    -- However some *.dir directories will remain.
    if dir2 ~= "" then
        DelDir(  dir .. slash .. dir2 .. slash .. dir2 .. ".dir" )
    end
end

-- Update clean.sh also.

CleanDir( "." )
CleanDir( "build", "base" )
CleanDir( "build", "collision" )
CleanDir( "build", "control" )
CleanDir( "build", "fx" )
CleanDir( "build", "game" )
CleanDir( "build", "gfx" )
CleanDir( "build", "glue" )
CleanDir( "build", "graph" )
CleanDir( "build", "gui" )
CleanDir( "build", "hud" )
CleanDir( "build", "init" )
CleanDir( "build", "input" )
CleanDir( "build", "lua_bind" )
CleanDir( "build", "lua_lang" )
CleanDir( "build", "math" )
CleanDir( "build", "object" )
CleanDir( "build", "physics" )
CleanDir( "build", "program" )
CleanDir( "build", "shader" )
CleanDir( "build", "sky" )
CleanDir( "build", "sound" )
CleanDir( "build", "threads" )
CleanDir( "build", "view" )
CleanDir( "build", "world" )

-- Update clean.sh also.
