copyFile(fs){
console.log("copyFile!")
let context = getContext(this) as common.UIAbilityContext;
let srcFileDescriptor = context.resourceManager.getRawFdSync('xxx.xx');
//这里填rawfile文件夹下的文件名(包括后缀)
let stat = fs.statSync(srcFileDescriptor.fd)
console.log(`stat isFile:${stat.isFile()}`);
//通过UIAbilityContext获取沙箱地址filesDir,以Stage模型为例
let pathDir = context.filesDir;
console.log("path:",pathDir)
let dstPath = pathDir + "/xxx.xx";
let dest = fs.openSync(dstPath, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE)
let bufsize = 4096
let buf = new ArrayBuffer(stat.size)
let off = 0, len = 0, readedLen = 0
while (len = fs.readSync(srcFileDescriptor.fd, buf, { offset: srcFileDescriptor.offset + off, length: bufsize })) {
readedLen += len
fs.writeSync(dest.fd, buf, { offset: off, length: len })
off = off + len
if ((srcFileDescriptor.length - readedLen) < bufsize) {
bufsize = srcFileDescriptor.length - readedLen
}
}
fs.close(dest.fd)
}