Skip to content

Commit 44bd0f6

Browse files
authored
Merge pull request #49 from arduino/feature/new-file-management
Feature/new file management
2 parents c14d293 + f511561 commit 44bd0f6

22 files changed

+1433
-589
lines changed

Diff for: README.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ This project is sponsored by Arduino, based on original work by Murilo Polese. T
2424

2525
Arduino Lab for MicroPython is an [Electron](https://www.electronjs.org/) app that has its main purpose to communicate over serial with a microprocessor running [MicroPython](https://micropython.org/). All Electron code is at `/index.js`.
2626

27-
All operations over serial are abstracted and packaged on `/micropython.js` which is an attempt of porting `pyboard.py`. The port has its [own repository](https://github.com/murilopolese/micropython.js) but for the sake of simplicity and transparency, `micropython.js` is committed as source code.
27+
All operations over serial are abstracted and packaged on `/micropython.js` which is an attempt of porting `pyboard.py`. The port has its [own repository](https://github.com/arduino/micropython.js) but for the sake of simplicity and transparency, `micropython.js` is committed as source code.
2828

2929
The User Interface (UI) source code stays inside `/ui` folder and is completely independent of the Electron code.
3030

@@ -39,7 +39,6 @@ At the root of the repository you will find:
3939
- `/scripts`: Scripts executed during the build process.
4040
- `/ui`: Available user interfaces.
4141
- `/index.js`: Main Electron code.
42-
- `/micropython.js`: Serial connection abstraction.
4342
- `/preload.js`: Creates Disk and Serial APIs on Electron's main process and exposes it to Electron's renderer process (context bridge).
4443

4544
## Arduino UI
@@ -82,4 +81,3 @@ Some changes on the Electron code will require reopening the app but all UI chan
8281
## Disclaimer
8382

8483
This software is provided “as is” and we make no express or implied warranties whatsoever with respect to its functionality, operability, or use, including, without limitation, any implied warranties of merchantability, fitness for a particular purpose, or infringement. We expressly disclaim any liability whatsoever for any direct, indirect, consequential, incidental or special damages, including, without limitation, lost revenues, lost profits, losses resulting from business interruption or loss of data, regardless of the form of action or legal theory under which the liability may be asserted, even if advised of the possibility or likelihood of such damages.
85-

Diff for: index.js

+25
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,25 @@ function listFolder(folder) {
2222
return files
2323
}
2424

25+
function ilistFolder(folder, filesOnly) {
26+
let files = fs.readdirSync(path.resolve(folder))
27+
files = files.map(f => {
28+
let filePath = path.resolve(folder, f)
29+
return {
30+
path: f,
31+
type: fs.lstatSync(filePath).isDirectory() ? 'folder' : 'file'
32+
}
33+
})
34+
// Filter out directories
35+
if (filesOnly) {
36+
files = files.filter(f => f.type === 'file')
37+
}
38+
// Filter out dot files
39+
files = files.filter(f => f.path.indexOf('.') !== 0)
40+
return files
41+
}
42+
43+
2544
// LOCAL FILE SYSTEM ACCESS
2645
ipcMain.handle('open-folder', async (event) => {
2746
console.log('ipcMain', 'open-folder')
@@ -39,6 +58,12 @@ ipcMain.handle('list-files', async (event, folder) => {
3958
return listFolder(folder)
4059
})
4160

61+
ipcMain.handle('ilist-files', async (event, folder) => {
62+
console.log('ipcMain', 'ilist-files', folder)
63+
if (!folder) return []
64+
return ilistFolder(folder)
65+
})
66+
4267
ipcMain.handle('load-file', (event, folder, filename) => {
4368
console.log('ipcMain', 'load-file', folder, filename )
4469
let filePath = path.resolve(folder, filename)

0 commit comments

Comments
 (0)