Closed 250king closed 1 year ago
what is the use-case? Do you want to set the position (cursor) for modifying a file in a certain index? Do you have any examples of this setPosition
method in other library or project?
I show a example from my code. Maybe you can know my meaning.
static void write(File file, String origin, String replace, int position) {
try {
final io = file.openSync(mode: FileMode.append);
const compare = ListEquality();
final length = origin.length;
io.setPositionSync(position);
final raw = io.readSync(length);
if (!compare.equals(raw, utf8.encode(replace))) {
if (compare.equals(raw, utf8.encode(origin))) {
io.setPositionSync(position);
io.writeFromSync(utf8.encode(replace));
}
}
io.closeSync();
}
// ignore: empty_catches, empty_statements
catch (e) {}
}
A Feature request
I need to usa the setPosition methd to modify some file. But after I refer your API document, I can't find any thing about this. So I give some suggestion here. If writeToFileAsBytes supports setPosition, it will be better.