From 7556967bf57453d412a8f18633599f38806f8620 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Sun, 4 Oct 2015 13:00:51 +0200 Subject: Imported Upstream version 0.6.7 --- src/utilities/paths.vala | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/utilities/paths.vala') diff --git a/src/utilities/paths.vala b/src/utilities/paths.vala index 96bce0a..7bdd642 100644 --- a/src/utilities/paths.vala +++ b/src/utilities/paths.vala @@ -107,6 +107,28 @@ public class Paths : GLib.Object { public static string executable { get; private set; default=""; } + ///////////////////////////////////////////////////////////////////// + /// Deletes a directory recursively from disk. Use with care :) + ///////////////////////////////////////////////////////////////////// + + public static void delete_directory(string directory) { + try { + var d = Dir.open(directory); + string name; + while ((name = d.read_name()) != null) { + string path = Path.build_filename(directory, name); + if (FileUtils.test(path, FileTest.IS_DIR)) { + delete_directory(path); + } else { + FileUtils.remove(path); + } + } + DirUtils.remove(directory); + } catch (Error e) { + warning (e.message); + } + } + ///////////////////////////////////////////////////////////////////// /// Initializes all values above. ///////////////////////////////////////////////////////////////////// -- cgit v1.2.3