createFile method
void
createFile(})
override
Creates an empty file at path
.
If errorIfAlreadyExists
is set to true, and a file already exists at
path
, a FileSystemException is thrown.
Implementation
@override
void createFile(String path,
{bool errorIfNotExists = false, bool errorIfAlreadyExists = false}) {
final type = _recognizeType(path);
if (type == null) {
throw ArgumentError.value(
path,
'path',
'Invalid path for OPFS file system, only ${FileType._validNames} are '
'supported!',
);
} else {
_metaHandle.read(_existsList, FileSystemReadWriteOptions(at: 0));
final exists = _existsList[type.index] != 0;
if ((exists && errorIfAlreadyExists) || (!exists && errorIfNotExists)) {
throw FileSystemException();
}
if (!exists) {
_markExists(type, true);
_files[type]!.truncate(0);
}
}
}