@@ -71,7 +71,7 @@ function createFile (name, opts) {
71
71
if ( err ) return onerror ( err )
72
72
requestFileSystem ( window . PERSISTENT , granted , function ( res ) {
73
73
fs = res
74
- mkdir ( folder ( name ) , function ( ) {
74
+ mkdirp ( parentFolder ( name ) , function ( ) {
75
75
fs . root . getFile ( name , { create : true } , function ( e ) {
76
76
entry = e
77
77
entry . file ( function ( f ) {
@@ -83,9 +83,13 @@ function createFile (name, opts) {
83
83
} , onerror )
84
84
} )
85
85
86
- function mkdir ( name , ondone ) {
86
+ function mkdirp ( name , ondone ) {
87
87
if ( ! name ) return ondone ( )
88
- fs . root . getDirectory ( name , { create : true } , ondone , ondone )
88
+ fs . root . getDirectory ( name , { create : true } , ondone , function ( ) {
89
+ mkdirp ( parentFolder ( name ) , function ( ) {
90
+ fs . root . getDirectory ( name , { create : true } , ondone , ondone )
91
+ } )
92
+ } )
89
93
}
90
94
91
95
function onerror ( err ) {
@@ -95,10 +99,11 @@ function createFile (name, opts) {
95
99
}
96
100
}
97
101
98
- function folder ( path ) {
99
- const i = path . indexOf ( '/' )
100
- const j = path . indexOf ( '\\' )
101
- return path . slice ( 0 , Math . max ( 0 , i , j ) )
102
+ function parentFolder ( path ) {
103
+ const i = path . lastIndexOf ( '/' )
104
+ const j = path . lastIndexOf ( '\\' )
105
+ const p = path . slice ( 0 , Math . max ( 0 , i , j ) )
106
+ return / ^ \w : $ / . test ( p ) ? '' : p
102
107
}
103
108
104
109
function WriteRequest ( pool , file , entry , mutex ) {
0 commit comments