LocalInfileRequestPacket.js 609 B

123456789101112131415161718192021
  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. };