Commit c4381b6
Check if the folder is writable
Changed files (4)
modifiedlibbirdfont/ExportTool.valamodifiedlibbirdfont/ExportUtils.valamodifiedlibbirdfont/OpenFontFormat/PostTable.valamodifiedresources/linux/birdfont-export.1
Diff
@@ -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;+ } } }@@ -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 ()) {@@ -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 ();@@ -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