diff options
author | John Wiegley <johnw@newartisans.com> | 2004-08-19 17:55:33 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2004-08-19 17:55:33 -0400 |
commit | aba3d3037a43f4c244b4065b7fd70a6f1d5656de (patch) | |
tree | eaa48c8cdb91852cd440b0c246f38ed790f7e5ee /binary.cc | |
parent | bf923ab33e9951d25611cb7193d6852e9113d929 (diff) | |
download | fork-ledger-aba3d3037a43f4c244b4065b7fd70a6f1d5656de.tar.gz fork-ledger-aba3d3037a43f4c244b4065b7fd70a6f1d5656de.tar.bz2 fork-ledger-aba3d3037a43f4c244b4065b7fd70a6f1d5656de.zip |
added support for parsing QIF files
Diffstat (limited to 'binary.cc')
-rw-r--r-- | binary.cc | 39 |
1 files changed, 23 insertions, 16 deletions
@@ -92,7 +92,7 @@ void read_binary_amount(std::istream& in, amount_t& amt) transaction_t * read_binary_transaction(std::istream& in, entry_t * entry) { - transaction_t * xact = new transaction_t(entry, NULL); + transaction_t * xact = new transaction_t(NULL); xact->account = accounts[read_binary_number<account_t::ident_t>(in)]; xact->account->add_transaction(xact); @@ -193,9 +193,10 @@ account_t * read_binary_account(std::istream& in, account_t * master = NULL) return acct; } -unsigned int read_binary_journal(std::istream& in, - journal_t * journal, - account_t * master) +unsigned int read_binary_journal(std::istream& in, + const std::string& file, + journal_t * journal, + account_t * master) { ident = 0; c_ident = 0; @@ -204,18 +205,24 @@ unsigned int read_binary_journal(std::istream& in, read_binary_number<unsigned long>(in) != format_version) return 0; - for (unsigned short i = 0, - count = read_binary_number<unsigned short>(in); - i < count; - i++) { - std::string path = read_binary_string(in); - std::time_t old_mtime; - read_binary_number(in, old_mtime); - struct stat info; - stat(path.c_str(), &info); - if (std::difftime(info.st_mtime, old_mtime) > 0) - return 0; - journal->sources.push_back(path); + if (! file.empty()) { + for (unsigned short i = 0, + count = read_binary_number<unsigned short>(in); + i < count; + i++) { + std::string path = read_binary_string(in); + if (i == 0 && path != file) + return 0; + + std::time_t old_mtime; + read_binary_number(in, old_mtime); + struct stat info; + stat(path.c_str(), &info); + if (std::difftime(info.st_mtime, old_mtime) > 0) + return 0; + + journal->sources.push_back(path); + } } journal->master = read_binary_account(in, master); |