statfs.bfree
文件系统中的空闲块。乘以 statfs.bsize 可得到空闲字节数。
🌐 Free blocks in file system. Multiply by statfs.bsize to get the number
of free bytes.
import { statfs } from 'node:fs/promises';
const stats = await statfs('/');
const freeBytes = stats.bsize * stats.bfree;
console.log(`Free space: ${freeBytes} bytes`);const { statfs } = require('node:fs/promises');
(async () => {
const stats = await statfs('/');
const freeBytes = stats.bsize * stats.bfree;
console.log(`Free space: ${freeBytes} bytes`);
})();