[rygel] core: Make sure autostart dir exists
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [rygel] core: Make sure autostart dir exists
- Date: Thu, 19 Nov 2009 13:58:58 +0000 (UTC)
commit 716e0ec379436019621a0837df32f45d1f7e40f0
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Wed Nov 18 18:14:05 2009 +0200
core: Make sure autostart dir exists
Make sure autostart dir exists before attempting to write to it.
src/rygel/rygel-user-config.vala | 20 +++++++++++++++-----
1 files changed, 15 insertions(+), 5 deletions(-)
---
diff --git a/src/rygel/rygel-user-config.vala b/src/rygel/rygel-user-config.vala
index 643916e..d778182 100644
--- a/src/rygel/rygel-user-config.vala
+++ b/src/rygel/rygel-user-config.vala
@@ -290,12 +290,14 @@ public class Rygel.UserConfig : GLib.Object, Configuration {
}
private void enable_upnp (bool enable) {
- var dest_path = Path.build_filename (Environment.get_user_config_dir (),
- "autostart",
- "rygel.desktop");
- var dest = File.new_for_path (dest_path);
-
+ var dest_dir = Path.build_filename (Environment.get_user_config_dir (),
+ "autostart");
try {
+ this.ensure_dir_exists (dest_dir);
+
+ var dest_path = Path.build_filename (dest_dir, "rygel.desktop");
+ var dest = File.new_for_path (dest_path);
+
if (enable) {
uint32 res;
@@ -333,5 +335,13 @@ public class Rygel.UserConfig : GLib.Object, Configuration {
err.message);
}
}
+
+ private void ensure_dir_exists (string dir_path) throws GLib.Error {
+ var dir = File.new_for_path (dir_path);
+
+ try {
+ dir.make_directory (null);
+ } catch (IOError.EXISTS err) { /* Thats OK */ }
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]