load method

Future<MemoryFile?> load(
  1. String path
)

Load a specific memory file.

Implementation

Future<MemoryFile?> load(String path) async {
  final file = File(path);
  if (!await file.exists()) return null;

  final content = await file.readAsString();
  final stat = await file.stat();
  final hash = _hashContent(content);

  final type = _inferType(path);
  final memFile = MemoryFile(
    path: path,
    type: type,
    content: content,
    lastModified: stat.modified,
    hash: hash,
  );

  _files[path] = memFile;
  _lastKnownHashes[path] = hash;
  return memFile;
}