diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2015-10-04 13:00:51 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2015-10-04 13:00:51 +0200 |
commit | 7556967bf57453d412a8f18633599f38806f8620 (patch) | |
tree | b7403b6ac1b5cf5db9462c3ca6d52b973df24819 /src/utilities/paths.vala | |
parent | 16fe2e5d0525422ba6ca5db9e92a93d17caae302 (diff) |
Imported Upstream version 0.6.7upstream/0.6.7
Diffstat (limited to 'src/utilities/paths.vala')
-rw-r--r-- | src/utilities/paths.vala | 22 |
1 files changed, 22 insertions, 0 deletions
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 @@ -108,6 +108,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. ///////////////////////////////////////////////////////////////////// |