~robru/friends/csv-model-schema

« back to all changes in this revision

Viewing changes to service/src/service.vala

  • Committer: Robert Bruce Park
  • Date: 2013-04-05 01:49:46 UTC
  • Revision ID: robert.park@canonical.com-20130405014946-lxvvwd4uhhrd29oc
Regex is overkill.

Show diffs side-by-side

added added

removed removed

Lines of Context:
77
77
        string[] SCHEMA = {};
78
78
 
79
79
        var file = FileStream.open("/usr/share/friends/model-schema.csv", "r");
80
 
        var find_type = new Regex("([^,]+)$");
81
 
        MatchInfo match_info = null;
82
80
        string line = null;
83
81
        while (true)
84
82
        {
85
83
            line = file.read_line();
86
84
            if (line == null) break;
87
 
            find_type.match(line, 0, out match_info);
88
 
            var match = match_info.fetch(0);
89
 
            if (match != null) SCHEMA += match;
 
85
            SCHEMA += line.split(",")[1];
90
86
        }
 
87
        debug ("Found %u schema columns.", SCHEMA.length);
91
88
 
92
89
        bool schemaReset = false;
93
90