@@ -35,6 +35,7 @@ const isWindows = process.platform === 'win32'; |
35 | 35 |
|
36 | 36 | const DEBUG = process.env.NODE_DEBUG && /fs/.test(process.env.NODE_DEBUG); |
37 | 37 | const errnoException = util._errnoException; |
| 38 | +const printDeprecation = require('internal/util').printDeprecationMessage; |
38 | 39 |
|
39 | 40 | function throwOptionsError(options) { |
40 | 41 | throw new TypeError('Expected options to be either an object or a string, ' + |
@@ -584,9 +585,14 @@ fs.openSync = function(path, flags, mode) { |
584 | 585 | return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode); |
585 | 586 | }; |
586 | 587 |
|
| 588 | +var readWarned = false; |
587 | 589 | fs.read = function(fd, buffer, offset, length, position, callback) { |
588 | 590 | if (!(buffer instanceof Buffer)) { |
589 | 591 | // legacy string interface (fd, length, position, encoding, callback) |
| 592 | + readWarned = printDeprecation('fs.read\'s legacy String interface ' + |
| 593 | + 'is deprecated. Use the Buffer API as ' + |
| 594 | + 'mentioned in the documentation instead.', |
| 595 | + readWarned); |
590 | 596 | const cb = arguments[4]; |
591 | 597 | const encoding = arguments[3]; |
592 | 598 |
|
@@ -636,12 +642,17 @@ function tryToStringWithEnd(buf, encoding, end, callback) { |
636 | 642 | callback(e, buf, end); |
637 | 643 | } |
638 | 644 |
|
| 645 | +var readSyncWarned = false; |
639 | 646 | fs.readSync = function(fd, buffer, offset, length, position) { |
640 | 647 | var legacy = false; |
641 | 648 | var encoding; |
642 | 649 |
|
643 | 650 | if (!(buffer instanceof Buffer)) { |
644 | 651 | // legacy string interface (fd, length, position, encoding, callback) |
| 652 | + readSyncWarned = printDeprecation('fs.readSync\'s legacy String interface' + |
| 653 | + 'is deprecated. Use the Buffer API as ' + |
| 654 | + 'mentioned in the documentation instead.', |
| 655 | + readSyncWarned); |
645 | 656 | legacy = true; |
646 | 657 | encoding = arguments[3]; |
647 | 658 |
|
|