Improve buffer allocation for copying files in utils/filesystem.js

print-window-tiddler
Jermolene 2014-12-18 21:08:14 +00:00
rodzic d2c4920ba4
commit 2abc5dee78
1 zmienionych plików z 5 dodań i 1 usunięć

Wyświetl plik

@ -52,9 +52,13 @@ exports.copyDirectory = function(srcPath,dstPath) {
Copy a file
*/
var FILE_BUFFER_LENGTH = 64 * 1024,
fileBuffer = $tw.node && new Buffer(FILE_BUFFER_LENGTH);
fileBuffer;
exports.copyFile = function(srcPath,dstPath) {
// Create buffer if required
if(!fileBuffer) {
fileBuffer = new Buffer(FILE_BUFFER_LENGTH);
}
// Create any directories in the destination
$tw.utils.createDirectory(path.dirname(dstPath));
// Copy the file