private void Delete(string directory, GLib.IFile dir, bool recursive) { if (!dir.Exists) { return; } if (dir.QueryFileType(FileQueryInfoFlags.NofollowSymlinks, null) != FileType.Directory) { return; } // If native, use the System.IO recursive delete if (dir.IsNative && !DisableNativeOptimizations) { System.IO.Directory.Delete(directory, recursive); return; } if (recursive) { foreach (string child in GetFiles(dir, false)) { FileFactory.NewForUri(child).Delete(); } foreach (string child in GetDirectories(dir, false)) { Delete(child, GetDir(child, true), true); } } dir.Delete(); }
public DemuxVfs(string path) { file = path.StartsWith ("/") ? FileFactory.NewForPath (path) : FileFactory.NewForUri (path); if (file.Exists) { using (var info = file.QueryInfo ("etag::value,access::can-read,access::can-write", FileQueryInfoFlags.None, null)) { IsReadable = info.GetAttributeBoolean ("access::can-read"); IsWritable = info.GetAttributeBoolean ("access::can-write"); } } }
public DemuxVfs(string path) { file = path.StartsWith("/") ? FileFactory.NewForPath(path) : FileFactory.NewForUri(path); if (file.Exists) { using (var info = file.QueryInfo("etag::value,access::can-read,access::can-write", FileQueryInfoFlags.None, null)) { IsReadable = info.GetAttributeBoolean("access::can-read"); IsWritable = info.GetAttributeBoolean("access::can-write"); } } }
static void Main () { Gtk.Application.Init (); file = FileFactory.NewForUri (new Uri ("smb://[email protected]/myshare/test")); Window w = new Window ("test"); operation = new Gtk.MountOperation (w); Button b = new Button ("Mount"); b.Clicked += new System.EventHandler (HandleButtonClicked); b.Show (); w.Add (b); w.Show (); Gtk.Application.Run (); }
static void Main() { Gtk.Application.Init(); file = FileFactory.NewForUri(new Uri("smb://[email protected]/myshare/test")); Window w = new Window("test"); operation = new Gtk.MountOperation(w); Button b = new Button("Mount"); b.Clicked += new EventHandler(HandleButtonClicked); b.Show(); w.Add(b); w.Show(); Gtk.Application.Run(); }
private IEnumerable <SafeUri> GetDirectories(GLib.IFile dir, bool followSymlinks) { var enumerator = dir.EnumerateChildren("standard::type,standard::name", followSymlinks ? FileQueryInfoFlags.None : FileQueryInfoFlags.NofollowSymlinks, null); foreach (FileInfo file in enumerator) { if ((file.FileType & FileType.Directory) != 0) { var ret = new SafeUri(System.IO.Path.Combine(dir.Path, file.Name), false); file.Dispose(); yield return(ret); } else { file.Dispose(); } } if (!enumerator.IsClosed) { enumerator.Close(null); enumerator.Dispose(); } }
static void start_import(Gtk.FileChooserButton widget) { string type = widget.Title; string path = widget.Filename; GLib.IFile old = GLib.FileFactory.NewForPath(path); GLib.IFile news = GLib.FileFactory.NewForPath("./gtml" + old.Basename); GLib.KeyFile programs = new GLib.KeyFile(); if (GLib.FileFactory.NewForPath("./data/programs.gkf").Exists) { programs.LoadFromFile("./data/programs.gkf", gkfflags); } if (type.Equals("Full")) { old.Move(news, fcflags, null, null); GLib.FileFactory.NewForPath(news.Path + "/profile").MakeDirectoryWithParents(null); create_stacks(news.Basename, news.Path); } else if (type.Equals("Partial")) { /* * g_file_copy (old, new,cflags,NULL,NULL,NULL,NULL); * GFileEnumerator *ennew = g_file_enumerate_children (old,"*",G_FILE_QUERY_INFO_NONE,NULL,NULL); * while (TRUE) { * GFile *out; * GFileInfo *info; * if (!g_file_enumerator_iterate(ennew,&info,&out,NULL,NULL)) { * g_object_unref(ennew); * break; * } else { * if (!info) break; * gchar *name = g_file_info_get_attribute_as_string (info,G_FILE_ATTRIBUTE_STANDARD_NAME); * if ((g_strcmp0(name,".") && g_strcmp0(name,"..")) && name[0] != '.') { * gchar *path = g_file_get_path (out); * GString *n = g_string_new (name); * if (g_file_test(path,G_FILE_TEST_IS_DIR)){ * * if (!gtk_stack_get_child_by_name (GTK_STACK(stack),n->str)) { * g_print("%s\n",n->str); * //gtk_stack_add_titled (GTK_STACK(stack),create_tabs(),n->str,n->str); * } * //gtk_stack_set_visible_child_name (GTK_STACK(stack),n->str); * } * } * } * if (!info) break; * } * g_file_make_directory_with_parents (g_file_new_for_path(g_strdup_printf("%s/profile",g_file_get_path(new))),NULL,NULL); */ } else if (type.Equals("Link")) { programs.SetString("Programs", old.Basename, old.Path); GLib.FileFactory.NewForPath(news.Path + "/profile").MakeDirectoryWithParents(null); create_stacks(old.Basename, old.Path); } programs.Save("./data/programs.gkf"); /* * GNotification *inotification = g_notification_new ("Import Complete"); * g_notification_set_priority (inotification,G_NOTIFICATION_PRIORITY_NORMAL); * ... Data was here ... * g_notification_set_body (inotification,g_strdup_printf ("The %s import of the file located at %s is now complete.\nReturn to Mozilla Launcher to secure and launch it.", type,path)); * g_application_send_notification (G_APPLICATION(app),"import-complete",inotification); */ }
static void gtml_reload() { GLib.IFile applications = GLib.FileFactory.NewForPath("./gtml"); GLib.KeyFile programs = new GLib.KeyFile(); bool load = false; if (GLib.FileFactory.NewForPath("./data").Exists) { if (GLib.FileFactory.NewForPath("./data/programs.gkf").Exists) { load = programs.LoadFromFile("./data/programs.gkf", gkfflags); } } else { GLib.FileFactory.NewForPath("./data").MakeDirectoryWithParents(null); } if (load == true) { if (programs.HasGroup("Programs")) { string[] names = programs.GetKeys("Programs"); int x = 0; while (names[x].Equals("") != true || names[x] != null) { string location = programs.GetString("Programs", names[x]); create_stacks(names[x], location); location = null; x++; break; } } else { System.Console.WriteLine("No linked programs in data."); } } else { System.Console.WriteLine("No linked programs\n"); } GLib.FileEnumerator apps = applications.EnumerateChildren("*", feflags, null); while (true) { GLib.FileInfo info = apps.NextFile(); if (info == null) { apps.Dispose(); break; } else { GLib.IFile outf = applications.GetChildForDisplayName(info.DisplayName); string name = info.DisplayName; if ((name.Equals(".") && name.Equals("..")) == false && (name.Length != 0 || name != null)) { string path = outf.Path; if (info.FileType == GLib.FileType.Directory) { create_stacks(name, path); /* * if (!gtk_stack_get_child_by_name (GTK_STACK(stack),path)) { * create_stacks (name,path); * } * * * * */ } } } } if (stack.CurrentPageWidget == null) { ; //gtml_import_full (); } }