Skip to content

Bugfix/windows path #53

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jun 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 11 additions & 15 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ function ilistFolder(folder, filesOnly) {
return files
}


// LOCAL FILE SYSTEM ACCESS
ipcMain.handle('open-folder', async (event) => {
console.log('ipcMain', 'open-folder')
Expand All @@ -64,16 +63,14 @@ ipcMain.handle('ilist-files', async (event, folder) => {
return ilistFolder(folder)
})

ipcMain.handle('load-file', (event, folder, filename) => {
console.log('ipcMain', 'load-file', folder, filename )
let filePath = path.resolve(folder, filename)
ipcMain.handle('load-file', (event, filePath) => {
console.log('ipcMain', 'load-file', filePath)
let content = fs.readFileSync(filePath)
return content
})

ipcMain.handle('save-file', (event, folder, filename, content) => {
console.log('ipcMain', 'save-file', folder, filename, content)
let filePath = path.resolve(folder, filename)
ipcMain.handle('save-file', (event, filePath, content) => {
console.log('ipcMain', 'save-file', filePath, content)
fs.writeFileSync(filePath, content, 'utf8')
return true
})
Expand All @@ -89,21 +86,20 @@ ipcMain.handle('update-folder', (event, folder) => {
return { folder, files }
})

ipcMain.handle('remove-file', (event, folder, filename) => {
console.log('ipcMain', 'remove-file', folder, filename)
let filePath = path.resolve(folder, filename)
ipcMain.handle('remove-file', (event, filePath) => {
console.log('ipcMain', 'remove-file', filePath)
fs.unlinkSync(filePath)
return true
})

ipcMain.handle('rename-file', (event, folder, filename, newFilename) => {
console.log('ipcMain', 'rename-file', folder, filename, newFilename)
let filePath = path.resolve(folder, filename)
let newFilePath = path.resolve(folder, newFilename)
ipcMain.handle('rename-file', (event, filePath, newFilePath) => {
console.log('ipcMain', 'rename-file', filePath, newFilePath)
fs.renameSync(filePath, newFilePath)
return newFilename
return true
})

// WINDOW MANAGEMENT

ipcMain.handle('set-window-size', (event, minWidth, minHeight) => {
console.log('ipcMain', 'set-window-size', minWidth, minHeight)
if (!win) {
Expand Down
54 changes: 27 additions & 27 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 31 additions & 14 deletions preload.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
console.log('preload')
const { contextBridge, ipcRenderer } = require('electron')
const path = require('path')

const Micropython = require('micropython.js')
const board = new Micropython()
Expand Down Expand Up @@ -53,14 +54,12 @@ const Serial = {
saveFileContent: async (filename, content, dataConsumer) => {
return board.fs_save(content || ' ', filename, dataConsumer)
},
uploadFile: async (diskFolder, serialFolder, filename, dataConsumer) => {
let src = `${diskFolder}/${filename}`
let dest = `${serialFolder}/${filename}`
uploadFile: async (src, dest, dataConsumer) => {
return board.fs_put(src, dest, dataConsumer)
},
downloadFile: async (serialFolder, diskFolder, filename) => {
let contents = await Serial.loadFile(`${serialFolder}/${filename}`)
return ipcRenderer.invoke('save-file', diskFolder, filename, contents)
downloadFile: async (src, dest) => {
let contents = await Serial.loadFile(src)
return ipcRenderer.invoke('save-file', dest, contents)
},
renameFile: async (oldName, newName) => {
return board.fs_rename(oldName, newName)
Expand All @@ -73,6 +72,15 @@ const Serial = {
},
exit_raw_repl: async () => {
return board.exit_raw_repl()
},
getNavigationPath: (navigation, target) => {
return [navigation, target].filter(p => p).join('/')
},
getFullPath: (root, navigation, file) => {
return root + [navigation, file].filter(p => p).join('/')
},
getParentPath: (filePath) => {
return filePath.split('/').slice(0, -1).join('/')
}
}

Expand All @@ -86,18 +94,27 @@ const Disk = {
ilistFiles: async (folder) => {
return ipcRenderer.invoke('ilist-files', folder)
},
loadFile: async (folder, file) => {
let content = await ipcRenderer.invoke('load-file', folder, file)
loadFile: async (filePath) => {
let content = await ipcRenderer.invoke('load-file', filePath)
return new TextDecoder().decode(content)
},
removeFile: async (folder, file) => {
return ipcRenderer.invoke('remove-file', folder, file)
removeFile: async (filePath) => {
return ipcRenderer.invoke('remove-file', filePath)
},
saveFileContent: async (filePath, content) => {
return ipcRenderer.invoke('save-file', filePath, content)
},
renameFile: async (oldName, newName) => {
return ipcRenderer.invoke('rename-file', oldName, newName)
},
getNavigationPath: (navigation, target) => {
return path.join(navigation, target)
},
saveFileContent: async (folder, file, content) => {
return ipcRenderer.invoke('save-file', folder, file, content)
getFullPath: (root, navigation, file) => {
return path.resolve(path.join(root, navigation, file))
},
renameFile: async (folder, oldName, newName) => {
return ipcRenderer.invoke('rename-file', folder, oldName, newName)
getParentPath: (navigation) => {
return path.dirname(navigation)
}
}

Expand Down
2 changes: 1 addition & 1 deletion ui/arduino/components/panel_files.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function PanelFiles(state, emit) {
<div class="path">
${state.isConnected ? Icon('icons/Connect.svg') : Icon('icons/Disconnect.svg')}
<a class="full" href="#" onclick=${() => emit('open-port-dialog')}>
${state.isConnected ? state.serialPath : 'Connect'}
${state.isConnected ? state.serialPort : 'Connect'}
</a>
${removeSerial}
${newSerial}
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy