File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ const assert = require("assert");
4
4
5
5
const remote = require ( 'electron' ) . remote ;
6
6
const dialog = remote . dialog ;
7
+ const mkdirp = require ( 'mkdirp' ) ;
7
8
8
9
const InkFileSymbols = require ( "./inkFileSymbols.js" ) . InkFileSymbols ;
9
10
@@ -172,7 +173,12 @@ InkFile.prototype.save = function(afterSaveCallback) {
172
173
var fileContent = this . aceDocument . getValue ( ) ;
173
174
if ( ! fileContent || fileContent . length < 1 ) throw "Empty file content in aceDocument!" ;
174
175
175
- fs . writeFile ( this . absolutePath ( ) , fileContent , "utf8" , ( err ) => {
176
+ // Ensure that the enclosing folder exists beforehand
177
+ var fileAbsPath = this . absolutePath ( ) ;
178
+ var fileDirectory = path . dirname ( fileAbsPath ) ;
179
+ mkdirp . sync ( fileDirectory ) ;
180
+
181
+ fs . writeFile ( fileAbsPath , fileContent , "utf8" , ( err ) => {
176
182
this . brandNewEmpty = false ;
177
183
if ( err )
178
184
afterSaveCallback ( false ) ;
You can’t perform that action at this time.
0 commit comments