mirror of https://github.com/lukechilds/node.git
Browse Source
writeFileSync could exhibit pathological behavior when a buffer could not be written to the file in a single write() call. Also, writeFile was not quite as optimized as it could be.v0.7.4-release
isaacs
14 years ago
committed by
Ryan Dahl
2 changed files with 43 additions and 9 deletions
@ -0,0 +1,30 @@ |
|||||
|
var common = require('../common'); |
||||
|
var join = require('path').join; |
||||
|
var util = require('util'); |
||||
|
var fs = require('fs'); |
||||
|
|
||||
|
var data = [ |
||||
|
'/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAUDBAQEAwUEBAQFBQUGBwwIBwcH', |
||||
|
'Bw8LCwkMEQ8SEhEPERETFhwXExQaFRERGCEYGh0dHx8fExciJCIeJBweHx7/', |
||||
|
'2wBDAQUFBQcGBw4ICA4eFBEUHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4e', |
||||
|
'Hh4eHh4eHh4eHh4eHh4eHh4eHh4eHh7/wAARCAAQABADASIAAhEBAxEB/8QA', |
||||
|
'HwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUF', |
||||
|
'BAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkK', |
||||
|
'FhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1', |
||||
|
'dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXG', |
||||
|
'x8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEB', |
||||
|
'AQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAEC', |
||||
|
'AxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRom', |
||||
|
'JygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOE', |
||||
|
'hYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU', |
||||
|
'1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwDhfBUFl/wk', |
||||
|
'OmPqKJJZw3aiZFBw4z93jnkkc9u9dj8XLfSI/EBt7DTo7ea2Ox5YXVo5FC7g', |
||||
|
'Tjq24nJPXNVtO0KATRvNHCIg3zoWJWQHqp+o4pun+EtJ0zxBq8mnLJa2d1L5', |
||||
|
'0NvnKRjJBUE5PAx3NYxxUY0pRtvYHSc5Ka2X9d7H/9k=']; |
||||
|
|
||||
|
data = data.join('\n'); |
||||
|
|
||||
|
var buf = new Buffer(data, 'base64'); |
||||
|
fs.writeFileSync(join(common.tmpDir, 'test.jpg'), buf); |
||||
|
|
||||
|
util.log('Done!'); |
Loading…
Reference in new issue