statLimited method

Future<FileStat> statLimited()

Similar to File.stat, but limits concurrency to the current semaphore limit to reduce excessive parallel I/O operations.

Helps prevent Too many open files errors and mitigates disk contention when multiple files are accessed simultaneously.

Implementation

Future<FileStat> statLimited() async {
  await _semaphore.acquire();
  try {
    return await stat();
  } finally {
    _semaphore.release();
  }
}