getFileSize static method

FileResult<int> getFileSize(
  1. String path
)

获取文件大小

Gets the file size

Implementation

static FileResult<int> getFileSize(String path) {
  try {
    final file = File(path);
    if (!file.existsSync()) {
      return const FileResult.failure('File does not exist');
    }
    return FileResult.success(file.lengthSync());
  } catch (e, stack) {
    loge('Failed to get file size for $path: $e\n$stack');
    return FileResult.failure(e.toString());
  }
}