LocalInfileRequestPacket.js 609 B

12345678910111213141516171819202122
  1. module.exports = LocalInfileRequestPacket;
  2. function LocalInfileRequestPacket(options) {
  3. options = options || {};
  4. this.filename = options.filename;
  5. }
  6. LocalInfileRequestPacket.prototype.parse = function parse(parser) {
  7. if (parser.parseLengthCodedNumber() !== null) {
  8. var err = new TypeError('Received invalid field length');
  9. err.code = 'PARSER_INVALID_FIELD_LENGTH';
  10. throw err;
  11. }
  12. this.filename = parser.parsePacketTerminatedString();
  13. };
  14. LocalInfileRequestPacket.prototype.write = function write(writer) {
  15. writer.writeLengthCodedNumber(null);
  16. writer.writeString(this.filename);
  17. };