Starting FileUtils, used in the Lua/LÖVE video game tutorial notebook, but useful in other contexts :-).
This commit is contained in:
parent
08d48aed12
commit
e36bcff4c3
28
repository/Grafoscopio/FileUtils.class.st
Normal file
28
repository/Grafoscopio/FileUtils.class.st
Normal file
@ -0,0 +1,28 @@
|
||||
"
|
||||
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)
|
||||
]
|
@ -41,7 +41,7 @@ GrafoscopioNode class >> cleanTreeRootReferences [
|
||||
clipboard preorderTraversal allButFirstDo: [ :n |
|
||||
ref := n.
|
||||
n level - 1 timesRepeat: [ ref := ref parent ].
|
||||
ref parent: nil
|
||||
ref ifNotNil: [ ref parent: nil ]
|
||||
]
|
||||
]
|
||||
|
||||
|
@ -26,3 +26,8 @@ ManifestGrafoscopio class >> ruleRBLongMethodsRuleV1FalsePositive [
|
||||
ManifestGrafoscopio class >> ruleRBSentNotImplementedRuleV1FalsePositive [
|
||||
^ #(#(#(#RGMetaclassDefinition #(#'GrafoscopioGUI class' #GrafoscopioGUI)) #'2015-12-23T10:38:16.706667-05:00') #(#(#RGClassDefinition #(#GrafoscopioGUI)) #'2016-01-06T18:53:45.844051-05:00') #(#(#RGMethodDefinition #(#GrafoscopioNotebook #newWindowMainMenu #false)) #'2016-12-17T18:51:40.617924-05:00') )
|
||||
]
|
||||
|
||||
{ #category : #'code-critics' }
|
||||
ManifestGrafoscopio class >> ruleRBStringConcatenationRuleV1FalsePositive [
|
||||
^ #(#(#(#RGMethodDefinition #(#'FileUtils class' #createFilesNamed:endingWith:intoFolder: #true)) #'2017-01-01T21:48:26.712639-05:00') )
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user