if (encoding == "iso-8859-1") {
std::vector<std::uint8_t> data;
latin1::from_utf8(str, data);
- write_file(data.data(), data.size(), location, offset, rewrite);
+ write_file(data.data(), data.size(), location, offset, mode);
+ ReportSuccess(picojson::value{(double)data.size()}, out);
} else { // default: UTF-8
const std::uint8_t* buf = (const std::uint8_t*)str.c_str();
std::size_t len = str.length();
- write_file(buf, len, location, offset, rewrite);
+ write_file(buf, len, location, offset, mode);
+ ReportSuccess(picojson::value{(double)str.size()}, out);
}
} catch (std::runtime_error& e) {
LoggerE("Cannot write to file %s, cause: %s", location.c_str(), e.what());
throw new WebAPIException(WebAPIException.IO_ERR, 'Could not write');
}
can_change_size = true;
- this.position = this.position + args.stringData.length;
+ var written_bytes = native_.getResultObject(result);
+ this.position = this.position + written_bytes;
can_change_size = false;
- this._rewrite = false;
+ this._truncate = false;
}
FileStream.prototype.write = function() {