]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
mv remove_directory to filehelper.vala
authorFlorian Brosch <flo.brosch@gmail.com>
Wed, 8 Sep 2010 18:33:13 +0000 (20:33 +0200)
committerFlorian Brosch <flo.brosch@gmail.com>
Wed, 8 Sep 2010 18:33:13 +0000 (20:33 +0200)
src/libvaladoc/filehelper.vala
src/valadoc/valadoc.vala

index 47fba3799874cb654a0e104186d58a7d86eaaaa0..a14f8ae0f83f38d988d850405aa81199d044dad1 100755 (executable)
@@ -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
index 1c6b73ec7d73e72e1f42bed38b29065c057ae97e..77c13e2139ee8df9a225e7e869fd76051a5aa982 100755 (executable)
@@ -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();