Clone in a terminal:
Commit d5afd98
Johan Mattsson - 2014-10-15T12:11:51+00:00
d5afd980f80179b4cd1c41bc9f743724e2f10a42johan.mattsson.m@gmail.com

Fix the drive letter bug on Windows

Changed files (12)

Diff

diff --git a/libbirdfont/BackgroundImage.vala b/libbirdfont/BackgroundImage.valaindex bd626aa..2e9f823 100644--- a/libbirdfont/BackgroundImage.vala+++ b/libbirdfont/BackgroundImage.vala@@ -233,7 +233,7 @@ public class BackgroundImage { 			DirUtils.create ((!) dir.get_path (), 0755); 		} -		dir = font.get_backgrounds_folder ().get_child ("parts");+		dir = get_child (font.get_backgrounds_folder (), "parts"); 		if (!dir.query_exists ()) { 			DirUtils.create ((!) dir.get_path (), 0755); 		}@@ -314,7 +314,7 @@ public class BackgroundImage { 		Font font = BirdFont.get_current_font (); 		File folder = font.get_backgrounds_folder (); 		File original = File.new_for_path (file_name);-		File png_image = folder.get_child (@"full_$((!)original.get_basename ())");+		File png_image = get_child (folder, @"full_$((!)original.get_basename ())"); 		bool converted; 		 		if (png_image.query_exists ()) {diff --git a/libbirdfont/BirdFont.vala b/libbirdfont/BirdFont.valaindex 1a2393f..cc15e43 100644--- a/libbirdfont/BirdFont.vala+++ b/libbirdfont/BirdFont.vala@@ -533,7 +533,7 @@ public class BirdFont { 	 	public static File get_preview_directory () { 		File settings = get_settings_directory ();-		File backup = settings.get_child ("preview");+		File backup = get_child(settings, "preview"); 		 		if (!backup.query_exists ()) { 			DirUtils.create ((!) backup.get_path (), 0755);@@ -543,7 +543,7 @@ public class BirdFont { 	}  	internal static File get_thumbnail_directory () {-		File thumbnails = get_settings_directory ().get_child ("thumbnails");+		File thumbnails = get_child (get_settings_directory (), "thumbnails"); 		 		if (!thumbnails.query_exists ()) { 			DirUtils.create ((!) thumbnails.get_path (), 0755);@@ -576,7 +576,7 @@ public class BirdFont { 		 		home = File.new_for_path (home_path); #endif-		settings = home.get_child ("birdfont");+		settings = get_child(home, "birdfont"); 				 		if (!settings.query_exists ()) { 			DirUtils.create ((!) settings.get_path (), 0755);@@ -587,7 +587,7 @@ public class BirdFont {  	internal static File get_backup_directory () { 		File settings = get_settings_directory ();-		File backup = settings.get_child ("backup");+		File backup = get_child (settings, "backup"); 		 		if (!backup.query_exists ()) { 			DirUtils.create ((!) backup.get_path (), 0755);@@ -619,7 +619,7 @@ void init_logfile () { 		t = new DateTime.now_local (); 		settings = BirdFont.get_settings_directory (); 		s = t.to_string ().replace (":", "_");-		log = settings.get_child (@"birdfont_$s.log");+		log = get_child (settings, @"birdfont_$s.log"); 		 		BirdFont.logstream = new DataOutputStream (log.create (FileCreateFlags.REPLACE_DESTINATION)); 		((!)BirdFont.logstream).put_string ((!) log.get_path ());@@ -685,3 +685,28 @@ public static void warn_if_test (string message) { 	} } +/** Obtain a handle to a file in a folder. */ +public static File get_child (File folder, string file_name) {+	string f;+	string s;+	string n;++	// avoid drive letter problems on windows+	+	n = file_name;+	if (unlikely (BirdFont.win32 && file_name.index_of ("\\") != -1)) {+		warning ("File name contains path separator.");+		n = n.substring (n.last_index_of ("\\")).replace ("\\", "");+	}+	+	f = (!) folder.get_path ();+	s = (BirdFont.win32) ? "\\" : "/"; +	+	if (!f.has_suffix (s)) {+		f += s;+	}+	+	return File.new_for_path (f + n);+}++}diff --git a/libbirdfont/BirdFontFile.vala b/libbirdfont/BirdFontFile.valaindex 53dcc6f..3bc0478 100644--- a/libbirdfont/BirdFontFile.vala+++ b/libbirdfont/BirdFontFile.vala@@ -796,13 +796,13 @@ class BirdFontFile : GLib.Object { 			DirUtils.create ((!) font.get_backgrounds_folder ().get_path (), 0755); 		} 		-		img_dir = font.get_backgrounds_folder ().get_child ("parts");+		img_dir = get_child (font.get_backgrounds_folder (), "parts");  		if (!img_dir.query_exists ()) { 			DirUtils.create ((!) img_dir.get_path (), 0755); 		} 	-		img_file = img_dir.get_child (@"$(file).png");+		img_file = get_child (img_dir, @"$(file).png"); 		 		if (img_file.query_exists ()) { 			return;@@ -1310,11 +1310,11 @@ class BirdFontFile : GLib.Object { 		BackgroundImage img; 		BackgroundImage? new_img = null; 		-		File img_file = font.get_backgrounds_folder ().get_child ("parts");+		File img_file = get_child (font.get_backgrounds_folder (), "parts"); 		 		foreach (Attribute attr in tag.get_attributes ()) { 			if (attr.get_name () == "sha1") {-				img_file = img_file.get_child (attr.get_content () + ".png");+				img_file = get_child (img_file, attr.get_content () + ".png");  				if (!img_file.query_exists ()) { 					warning (@"Background file has not been created yet. $((!) img_file.get_path ())");diff --git a/libbirdfont/BirdFontPart.vala b/libbirdfont/BirdFontPart.valaindex a8d4a07..2a5b4a7 100644--- a/libbirdfont/BirdFontPart.vala+++ b/libbirdfont/BirdFontPart.vala@@ -68,7 +68,7 @@ public class BirdFontPart : GLib.Object{ 			font.background_images.clear ();  			bfp_dir = File.new_for_path (root_directory);-			image_dir = bfp_dir.get_child ("images");+			image_dir = get_child (bfp_dir, "images"); 			copy_backgrounds ((!) image_dir.get_path ());  			foreach (string fn in parts) {@@ -278,6 +278,7 @@ public class BirdFontPart : GLib.Object{ 		File image_dir; 		BackgroundImage bg; 		File found;+		File parts; 		File dest; 		 		image_dir = File.new_for_path (folder);@@ -295,13 +296,14 @@ public class BirdFontPart : GLib.Object{ 				name = info.get_name (); 				 				if (info.get_file_type () == FileType.DIRECTORY) {-					found = image_dir.get_child (name);+					found = get_child (image_dir, name); 					copy_backgrounds ((!) found.get_path ()); 				} 				 				if (name.has_suffix (".png")) {-					found = image_dir.get_child (name);-					dest = font.get_backgrounds_folder ().get_child ("parts").get_child (name);+					found = get_child (image_dir, name);+					parts = get_child (font.get_backgrounds_folder (), "parts");+					dest = get_child (parts, name); 					bg = new BackgroundImage ((!) found.get_path ()); 					bg.create_background_folders (font); 					bg.copy_if_new (dest);@@ -377,11 +379,11 @@ public class BirdFontPart : GLib.Object{ 		if (directory.has_suffix (font.get_full_name ())) { 			bfp_dir = dir; 		} else {-			bfp_dir = dir.get_child (font.get_full_name ());+			bfp_dir = get_child (dir, font.get_full_name ()); 		} 		 		while (bfp_dir.query_exists ()) {-			bfp_dir = dir.get_child (@"$(font.get_full_name ())_$(i)");+			bfp_dir = get_child (dir, @"$(font.get_full_name ())_$(i)"); 			i++; 		} 		@@ -429,9 +431,9 @@ public class BirdFontPart : GLib.Object{ 			info = (!) fi; 			name = info.get_name (); 			if (info.get_file_type () == FileType.DIRECTORY) {-				find_parts ((!) ((!) start.get_child (name)).get_path ());+				find_parts ((!) ((!) get_child (start, name)).get_path ()); 			} else if (name.has_suffix (".bfp")) {-				found = start.get_child (name);+				found = get_child (start, name); 				parts.add ((!) found.get_path ()); 			} 		}@@ -470,7 +472,7 @@ public class BirdFontPart : GLib.Object{ 		File dir; 		 		dir = d;-		dir = dir.get_child (subdir);+		dir = get_child (dir, subdir); 		 		if (!dir.query_exists ()) { 			DirUtils.create ((!) dir.get_path (), 0755);@@ -497,7 +499,7 @@ public class BirdFontPart : GLib.Object{ 			dir = new_subdirectory (dir, subdir2); 		} 				-		file = dir.get_child (name);+		file = get_child (dir, name);  		if (file.query_file_type (0) == FileType.DIRECTORY) { 			throw new FileError.FAILED (@"Can't save font, $name is a directory.");diff --git a/libbirdfont/CutBackgroundTool.vala b/libbirdfont/CutBackgroundTool.valaindex 6d4a078..debeda2 100644--- a/libbirdfont/CutBackgroundTool.vala+++ b/libbirdfont/CutBackgroundTool.vala@@ -217,7 +217,7 @@ class CutBackgroundTool : Tool { 		string fn; 		double wc, hc; 		-		img_dir =  f.get_backgrounds_folder ().get_child ("parts");+		img_dir = get_child (f.get_backgrounds_folder (), "parts");  		if (!img_dir.query_exists ()) { 			if (DirUtils.create_with_parents ((!) img_dir.get_path (), 755) != 0) {diff --git a/libbirdfont/ExportTool.vala b/libbirdfont/ExportTool.valaindex 1bfd762..d14332d 100644--- a/libbirdfont/ExportTool.vala+++ b/libbirdfont/ExportTool.vala@@ -422,7 +422,7 @@ os.put_string ( 		SvgFontFormatWriter fo; 		 		try {-			file = folder.get_child (file_name);+			file = get_child (folder, file_name); 			 			if (file.query_exists ()) { 				file.delete ();diff --git a/libbirdfont/FileDialogTab.vala b/libbirdfont/FileDialogTab.valaindex 31556df..e34db68 100644--- a/libbirdfont/FileDialogTab.vala+++ b/libbirdfont/FileDialogTab.vala@@ -132,7 +132,7 @@ public class FileDialogTab : FontDisplay { 			if (selected_filename == "") { 				action.cancel (); 			} else {-				f = current_dir.get_child (selected_filename);+				f = get_child (current_dir, selected_filename); 				action.file_selected ((!)f.get_path ()); 			} 		});@@ -221,6 +221,7 @@ public class FileDialogTab : FontDisplay { 		double y = 0; 		string selected; 		bool dir = false;+		File f; 		 		selected = ""; @@ -252,7 +253,8 @@ public class FileDialogTab : FontDisplay { 				if (selected == "..") { 					propagate_files ((!)((!)current_dir.get_parent ()).get_path ()); 				} else {-					propagate_files ((!)current_dir.get_child (selected).get_path ());+					f = get_child (current_dir, selected);+					propagate_files ((!) f.get_path ()); 				} 			} 		}diff --git a/libbirdfont/FileTab.vala b/libbirdfont/FileTab.valaindex 44cfe39..8a0b246 100644--- a/libbirdfont/FileTab.vala+++ b/libbirdfont/FileTab.vala@@ -107,7 +107,7 @@ public class FileTab : FontDisplay { 		} 		 		backup_file = BirdFont.get_backup_directory ();-		backup_file = backup_file.get_child (file_name);+		backup_file = get_child (backup_file, file_name); 		load_font ((!) backup_file.get_path ()); 	} 	@@ -120,7 +120,7 @@ public class FileTab : FontDisplay { 		 		try { 			backup_file = BirdFont.get_backup_directory ();-			backup_file = backup_file.get_child (file_name);+			backup_file = get_child (backup_file, file_name); 			if (backup_file.query_exists ()) { 				backup_file.delete ();	 			}@@ -292,7 +292,7 @@ public class FileTab : FontDisplay { 		File thumbnail; 		double u = MainWindow.units; 		-		thumbnail = BirdFont.get_thumbnail_directory ().get_child (backup);+		thumbnail = get_child (BirdFont.get_thumbnail_directory (), backup); 			 		draw_background (cr, allocation, y, color); 		@@ -446,7 +446,7 @@ public class FileTab : FontDisplay { 			enumerator = dir.enumerate_children (FileAttribute.STANDARD_NAME, 0); 			while ((file_info = enumerator.next_file ()) != null) { 				file_name = ((!) file_info).get_name ();-				backup_file = dir.get_child (file_name);+				backup_file = get_child (dir, file_name); 				backup_file.delete (); 			} 		} catch (Error e) {diff --git a/libbirdfont/Font.vala b/libbirdfont/Font.valaindex 9e8ce41..f099a37 100644--- a/libbirdfont/Font.vala+++ b/libbirdfont/Font.vala@@ -153,7 +153,7 @@ public class Font : GLib.Object { 	 	public File get_backgrounds_folder () { 		string fn = @"$(get_name ()) backgrounds";-		File f = BirdFont.get_settings_directory ().get_child (fn);+		File f = get_child (BirdFont.get_settings_directory (), fn); 		return f; 	} @@ -528,7 +528,7 @@ public class Font : GLib.Object { 		File file; 		string backup_file; 		-		new_file = dir.get_child (@"$(name).bf");+		new_file = get_child (dir, @"$(name).bf"); 		backup_file = (!) ((!) new_file).get_path (); 		 		try {@@ -549,7 +549,7 @@ public class Font : GLib.Object { 		string backup_file; 		BirdFontFile birdfont_file = new BirdFontFile (this); -		temp_file = dir.get_child (@"$(name).bf");+		temp_file = get_child (dir, @"$(name).bf"); 		backup_file = (!) ((!) temp_file).get_path (); 		backup_file = backup_file.replace (" ", "_"); 		diff --git a/libbirdfont/Preferences.vala b/libbirdfont/Preferences.valaindex 63959e4..9b5ed16 100644--- a/libbirdfont/Preferences.vala+++ b/libbirdfont/Preferences.vala@@ -104,7 +104,7 @@ public class Preferences { 		}  		printd ("get settings file");-		settings = app_dir.get_child ("settings");+		settings = get_child (app_dir, "settings");  		if (is_null (settings)) { 			warning ("No setting directory.");@@ -158,7 +158,7 @@ public class Preferences { 	public static void save () { 		try { 			File app_dir = BirdFont.get_settings_directory ();-			File settings = app_dir.get_child ("settings");+			File settings = get_child (app_dir, "settings");  			return_if_fail (app_dir.query_exists ()); 		diff --git a/libbirdfont/Preview.vala b/libbirdfont/Preview.valaindex 813bae7..45b15bb 100644--- a/libbirdfont/Preview.vala+++ b/libbirdfont/Preview.vala@@ -38,7 +38,7 @@ public class Preview : FontDisplay { 		Font font = BirdFont.get_current_font (); 		string fn = get_html_file_name (); 		File dir = font.get_folder ();-		File file = dir.get_child (fn);+		File file = get_child (dir, fn); 		 		if (!file.query_exists ()) { 			ExportTool.generate_html_document ((!)file.get_path (), font);				@@ -51,7 +51,7 @@ public class Preview : FontDisplay { 		Font font = BirdFont.get_current_font (); 		string path = get_html_file_name (); 		File dir = font.get_folder ();-		File file = dir.get_child (path);+		File file = get_child (dir, path); 		return file.query_exists (); 	} 	@@ -59,7 +59,7 @@ public class Preview : FontDisplay { 		Font font = BirdFont.get_current_font (); 		string path = get_html_file_name (); 		File dir = font.get_folder ();-		File file = dir.get_child (path);+		File file = get_child (dir, path); 		ExportTool.generate_html_document ((!)file.get_path (), font); 	} @@ -67,7 +67,7 @@ public class Preview : FontDisplay { 		Font font = BirdFont.get_current_font (); 		string path = get_html_file_name (); 		File dir = font.get_folder ();-		File file = dir.get_child (path);+		File file = get_child (dir, path); 		try { 			file.delete (); 		} catch (Error e) {@@ -92,7 +92,7 @@ public class Preview : FontDisplay { 		Font font = BirdFont.get_current_font (); 		string html = get_html_file_name (); 		File dir = font.get_folder ();-		File file = dir.get_child (html);+		File file = get_child (dir, html); 		return "file:///" + (!)	file.get_path (); 	} 	@@ -115,9 +115,9 @@ public class Preview : FontDisplay { 			 			preview_directory = BirdFont.get_preview_directory (); 			-			f_ttf = font.get_folder ().get_child (@"$(font.get_full_name ()).ttf");-			f_eot = font.get_folder ().get_child (@"$(font.get_full_name ()).eot");-			f_svg = font.get_folder ().get_child (@"$(font.get_full_name ()).svg");+			f_ttf = get_child (font.get_folder (), @"$(font.get_full_name ()).ttf");+			f_eot = get_child (font.get_folder (), @"$(font.get_full_name ()).eot");+			f_svg = get_child (font.get_folder (), @"$(font.get_full_name ()).svg");  			if (!f_ttf.query_exists ()) { 				warning ("TTF file does not exist.");diff --git a/libbirdfont/TestCases.vala b/libbirdfont/TestCases.valaindex d76fe24..02916ca 100644--- a/libbirdfont/TestCases.vala+++ b/libbirdfont/TestCases.vala@@ -207,7 +207,7 @@ class TestCases { 			warning ("TTF export failed."); 		} 		-		f = f.get_child (font.get_name () + ".ttf");+		f = get_child (f, font.get_name () + ".ttf"); 		if (!f.query_exists ()) { 			warning ("File does not exist."); 		}@@ -345,7 +345,7 @@ class TestCases { 			DataOutputStream d; 			FileOutputStream? os; 			-			temp_file = BirdFont.get_settings_directory ().get_child ("illustrator_test.svg");+			temp_file = get_child (BirdFont.get_settings_directory (), "illustrator_test.svg"); 			 			if (temp_file.query_exists ()) { 				temp_file.delete ();@@ -439,7 +439,7 @@ class TestCases { 			DataOutputStream d; 			FileOutputStream? os; 			-			temp_file = BirdFont.get_settings_directory ().get_child ("inkscape_test.svg");+			temp_file = get_child (BirdFont.get_settings_directory (), "inkscape_test.svg"); 			 			if (temp_file.query_exists ()) { 				temp_file.delete ();

Contact

Email: johan.mattsson.m@gmail.com
Mastodon: typo.social/@birdfont
GitHub: johanmattssonm
LinkedIn: johan-mattsson-2ab324112