FileHandle.fromFile constructor

FileHandle.fromFile(
  1. File fp, {
  2. AbstractFileOpenMode openMode = AbstractFileOpenMode.read,
})

Implementation

FileHandle.fromFile(File fp,
    {AbstractFileOpenMode openMode = AbstractFileOpenMode.read})
    : _position = 0,
      _path = "",
      super(openMode) {
  final FileMode fileOpenMode;
  switch (openMode) {
    case AbstractFileOpenMode.read:
      fileOpenMode = FileMode.read;
      break;
    case AbstractFileOpenMode.write:
      fileOpenMode = FileMode.write;
      break;
  }
  _file = fp.openSync(mode: fileOpenMode);
  _length = _file?.lengthSync() ?? 0;
}