| 781 | apps.log([""], output, path); |
| 782 | }, |
| 783 | fileWrapper = function node_apps_base64_fileWrapper(filepath):void { |
| 784 | node |
| 785 | .fs |
| 786 | .stat(filepath, function node_apps_base64_fileWrapper_stat(er:Error, stat:Stats):void { |
| 787 | const angrypath:string = `filepath ${text.angry + filepath + text.none} is not a file or directory.`, |
| 788 | file = function node_apps_base64_fileWrapper_stat_file():void { |
| 789 | node |
| 790 | .fs |
| 791 | .open(filepath, "r", function node_apps_base64_fileWrapper_stat_file_open(ero:Error, fd:number):void { |
| 792 | let buff = Buffer.alloc(stat.size); |
| 793 | if (ero !== null) { |
| 794 | if (http === true) { |
| 795 | apps.remove(filepath); |
| 796 | } |
| 797 | apps.errout([ero.toString()]); |
| 798 | return; |
| 799 | } |
| 800 | node |
| 801 | .fs |
| 802 | .read( |
| 803 | fd, |
| 804 | buff, |
| 805 | 0, |
| 806 | stat.size, |
| 807 | 0, |
| 808 | function node_apps_base64_fileWrapper_stat_file_open_read(erra:Error, bytesa:number, buffera:Buffer):number { |
| 809 | if (http === true) { |
| 810 | apps.remove(filepath); |
| 811 | } |
| 812 | if (erra !== null) { |
| 813 | apps.errout([erra.toString()]); |
| 814 | return; |
| 815 | } |
| 816 | const output = (direction === "decode") |
| 817 | ? Buffer.from(buffera.toString("utf8"), "base64").toString("utf8") |
| 818 | : buffera.toString("base64"); |
| 819 | apps.log([""], output, path); |
| 820 | } |
| 821 | ); |
| 822 | }); |
| 823 | }; |
| 824 | if (er !== null) { |
| 825 | if (http === true) { |
| 826 | apps.remove(filepath); |
| 827 | } |
| 828 | if (er.toString().indexOf("no such file or directory") > 0) { |
| 829 | apps.errout([angrypath]); |
| 830 | return; |
| 831 | } |
| 832 | apps.errout([er.toString()]); |
| 833 | return; |
| 834 | } |
| 835 | if (stat === undefined) { |
| 836 | if (http === true) { |
| 837 | apps.remove(filepath); |
| 838 | } |
| 839 | apps.errout([angrypath]); |
| 840 | return; |