Clone in a terminal:
Commit c4381b6
Johan Mattsson - 2017-09-22T16:09:21+00:00
c4381b6b6e8321ad020bcbd0016f37dff885dbaejohan.mattsson.m@gmail.com

Check if the folder is writable

Changed files (4)

Diff

diff --git a/libbirdfont/ExportTool.vala b/libbirdfont/ExportTool.valaindex 66c2061..01975a2 100644--- a/libbirdfont/ExportTool.vala+++ b/libbirdfont/ExportTool.vala@@ -603,6 +603,23 @@ os.put_string ( 			critical (@"$(e.message)"); 		} 	}+	+	static bool can_write (File folder) {+		File test = get_child (folder, "text.tmp");+		bool writable = false;+		+		try {+			writable = FileUtils.set_contents ((!) test.get_path (), "test");+			+			if (writable) {+				FileUtils.remove ((!) test.get_path ());+			}+		} catch (GLib.Error e) {+			writable = false;+		}+		+		return writable;+	} }  }diff --git a/libbirdfont/ExportUtils.vala b/libbirdfont/ExportUtils.valaindex 151d66a..399eae2 100644--- a/libbirdfont/ExportUtils.vala+++ b/libbirdfont/ExportUtils.vala@@ -17,6 +17,7 @@ static void print_export_help (string[] arg) { 	stdout.printf (t_("Usage:")); 	stdout.printf (arg[0]); 	stdout.printf (" [" + t_("OPTION") + "...] " + t_("FILE") +"\n");+	stdout.printf ("    --filter [CHARACTERS]       " + t_("include only these characters") + "\n");	 	stdout.printf ("-h, --help                      " + t_("print this message") + "\n"); 	stdout.printf ("-o, --output [DIRECTORY]        " + t_("write files to this directory") + "\n"); 	stdout.printf ("-s, --svg                       " + t_("write svg file") + "\n");@@ -28,6 +29,7 @@ static void print_export_help (string[] arg) { public static int run_export (string[] arg) { 	string output_directory = "."; 	string file_name = "";+	string filter_characters = ""; 	bool specific_formats = false;	 	bool write_ttf = false; 	bool write_svg = false;	@@ -44,7 +46,7 @@ public static int run_export (string[] arg) {  	Theme.set_default_colors (); 	BirdFont.current_font = BirdFont.new_font ();-	BirdFont.current_glyph_collection = new GlyphCollection.with_glyph ( '\0', "null");+	BirdFont.current_glyph_collection = new GlyphCollection.with_glyph ('\0', "null"); 	main_window = new MainWindow (); 	 	// FIXME: create a option for this and add structure the log messages@@ -82,7 +84,13 @@ public static int run_export (string[] arg) { 			specific_formats = true; 			continue; 		}-		++		if (arg[i] == "--filter" && i + 1 < arg.length) {+			filter_characters = arg[i + 1];+			i++;+			continue;+		}+				 		if (arg[i].has_prefix ("-")) { 			print_export_help (arg); 			return 1;@@ -124,6 +132,16 @@ public static int run_export (string[] arg) { 		return 1; 	} +	if (filter_characters != "") {+		stdout.printf ("Exporting only  %s\n", filter_characters);++		+		int characters_count = filter_characters.char_count ();+		for (int i = 0; i < characters_count; i++) {+			filter_characters.get_char (filter_characters.index_of_nth_char (i));+		}+	}+ 	directory = File.new_for_path (output_directory); 	 	if (!directory.query_exists ()) {diff --git a/libbirdfont/OpenFontFormat/PostTable.vala b/libbirdfont/OpenFontFormat/PostTable.valaindex b51def3..93b3d24 100644--- a/libbirdfont/OpenFontFormat/PostTable.vala+++ b/libbirdfont/OpenFontFormat/PostTable.vala@@ -1102,8 +1102,6 @@ public class PostTable : OtfTable { 		assert (names.size == 0); 		add_standard_names (); -		print ("Adding post names\n");- 		for (int i = 1; i < glyf_table.glyphs.size; i++) { 			gc = glyf_table.glyphs.get (i); 			g = gc.get_current ();diff --git a/resources/linux/birdfont-export.1 b/resources/linux/birdfont-export.1index bfcefa3..d05e75e 100644--- a/resources/linux/birdfont-export.1+++ b/resources/linux/birdfont-export.1@@ -11,6 +11,9 @@ your computer or deployed on your website. See http://birdfont.org for use cases. .SH OPTIONS .TP 5+\--filter [characters]+Include only these characters+.TP \-h, \--help Print command line options. .TP

Contact

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