29 lines
833 B
Smalltalk
29 lines
833 B
Smalltalk
"
|
|
I provide some convenience functionality to work with files.
|
|
"
|
|
Class {
|
|
#name : #FileUtils,
|
|
#superclass : #Object,
|
|
#category : #'Grafoscopio-Model'
|
|
}
|
|
|
|
{ #category : #utilities }
|
|
FileUtils class >> createFilesNamed: fileNames endingWith: fileExtension intoFolder: aFolder [
|
|
|
|
| createdFiles fullFileName existingFiles typedFileName |
|
|
createdFiles := OrderedCollection new.
|
|
existingFiles := OrderedCollection new.
|
|
fileNames do: [ :eachFile |
|
|
typedFileName := eachFile, fileExtension.
|
|
fullFileName := aFolder / typedFileName.
|
|
fullFileName exists
|
|
ifFalse: [
|
|
fullFileName ensureCreateFile.
|
|
createdFiles add: fullFileName basename ]
|
|
ifTrue: [existingFiles add: fullFileName basename ]].
|
|
^ (Dictionary new
|
|
at: 'created files' put: createdFiles;
|
|
at: 'existing files' put: existingFiles;
|
|
yourself)
|
|
]
|