[valadoc] mv remove_directory to filehelper.vala



commit 4f45c44111c412be61f9b79be84fa82b63e31723
Author: Florian Brosch <flo brosch gmail com>
Date:   Wed Sep 8 20:33:13 2010 +0200

    mv remove_directory to filehelper.vala

 src/libvaladoc/filehelper.vala |   35 ++++++++++++++++++++++++++++++++++-
 src/valadoc/valadoc.vala       |   31 -------------------------------
 2 files changed, 34 insertions(+), 32 deletions(-)
---
diff --git a/src/libvaladoc/filehelper.vala b/src/libvaladoc/filehelper.vala
index 47fba37..a14f8ae 100755
--- a/src/libvaladoc/filehelper.vala
+++ b/src/libvaladoc/filehelper.vala
@@ -62,8 +62,41 @@ namespace Valadoc {
 		return true;
 	}
 
+	public bool remove_directory (string rpath) {
+		try {
+			GLib.Dir dir = GLib.Dir.open ( rpath );
+			if (dir == null)
+				return false;
+
+			for (weak string entry = dir.read_name(); entry != null ; entry = dir.read_name()) {
+				string path = rpath + entry;
+
+				bool is_dir = GLib.FileUtils.test (path, GLib.FileTest.IS_DIR);
+				if (is_dir == true) {
+					bool tmp = remove_directory (path);
+					if (tmp == false) {
+						return false;
+					}
+				} else {
+					int tmp = GLib.FileUtils.unlink (path);
+					if (tmp > 0) {
+						return false;
+					}
+				}
+			}
+		} catch (GLib.FileError err) {
+			return false;
+		}
+
+		return true;
+	}
+
 	/* cp from valacompiler.vala, ported from glibc */
-	private static string realpath (string name) {
+	private static bool ends_with_dir_separator (string s) {
+		return Path.is_dir_separator (s.offset (s.length - 1).get_char ());
+	}
+
+	public string realpath (string name) {
 		string rpath;
 
 		// start of path component
diff --git a/src/valadoc/valadoc.vala b/src/valadoc/valadoc.vala
index 1c6b73e..77c13e2 100755
--- a/src/valadoc/valadoc.vala
+++ b/src/valadoc/valadoc.vala
@@ -224,37 +224,6 @@ public class ValaDoc : Object {
 		return quit (reporter);
 	}
 
-	private static bool remove_directory (string rpath) {
-		try {
-			GLib.Dir dir = GLib.Dir.open ( rpath );
-			if (dir == null)
-				return false;
-
-			for (weak string entry = dir.read_name(); entry != null ; entry = dir.read_name()) {
-				string path = rpath + entry;
-
-				bool is_dir = GLib.FileUtils.test (path, GLib.FileTest.IS_DIR);
-				if (is_dir == true) {
-					bool tmp = remove_directory (path);
-					if (tmp == false) {
-						return false;
-					}
-				}
-				else {
-					int tmp = GLib.FileUtils.unlink (path);
-					if (tmp > 0) {
-						return false;
-					}
-				}
-			}
-		}
-		catch (GLib.FileError err) {
-			return false;
-		}
-
-		return true;
-	}
-
 	static int main (string[] args) {
 		ErrorReporter reporter = new ErrorReporter();
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]