diff options
Diffstat (limited to '7')
-rw-r--r-- | 7/main.pl | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -1,3 +1,6 @@ +% vim set ft=prolog + +:- use_module(library(files)). :- use_module(library(format)). :- use_module(library(lists)). @@ -19,8 +22,31 @@ print_warnings :- ; format("No warnings!~n", []) ). +rm_rf(Dir) :- + directory_files(Dir, Files), + path_segments(Dir, Ps), + rm_rf_files(Ps, Files). + +rm_rf_files(_, []). +rm_rf_files(Parents, [D|Dir]) :- +% format("rm_rf_files Parents=~w, D=~w, Dir=~w~n", [Parents,D,Dir]), + append(Parents, [D], PathS), + path_segments(Path, PathS), + ( directory_exists(Path) -> +% format("down ~s~n", [Path]), + directory_files(Path, Files), +% format("files ~w~n", [Files]), + rm_rf_files(PathS, Files), + format("rmdir ~s~n", [Path]), + delete_directory(Path) + ; format("rm ~s~n", [Path]), + delete_file(Path) + ), + rm_rf_files(Parents, Dir). + main :- bgp:create_firewall, print_warnings, bgp:bird_config(BirdDict), + rm_rf("host_vars"), yaml_write(current_output, BirdDict). |