feat(core): micropython 板卡文件管理 右键菜单添加 上传 和 下载 选项
This commit is contained in:
@@ -54,12 +54,16 @@ class AmpyFS extends FS {
|
||||
return [error, stdout];
|
||||
}
|
||||
|
||||
async readFile(filePath) {
|
||||
async readFile(filePath, encoding = 'utf8') {
|
||||
let stdout = '', error = null;
|
||||
try {
|
||||
const output = await this.#ampy_.get(this.#port_, this.#baud_, filePath);
|
||||
stdout = output.stdout;
|
||||
stdout = this.#decoder_.decode(this.#ampy_.unhexlify(stdout));
|
||||
if (encoding = 'utf8') {
|
||||
stdout = this.#decoder_.decode(this.#ampy_.unhexlify(stdout));
|
||||
} else {
|
||||
stdout = this.#ampy_.unhexlify(stdout);
|
||||
}
|
||||
} catch (e) {
|
||||
error = e;
|
||||
Debug.error(error);
|
||||
@@ -71,6 +75,9 @@ class AmpyFS extends FS {
|
||||
let stdout = '', error = null;
|
||||
try {
|
||||
const startFilePath = path.join(Env.clientPath, 'temp/temp');
|
||||
if (data.constructor.name === 'ArrayBuffer') {
|
||||
data = Buffer.from(data);
|
||||
}
|
||||
await fs_extra.outputFile(startFilePath, data);
|
||||
const output = await this.#ampy_.put(this.#port_, this.#baud_, startFilePath, filePath);
|
||||
stdout = output.stdout;
|
||||
|
||||
Reference in New Issue
Block a user