Compare commits
3 Commits
8e07c4bf66
...
83958f020e
Author | SHA1 | Date | |
---|---|---|---|
83958f020e | |||
9f8b696028 | |||
6aeafe34c3 |
@ -21,6 +21,8 @@ G_DECLARE_DERIVABLE_TYPE(
|
||||
|
||||
EDJournalEntry *ed_journal_entry_new(void);
|
||||
|
||||
EDJournalEntry *ed_journal_entry_new_parse(gchar const *line, GError **error);
|
||||
|
||||
EDErrorCode ed_journal_entry_parse(EDJournalEntry *self,
|
||||
gchar const *line,
|
||||
GError **error);
|
||||
|
@ -45,6 +45,22 @@ EDJournalEntry *ed_journal_entry_new(void)
|
||||
);
|
||||
}
|
||||
|
||||
EDJournalEntry *ed_journal_entry_new_parse(gchar const *line, GError **error)
|
||||
{
|
||||
EDJournalEntry *e = ed_journal_entry_new();
|
||||
return_if_true(e == NULL, NULL);
|
||||
|
||||
EDErrorCode ret = ed_error_internal;
|
||||
|
||||
ret = ed_journal_entry_parse(e, line, error);
|
||||
if (ED_ERROR(ret)) {
|
||||
g_clear_object(&e);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return e;
|
||||
}
|
||||
|
||||
EDErrorCode ed_journal_entry_parse(EDJournalEntry *self,
|
||||
gchar const *line,
|
||||
GError **error)
|
||||
|
@ -209,7 +209,7 @@ static EDErrorCode ed_journal_file_load(EDJournalFile *self,
|
||||
EDJournalFilePrivate *p = ed_journal_file_get_instance_private(self);
|
||||
|
||||
GFile *file = NULL;
|
||||
GFileIOStream *stream = NULL;
|
||||
GFileInputStream *stream = NULL;
|
||||
GDataInputStream *reader = NULL;
|
||||
EDJournalEntry *entry = NULL;
|
||||
GError *e = NULL;
|
||||
@ -219,15 +219,13 @@ static EDErrorCode ed_journal_file_load(EDJournalFile *self,
|
||||
file = g_file_new_for_path(p->filename);
|
||||
goto_if_true(file == NULL, done);
|
||||
|
||||
stream = g_file_open_readwrite(file, NULL, &e);
|
||||
stream = g_file_read(file, NULL, &e);
|
||||
if (stream == NULL) {
|
||||
g_propagate_error(error, e);
|
||||
goto done;
|
||||
}
|
||||
|
||||
reader = g_data_input_stream_new(
|
||||
g_io_stream_get_input_stream(G_IO_STREAM(stream))
|
||||
);
|
||||
reader = g_data_input_stream_new(G_INPUT_STREAM(stream));
|
||||
if (reader == NULL) {
|
||||
goto done;
|
||||
}
|
||||
@ -252,13 +250,12 @@ static EDErrorCode ed_journal_file_load(EDJournalFile *self,
|
||||
g_free(line);
|
||||
line = NULL;
|
||||
linelen = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
entry = ed_journal_entry_new();
|
||||
entry = ed_journal_entry_new_parse(line, NULL);
|
||||
goto_if_true(entry == NULL, done);
|
||||
|
||||
ret = ed_journal_entry_parse(entry, line, NULL);
|
||||
|
||||
g_free(line);
|
||||
line = NULL;
|
||||
linelen = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user