installBinaryToTempDir function
Installs bytes to temp dir and returns the full path of that file
Implementation
String installBinaryToTempDir(
Uint8List bytes, {
String prefix = '',
suffix = '',
int trial = 0,
}) {
var sha = md5(bytes);
String fileName = prefix + sha + (trial == 0 ? '' : '_$trial') + suffix;
String path = path_path.join(pathOfTempDir, fileName).replaceAll(r'\', '/');
if (!fileExists(path)) {
String uuid = uuidTimeBased();
writeFileBytes('$path.$uuid', bytes);
try {
//dart_io.File('$path.$uuid').renameSync(path);
pathRename('$path.$uuid', path);
} catch (_) {}
}
Uint8List bytes2 = readFileBytes(path);
if (identicalBinaries(bytes, bytes2)) {
return path;
}
return installBinaryToTempDir(
bytes,
prefix: prefix,
suffix: suffix,
trial: trial + 1,
);
}