diff --git a/library/src/main/ets/FileManager.ts b/library/src/main/ets/FileManager.ts index 215a1673f791a52a9814c1a8d070522e080aed3d..1d2a24e6e39f5707a717166837c7035df38ecef8 100644 --- a/library/src/main/ets/FileManager.ts +++ b/library/src/main/ets/FileManager.ts @@ -78,6 +78,18 @@ class FileManagerClass { if (this._fileMap.has(path)) { return this._fileMap.get(path); } + + let pathDecompose = path.split('/').filter(item => { + return (item !== null) && (item.trim() !== ""); + }); + if (pathDecompose.length > 1) { + pathDecompose.pop() + let createPath = pathDecompose.join(`/`) + if (!fs.accessSync(createPath)) { + fs.mkdirSync(createPath, true) + } + } + const f = fs.openSync(path, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE | fs.OpenMode.APPEND); this._fileMap.set(path, new ManagedFile(f, this.getCachedFiles(path))); return this._fileMap.get(path);