dazscript-framework 0.1.15 → 0.1.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/README.md +365 -93
  2. package/babel.config.js +33 -33
  3. package/dist/babel/trace-babel-plugin.js +243 -243
  4. package/dist/babel/trace-log-babel-plugin.js +164 -164
  5. package/dist/scripts/install-generator.js +185 -185
  6. package/package.json +72 -70
  7. package/src/common/dz-dump.ts +120 -120
  8. package/src/common/log.ts +56 -56
  9. package/src/common/trace.ts +26 -26
  10. package/src/core/action-decorator.ts +15 -15
  11. package/src/core/base-script.ts +30 -30
  12. package/src/core/custom-action.ts +11 -11
  13. package/src/core/global.ts +4 -4
  14. package/src/dialog/basic-dialog.ts +40 -32
  15. package/src/dialog/builders/button-builder.ts +52 -52
  16. package/src/dialog/builders/checkbox-builder.ts +29 -29
  17. package/src/dialog/builders/color-picker-builder.ts +35 -35
  18. package/src/dialog/builders/combo-box-builder.ts +38 -35
  19. package/src/dialog/builders/combo-edit-builder.ts +35 -35
  20. package/src/dialog/builders/dialog-builder.ts +49 -49
  21. package/src/dialog/builders/groupbox-builder.ts +121 -82
  22. package/src/dialog/builders/label-builder.ts +33 -28
  23. package/src/dialog/builders/layout-builder.ts +59 -59
  24. package/src/dialog/builders/line-edit-builder.ts +124 -119
  25. package/src/dialog/builders/list-box-builder.ts +103 -0
  26. package/src/dialog/builders/list-view-builder.ts +396 -328
  27. package/src/dialog/builders/node-selection-builder.ts +55 -55
  28. package/src/dialog/builders/path-combo-box-builder.ts +24 -24
  29. package/src/dialog/builders/popup-menu-builder.ts +46 -46
  30. package/src/dialog/builders/radio-builder.ts +42 -42
  31. package/src/dialog/builders/slider-builder.ts +39 -22
  32. package/src/dialog/builders/splitter-builder.ts +88 -88
  33. package/src/dialog/builders/tab-builder.ts +120 -106
  34. package/src/dialog/builders/widget-builder.ts +136 -124
  35. package/src/dialog/builders/widgets-builder.ts +140 -135
  36. package/src/dialog/input-dialog.ts +30 -27
  37. package/src/dialog/input-validator.ts +8 -8
  38. package/src/dialog/selection-dialog.ts +47 -0
  39. package/src/dialog/shared.ts +8 -8
  40. package/src/helpers/action-helper.ts +214 -81
  41. package/src/helpers/array-helper.ts +170 -145
  42. package/src/helpers/camera-helper.ts +12 -12
  43. package/src/helpers/custom-action-helper.ts +176 -176
  44. package/src/helpers/directory-helper.ts +14 -0
  45. package/src/helpers/file-helper.ts +90 -90
  46. package/src/helpers/http-helper.ts +186 -0
  47. package/src/helpers/input-helper.ts +18 -18
  48. package/src/helpers/list-view-helper.ts +105 -89
  49. package/src/helpers/menu-helper.ts +28 -28
  50. package/src/helpers/message-box-helper.ts +25 -15
  51. package/src/helpers/node-helper.ts +461 -236
  52. package/src/helpers/number-helper.ts +10 -10
  53. package/src/helpers/numeric-property-helper.ts +91 -91
  54. package/src/helpers/object-helper.ts +2 -2
  55. package/src/helpers/pane-helper.ts +28 -20
  56. package/src/helpers/progress-helper.ts +51 -33
  57. package/src/helpers/property-helper.ts +61 -52
  58. package/src/helpers/record-helper.ts +16 -16
  59. package/src/helpers/scene-helper.ts +144 -94
  60. package/src/helpers/script-helper.ts +15 -15
  61. package/src/helpers/skeleton-helper.ts +26 -26
  62. package/src/helpers/splitter-helper.ts +8 -8
  63. package/src/helpers/string-helper.ts +39 -31
  64. package/src/helpers/surface-helper.ts +5 -5
  65. package/src/helpers/undo-helper.ts +8 -8
  66. package/src/helpers/viewport-helper.ts +21 -8
  67. package/src/lib/delayed.ts +38 -38
  68. package/src/lib/dictionary.ts +3 -0
  69. package/src/lib/frame-keys.ts +67 -67
  70. package/src/lib/guid.ts +2 -2
  71. package/src/lib/menu-item.ts +10 -9
  72. package/src/lib/observable.ts +147 -94
  73. package/src/lib/set.ts +50 -25
  74. package/src/lib/settings.ts +112 -104
  75. package/src/lib/tree-node.ts +149 -145
  76. package/src/samples/config.ts +2 -2
  77. package/src/samples/hello-world.dsa.ts +12 -12
  78. package/src/samples/sample-dialog.dsa.ts +51 -51
  79. package/src/samples/sample-dialog.ts +48 -48
  80. package/src/shared/set-keyboard-shortcut.ts +146 -102
  81. package/tsconfig.json +116 -116
  82. package/webpack.config.js +70 -70
@@ -1,176 +1,176 @@
1
- import { debug } from '@dsf/common/log'
2
- import { CustomAction } from '@dsf/core/custom-action'
3
- import { mainWindow } from '@dsf/core/global'
4
- import * as array from '@dsf/helpers/array-helper'
5
- import { getMenu } from './menu-helper'
6
- import { keys } from './object-helper'
7
- import { progress } from './progress-helper'
8
- import { getScriptPath } from './script-helper'
9
-
10
- const actionMgr = mainWindow.getActionMgr()
11
- const paneMgr = mainWindow.getPaneMgr()
12
-
13
- export const findByFilePath = (action: CustomAction, filePath: string): CustomAction | null => {
14
- var actionsCount = actionMgr.getNumCustomActions()
15
- for (var i = 0; i < actionsCount; i++) {
16
- var actionFilePath = actionMgr.getCustomActionFile(i)
17
-
18
- if (actionFilePath != filePath) continue
19
-
20
- var name = actionMgr.getCustomActionName(i)
21
- var text = actionMgr.getCustomActionText(i)
22
- var desc = actionMgr.getCustomActionDesc(i)
23
- var icon = actionMgr.getCustomActionIcon(i)
24
-
25
- return {
26
- name: name.toString(),
27
- text: text.toString(),
28
- description: desc.toString(),
29
- filePath: actionFilePath.toString(),
30
- icon: icon.toString(),
31
- menuPath: action.menuPath,
32
- group: action.group,
33
- shortcut: action.shortcut,
34
- sort: action.sort,
35
- toolbar: action.toolbar
36
- } as CustomAction
37
- }
38
-
39
- return null
40
- }
41
-
42
- export const findMenuFor = (actionName: string, topMenu?: DzActionMenu): DzActionMenu | null => {
43
- topMenu = topMenu ?? actionMgr.getMenu()
44
- if (!topMenu.hasItems()) return null
45
- for (let i = 0; i < topMenu.getNumItems(); i++) {
46
- let item = topMenu.getItem(i)
47
- if (item.type == DzActionMenuItem.CustomAction && item.action == actionName)
48
- return item.getParentMenu()
49
- if (item.type == DzActionMenuItem.SubMenu) {
50
- var subMenu = findMenuFor(actionName, item.getSubMenu())
51
- if (subMenu) return subMenu
52
- }
53
- }
54
- return null
55
- }
56
-
57
- export const findInMenu = (menu: DzActionMenu, actionName: string): DzActionMenuItem | null => {
58
- var item: DzActionMenuItem
59
-
60
- var aItems = menu.getItemList()
61
- for (var i = 0; i < aItems.length; i += 1) {
62
- item = aItems[i]
63
-
64
- if (item.type != DzActionMenuItem.CustomAction) {
65
- continue
66
- }
67
-
68
- if (item.action == actionName) {
69
- return item
70
- }
71
- }
72
-
73
- return null
74
- }
75
-
76
- export const createCustomAction = (action: CustomAction, update: boolean) => {
77
- let existingAction = findByFilePath(action, action.filePath)
78
-
79
- if (existingAction && !update) return
80
-
81
- if (existingAction) {
82
- removeCustomAction(existingAction)
83
- }
84
-
85
- let name = actionMgr.addCustomAction(String(action.text), String(action.description), String(action.filePath), true, action.shortcut ?? "", String(action.icon)).toString()
86
- action.name = name
87
-
88
- if (action.shortcut) {
89
- actionMgr.setCustomActionShortcut(actionMgr.findCustomAction(name), action.shortcut)
90
- debug(`Created Custom Action: ${action.text} (${action.name}): ${action.filePath}`)
91
- }
92
-
93
- addToMenu(action)
94
- addToToolbar(action)
95
- }
96
-
97
- export const addToMenu = (action: CustomAction) => {
98
- if (!action.menuPath) return
99
- action.menuPath = action.menuPath + '/'
100
- var menu = getMenu(action.menuPath, true)
101
- var menuAction = findInMenu(menu, action.name)
102
- if (menuAction) return
103
- menu.insertCustomAction(action.name, action.sort ?? -1)
104
- debug(`Action "${action.text}" added to menu "${menu.getPath()}"`)
105
- }
106
-
107
- export const addToToolbar = (action: CustomAction) => {
108
- if (!action.toolbar) return;
109
-
110
- var toolbar = paneMgr.findToolBar(action.toolbar);
111
-
112
- if (!toolbar) {
113
- toolbar = paneMgr.createToolBar(action.toolbar);
114
- toolbar.dock(DzToolBar.ToolBarTop);
115
- }
116
-
117
- if (array.find(toolbar.getItemList(), i => i.action == action.name)) return
118
-
119
- debug(`Adding menu to toolbar ${toolbar.name}`)
120
- toolbar.insertCustomAction(action.name, action.sort)
121
- }
122
-
123
- const removeCustomAction = (action: CustomAction) => {
124
- if (!action.name) return
125
- var menu = findMenuFor(action.name, actionMgr.getMenu())
126
- if (menu) {
127
- var menuAction = findInMenu(menu, action.name)
128
- if (menuAction) {
129
- menu.removeItem(menuAction)
130
- debug(`Action ${action.text} Removed from menu`)
131
- }
132
- }
133
-
134
- actionMgr.removeCustomAction(actionMgr.findCustomAction(action.name))
135
- debug(`Action ${action.text} Removed`)
136
- debug(`Toolbar: ${action.toolbar}`)
137
-
138
- if (!action.toolbar) return
139
- debug(`Removing Toolbar ${action.toolbar}`)
140
- var toolbar = paneMgr.findToolBar(action.toolbar)
141
- if (!toolbar) return
142
- toolbar.clear()
143
- paneMgr.removeToolBar(action.toolbar)
144
- debug(`Toolbar Removed`)
145
- }
146
-
147
- export const installCustomActions = (actions: CustomAction[]) => {
148
- uninstallCustomActions(actions)
149
- let scriptsPath = getScriptPath()
150
- debug(`Script path: ${scriptsPath}`)
151
- let menuPaths = array.group(actions, (a => a.menuPath ?? ""))
152
- progress('Installing', keys(menuPaths), (menuPath) => {
153
- let actions = menuPaths[menuPath] as CustomAction[]
154
- let groups = array.group(actions, (action) => action.group ?? "")
155
- keys(groups).forEach(group => {
156
- groups[group].forEach(action => {
157
- action.filePath = `${scriptsPath}/${action.filePath}`
158
- action.icon = action.icon ? `${scriptsPath}/${action.icon}` : ''
159
- createCustomAction(action, true)
160
- // findMenuFor(action.name)
161
- })
162
- })
163
- })
164
- }
165
-
166
- export const uninstallCustomActions = (actions: CustomAction[]) => {
167
- debug(`Uninstalling Actions`)
168
- actions.forEach(action => {
169
- if (!action) return
170
- let customAction = findByFilePath(action, `${getScriptPath()}/${action.filePath}`)
171
- if (!customAction) return
172
- debug(`Uninstalling action "${customAction.text} (${customAction.name})"`)
173
- removeCustomAction(customAction)
174
- })
175
- }
176
-
1
+ import { debug } from '@dsf/common/log'
2
+ import { CustomAction } from '@dsf/core/custom-action'
3
+ import { mainWindow } from '@dsf/core/global'
4
+ import * as array from '@dsf/helpers/array-helper'
5
+ import { getMenu } from './menu-helper'
6
+ import { keys } from './object-helper'
7
+ import { progress } from './progress-helper'
8
+ import { getScriptPath } from './script-helper'
9
+
10
+ const actionMgr = mainWindow.getActionMgr()
11
+ const paneMgr = mainWindow.getPaneMgr()
12
+
13
+ export const findByFilePath = (action: CustomAction, filePath: string): CustomAction | null => {
14
+ var actionsCount = actionMgr.getNumCustomActions()
15
+ for (var i = 0; i < actionsCount; i++) {
16
+ var actionFilePath = actionMgr.getCustomActionFile(i)
17
+
18
+ if (actionFilePath != filePath) continue
19
+
20
+ var name = actionMgr.getCustomActionName(i)
21
+ var text = actionMgr.getCustomActionText(i)
22
+ var desc = actionMgr.getCustomActionDesc(i)
23
+ var icon = actionMgr.getCustomActionIcon(i)
24
+
25
+ return {
26
+ name: name.toString(),
27
+ text: text.toString(),
28
+ description: desc.toString(),
29
+ filePath: actionFilePath.toString(),
30
+ icon: icon.toString(),
31
+ menuPath: action.menuPath,
32
+ group: action.group,
33
+ shortcut: action.shortcut,
34
+ sort: action.sort,
35
+ toolbar: action.toolbar
36
+ } as CustomAction
37
+ }
38
+
39
+ return null
40
+ }
41
+
42
+ export const findMenuFor = (actionName: string, topMenu?: DzActionMenu): DzActionMenu | null => {
43
+ topMenu = topMenu ?? actionMgr.getMenu()
44
+ if (!topMenu.hasItems()) return null
45
+ for (let i = 0; i < topMenu.getNumItems(); i++) {
46
+ let item = topMenu.getItem(i)
47
+ if (item.type == DzActionMenuItem.CustomAction && item.action == actionName)
48
+ return item.getParentMenu()
49
+ if (item.type == DzActionMenuItem.SubMenu) {
50
+ var subMenu = findMenuFor(actionName, item.getSubMenu())
51
+ if (subMenu) return subMenu
52
+ }
53
+ }
54
+ return null
55
+ }
56
+
57
+ export const findInMenu = (menu: DzActionMenu, actionName: string): DzActionMenuItem | null => {
58
+ var item: DzActionMenuItem
59
+
60
+ var aItems = menu.getItemList()
61
+ for (var i = 0; i < aItems.length; i += 1) {
62
+ item = aItems[i]
63
+
64
+ if (item.type != DzActionMenuItem.CustomAction) {
65
+ continue
66
+ }
67
+
68
+ if (item.action == actionName) {
69
+ return item
70
+ }
71
+ }
72
+
73
+ return null
74
+ }
75
+
76
+ export const createCustomAction = (action: CustomAction, update: boolean) => {
77
+ let existingAction = findByFilePath(action, action.filePath)
78
+
79
+ if (existingAction && !update) return
80
+
81
+ if (existingAction) {
82
+ removeCustomAction(existingAction)
83
+ }
84
+
85
+ let name = actionMgr.addCustomAction(String(action.text), String(action.description), String(action.filePath), true, action.shortcut ?? "", String(action.icon)).toString()
86
+ action.name = name
87
+
88
+ if (action.shortcut) {
89
+ actionMgr.setCustomActionShortcut(actionMgr.findCustomAction(name), action.shortcut)
90
+ debug(`Created Custom Action: ${action.text} (${action.name}): ${action.filePath}`)
91
+ }
92
+
93
+ addToMenu(action)
94
+ addToToolbar(action)
95
+ }
96
+
97
+ export const addToMenu = (action: CustomAction) => {
98
+ if (!action.menuPath) return
99
+ action.menuPath = action.menuPath + '/'
100
+ var menu = getMenu(action.menuPath, true)
101
+ var menuAction = findInMenu(menu, action.name)
102
+ if (menuAction) return
103
+ menu.insertCustomAction(action.name, action.sort ?? -1)
104
+ debug(`Action "${action.text}" added to menu "${menu.getPath()}"`)
105
+ }
106
+
107
+ export const addToToolbar = (action: CustomAction) => {
108
+ if (!action.toolbar) return;
109
+
110
+ var toolbar = paneMgr.findToolBar(action.toolbar);
111
+
112
+ if (!toolbar) {
113
+ toolbar = paneMgr.createToolBar(action.toolbar);
114
+ toolbar.dock(DzToolBar.ToolBarTop);
115
+ }
116
+
117
+ if (array.find(toolbar.getItemList(), i => i.action == action.name)) return
118
+
119
+ debug(`Adding menu to toolbar ${toolbar.name}`)
120
+ toolbar.insertCustomAction(action.name, action.sort)
121
+ }
122
+
123
+ const removeCustomAction = (action: CustomAction) => {
124
+ if (!action.name) return
125
+ var menu = findMenuFor(action.name, actionMgr.getMenu())
126
+ if (menu) {
127
+ var menuAction = findInMenu(menu, action.name)
128
+ if (menuAction) {
129
+ menu.removeItem(menuAction)
130
+ debug(`Action ${action.text} Removed from menu`)
131
+ }
132
+ }
133
+
134
+ actionMgr.removeCustomAction(actionMgr.findCustomAction(action.name))
135
+ debug(`Action ${action.text} Removed`)
136
+ debug(`Toolbar: ${action.toolbar}`)
137
+
138
+ if (!action.toolbar) return
139
+ debug(`Removing Toolbar ${action.toolbar}`)
140
+ var toolbar = paneMgr.findToolBar(action.toolbar)
141
+ if (!toolbar) return
142
+ toolbar.clear()
143
+ // paneMgr.removeToolBar(action.toolbar)
144
+ // debug(`Toolbar Removed`)
145
+ }
146
+
147
+ export const installCustomActions = (actions: CustomAction[]) => {
148
+ uninstallCustomActions(actions)
149
+ let scriptsPath = getScriptPath()
150
+ debug(`Script path: ${scriptsPath}`)
151
+ let menuPaths = array.group(actions, (a => a.menuPath ?? ""))
152
+ progress('Installing', keys(menuPaths), (menuPath) => {
153
+ let actions = menuPaths[menuPath] as CustomAction[]
154
+ let groups = array.group(actions, (action) => action.group ?? "")
155
+ keys(groups).forEach(group => {
156
+ groups[group].forEach(action => {
157
+ action.filePath = `${scriptsPath}/${action.filePath}`
158
+ action.icon = action.icon ? `${scriptsPath}/${action.icon}` : ''
159
+ createCustomAction(action, true)
160
+ // findMenuFor(action.name)
161
+ })
162
+ })
163
+ })
164
+ }
165
+
166
+ export const uninstallCustomActions = (actions: CustomAction[]) => {
167
+ debug(`Uninstalling Actions`)
168
+ actions.forEach(action => {
169
+ if (!action) return
170
+ let customAction = findByFilePath(action, `${getScriptPath()}/${action.filePath}`)
171
+ if (!customAction) return
172
+ debug(`Uninstalling action "${customAction.text} (${customAction.name})"`)
173
+ removeCustomAction(customAction)
174
+ })
175
+ }
176
+
@@ -0,0 +1,14 @@
1
+
2
+ import * as log from "@dsf/common/log"
3
+
4
+ export const createPath = (dirPath: string): boolean => {
5
+ try {
6
+ if (!dirPath) return false
7
+ var dzDir = new DzDir(dirPath)
8
+ dzDir.mkpath(dirPath)
9
+ return true
10
+ } catch (error) {
11
+ log.error(`Error while creating directory ${dirPath}`)
12
+ return false
13
+ }
14
+ }
@@ -1,90 +1,90 @@
1
- import * as log from '@dsf/common/log'
2
-
3
- /**
4
- * Reads a file and tries to deserialize it to the specified type, assuming the file content
5
- * is a valid JSON
6
- * @param filePath the file to read
7
- * @param cache if true, cache the file into memory
8
- * @returns the deserialized object or null of the file cannot be deserialized
9
- */
10
- export const readFromFile = <T>(filePath: string, cache: boolean = false): T | null => {
11
- try {
12
- var file = new DzFile(filePath)
13
- if (!file.exists()) return null
14
- file.open(DzFile.ReadOnly)
15
- file.setCaching(cache)
16
- var content = file.read().toString()
17
- var items: T = JSON.parse(content)
18
- file.close()
19
- file.deleteLater()
20
- return items
21
- } catch (error) {
22
- log.error(`Error while reading file ${filePath}`)
23
- return null
24
- }
25
- }
26
-
27
- /**
28
- *
29
- * @param path
30
- * @param fileName
31
- * @param content
32
- * @returns
33
- */
34
- export const saveToFile = (filePath: string, content: string): boolean => {
35
- try {
36
- if (!filePath || !content) return false
37
- let fileInfo = new DzFileInfo(filePath)
38
- let path = fileInfo.absolutePath()
39
- var dzDir = new DzDir(path)
40
- dzDir.mkpath(path)
41
- var file = new DzFile(`${filePath}`)
42
- file.open(DzFile.WriteOnly)
43
- file.write(content)
44
- file.close()
45
- fileInfo.deleteLater()
46
- file.deleteLater()
47
- return true
48
- } catch (error) {
49
- log.error(`Error while saving file ${filePath}`)
50
- return false
51
- }
52
- }
53
-
54
- /**
55
- *
56
- * @param path
57
- * @param fileName
58
- * @param content
59
- * @returns
60
- * @deprecated must remove path argument
61
- */
62
- export const saveToFileOld = (path: string, fileName: string, content: string): boolean => {
63
- try {
64
- if (!path || !fileName || !content) return false
65
- var dzDir = new DzDir(path)
66
- dzDir.mkpath(path)
67
- var file = new DzFile(`${path}${fileName}`)
68
- file.open(DzFile.WriteOnly)
69
- file.write(content)
70
- file.close()
71
- file.deleteLater()
72
- return true
73
- } catch (error) {
74
- log.error(`Error while saving file ${path}${fileName}`)
75
- return false
76
- }
77
- }
78
-
79
- export const deleteFile = (filePath: string): boolean => {
80
- try {
81
- var file = new DzFile(filePath)
82
- if (!file.exists()) return
83
- file.remove(filePath)
84
- file.deleteLater()
85
- return true
86
- } catch (error) {
87
- log.error(`Error while deleting file ${filePath}`)
88
- return false
89
- }
90
- }
1
+ import * as log from '@dsf/common/log'
2
+
3
+ /**
4
+ * Reads a file and tries to deserialize it to the specified type, assuming the file content
5
+ * is a valid JSON
6
+ * @param filePath the file to read
7
+ * @param cache if true, cache the file into memory
8
+ * @returns the deserialized object or null of the file cannot be deserialized
9
+ */
10
+ export const readFromFile = <T>(filePath: string, cache: boolean = false): T | null => {
11
+ try {
12
+ var file = new DzFile(filePath)
13
+ if (!file.exists()) return null
14
+ file.open(DzFile.ReadOnly)
15
+ file.setCaching(cache)
16
+ var content = file.read().toString()
17
+ var items: T = JSON.parse(content)
18
+ file.close()
19
+ file.deleteLater()
20
+ return items
21
+ } catch (error) {
22
+ log.error(`Error while reading file ${filePath}`)
23
+ return null
24
+ }
25
+ }
26
+
27
+ /**
28
+ *
29
+ * @param path
30
+ * @param fileName
31
+ * @param content
32
+ * @returns
33
+ */
34
+ export const saveToFile = (filePath: string, content: string): boolean => {
35
+ try {
36
+ if (!filePath || !content) return false
37
+ let fileInfo = new DzFileInfo(filePath)
38
+ let path = fileInfo.absolutePath()
39
+ var dzDir = new DzDir(path)
40
+ dzDir.mkpath(path)
41
+ var file = new DzFile(`${filePath}`)
42
+ file.open(DzFile.WriteOnly)
43
+ file.write(content)
44
+ file.close()
45
+ fileInfo.deleteLater()
46
+ file.deleteLater()
47
+ return true
48
+ } catch (error) {
49
+ log.error(`Error while saving file ${filePath}`)
50
+ return false
51
+ }
52
+ }
53
+
54
+ /**
55
+ *
56
+ * @param path
57
+ * @param fileName
58
+ * @param content
59
+ * @returns
60
+ * @deprecated must remove path argument
61
+ */
62
+ export const saveToFileOld = (path: string, fileName: string, content: string): boolean => {
63
+ try {
64
+ if (!path || !fileName || !content) return false
65
+ var dzDir = new DzDir(path)
66
+ dzDir.mkpath(path)
67
+ var file = new DzFile(`${path}${fileName}`)
68
+ file.open(DzFile.WriteOnly)
69
+ file.write(content)
70
+ file.close()
71
+ file.deleteLater()
72
+ return true
73
+ } catch (error) {
74
+ log.error(`Error while saving file ${path}${fileName}`)
75
+ return false
76
+ }
77
+ }
78
+
79
+ export const deleteFile = (filePath: string): boolean => {
80
+ try {
81
+ var file = new DzFile(filePath)
82
+ if (!file.exists()) return false
83
+ file.remove(filePath)
84
+ file.deleteLater()
85
+ return true
86
+ } catch (error) {
87
+ log.error(`Error while deleting file ${filePath}`)
88
+ return false
89
+ }
90
+ }