FileDirectory assureExistence
Last updated at 11:55 am UTC on 15 March 2018
A method of FileDirectory
assureExistence
"Make sure the current directory exists. If necessary, create all parts in between"
self exists ifFalse:
[ self containingDirectory
assureExistence ;
createDirectory: self localName.
self exists ifFalse: [ Error signal: self fullName, ' could not be created. Permissions?' ] ]
Call
(FileDirectory on: aPath) assureExistence
There is also #assureExistenceOfPath: . It is not to be used directly.
assureExistenceOfPath: lPath
"Make sure the local directory exists. If necessary, create all parts in between"
| localPath |
localPath := lPath.
localPath isEmpty ifTrue: [ ^self ]. "Assumed to exist"
self assureExistence.
(self directoryExists: localPath) ifTrue: [^ self]. "exists"
self createDirectory: localPath