[Vala] deleting folders



Hello everyone!

GLib.File provides a 'delete' method to delete files and empty folders.

I need to delete a non empty folder so I thought of a recursive method
like this:

bool remove_directory (string path) {
  bool flag = false;
  var directory = File.new_for_path (path);
  
  var enumerator = directory.enumerate_children (
    FileAttribute.STANDARD_NAME, 0
  );
  
  FileInfo file_info;
  while ((file_info = enumerator.next_file ()) != null) {
    if ((file_info.get_file_type ()) == FileType.DIRECTORY) {
      /*
        What should I do here? 
        How can I get a File from a FileInfo so I can use the 
        'delete' method on it?
      */
    }
  }
  return flag;
}


Best regards,

D.H. Bahr


10mo. ANIVERSARIO DE LA CREACION DE LA UNIVERSIDAD DE LAS CIENCIAS INFORMATICAS...
CONECTADOS AL FUTURO, CONECTADOS A LA REVOLUCION

http://www.uci.cu
http://www.facebook.com/universidad.uci
http://www.flickr.com/photos/universidad_uci



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