can't reliably use `access' and W_OK
This commit is contained in:
parent
f84f8dbd5d
commit
fbad042178
2 changed files with 3 additions and 8 deletions
9
main.cc
9
main.cc
|
|
@ -253,13 +253,8 @@ int parse_and_report(int argc, char * argv[], char * envp[])
|
|||
// Configure the output stream
|
||||
|
||||
std::ostream * out = &std::cout;
|
||||
if (! config.output_file.empty()) {
|
||||
if (access(config.output_file.c_str(), W_OK) == -1)
|
||||
throw error(std::string("Cannot write output to file '" +
|
||||
config.output_file + "'"));
|
||||
else
|
||||
out = new std::ofstream(config.output_file.c_str());
|
||||
}
|
||||
if (! config.output_file.empty())
|
||||
out = new std::ofstream(config.output_file.c_str());
|
||||
|
||||
// Compile the format strings
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ void quotes_by_script::operator()(commodity_t& commodity,
|
|||
price.parse(buf);
|
||||
commodity.add_price(now, price);
|
||||
|
||||
if (price && ! price_db.empty() && access(price_db.c_str(), W_OK) != -1) {
|
||||
if (price && ! price_db.empty()) {
|
||||
char buf[128];
|
||||
strftime(buf, 127, "%Y/%m/%d %H:%M:%S", localtime(&now));
|
||||
ofstream database(price_db.c_str(), ios_base::out | ios_base::app);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue