diff --git a/src/Common/Utils.js b/src/Common/Utils.js index ac2c8a6..9b83bd7 100644 --- a/src/Common/Utils.js +++ b/src/Common/Utils.js @@ -1,22 +1,23 @@ import fs from 'fs' import * as path from 'path' -function listFilesRecursively (directory) { +function listFilesRecursively(directory) { let fileList = [] for (const element of directory) { - const fullPath = path.join(element) - const stats = fs.statSync(fullPath) + const fullPath = path.join(element).replace(/\\/g, '/'); + const stats = fs.statSync(fullPath); if (stats.isDirectory()) { - fileList = fileList.concat(listFilesRecursively(fs.readdirSync(fullPath).map(file => path.join(fullPath, file)))) + fileList = fileList.concat(listFilesRecursively(fs.readdirSync(fullPath).map(file => (path.join(fullPath, file)).replace(/\\/g, '/'))); } else if (stats.isFile()) { - fileList.push(fullPath) + fileList.push(fullPath); } } - return fileList + return fileList; } + function calculateBitrate (bytesDownloaded, downloadTimeSeconds) { // Calculate the bitrate in bytes per second const bytesPerSecond = bytesDownloaded / downloadTimeSeconds