Skip to content

Commit

Permalink
add creation/modified time/file encoding to attr
Browse files Browse the repository at this point in the history
  • Loading branch information
SInginc committed Aug 25, 2023
1 parent 9b3b21b commit 7997072
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/DfReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,17 @@ class DfReader {
}
}

void setTimestamp(time_t c_time, time_t m_time) {
output_.attr("creation_timestamp") = c_time;
output_.attr("modified_timestamp") = m_time;
}

void setFileEncoding(const char *file_encoding) {
if (file_encoding != NULL && strcmp(file_encoding, "") != 0) {
output_.attr("encoding") = file_encoding;
}
}

void setNote(int note_index, const char *note) {
if (note != NULL && strcmp(note, "") != 0) {
notes_.push_back(note);
Expand Down Expand Up @@ -469,6 +480,8 @@ int dfreader_metadata(readstat_metadata_t *metadata, void *ctx) {
readstat_get_var_count(metadata)
);
((DfReader*) ctx)->setMetadata(readstat_get_file_label(metadata));
((DfReader*) ctx)->setFileEncoding(readstat_get_file_encoding(metadata));
((DfReader*) ctx)->setTimestamp(readstat_get_creation_time(metadata), readstat_get_modified_time(metadata));
return 0;
}

Expand Down

0 comments on commit 7997072

Please sign in to comment.