Release v1.01 Enhanced: Vi Control, TUI Gen5, Core Stability
This commit is contained in:
32
bin/goose-ultra-final/electron/fs-api.js
Normal file
32
bin/goose-ultra-final/electron/fs-api.js
Normal file
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* File System API Bridge
|
||||
*/
|
||||
import fs from 'fs/promises';
|
||||
import path from 'path';
|
||||
|
||||
export const fsApi = {
|
||||
async listFiles(dirPath) {
|
||||
try {
|
||||
const files = await fs.readdir(dirPath, { withFileTypes: true });
|
||||
return files.map(f => ({
|
||||
name: f.name,
|
||||
isDirectory: f.isDirectory(),
|
||||
path: path.join(dirPath, f.name)
|
||||
}));
|
||||
} catch (e) {
|
||||
console.error('List files error:', e);
|
||||
throw e;
|
||||
}
|
||||
},
|
||||
async readFile(filePath) {
|
||||
return fs.readFile(filePath, 'utf-8');
|
||||
},
|
||||
async writeFile(filePath, content) {
|
||||
// Ensure dir exists
|
||||
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
||||
return fs.writeFile(filePath, content, 'utf-8');
|
||||
},
|
||||
async deletePath(targetPath) {
|
||||
await fs.rm(targetPath, { recursive: true, force: true });
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user