6775 " |
6775 " |
6776 |
6776 |
6777 "Created: / 09-11-2012 / 10:07:41 / sr" |
6777 "Created: / 09-11-2012 / 10:07:41 / sr" |
6778 ! |
6778 ! |
6779 |
6779 |
6780 contents:aStringOrCollectionOfLines |
6780 contents:aStringOrByteArrayOrCollectionOfLines |
6781 "create (or overwrite) a file given its contents as a collection of lines. |
6781 "create (or overwrite) a file given its contents as a collection of lines. |
6782 Raises an error, if the file is unwritable." |
6782 Raises an error, if the file is unwritable." |
6783 |
6783 |
6784 ^ self |
6784 ^ self |
6785 writingFileDo:[:s | |
6785 writingFileDo:[:s | |
6786 aStringOrCollectionOfLines isNonByteCollection ifTrue:[ |
6786 aStringOrByteArrayOrCollectionOfLines isNonByteCollection ifTrue:[ |
6787 "a StringCollection or a collection of lines" |
6787 "a StringCollection or a collection of lines" |
6788 aStringOrCollectionOfLines do:[:each | s nextPutLine:(each ? '')] |
6788 aStringOrByteArrayOrCollectionOfLines do:[:each | s nextPutLine:(each ? '')] |
6789 ] ifFalse:[ |
6789 ] ifFalse:[ |
6790 "something string-like" |
6790 "something string-like" |
6791 aStringOrCollectionOfLines isString ifFalse:[ |
6791 aStringOrByteArrayOrCollectionOfLines isString ifFalse:[ |
6792 s binary |
6792 s binary |
6793 ]. |
6793 ]. |
6794 s nextPutAll:aStringOrCollectionOfLines |
6794 s nextPutAll:aStringOrByteArrayOrCollectionOfLines |
6795 ] |
6795 ] |
6796 ]. |
6796 ]. |
6797 |
6797 |
6798 " |
6798 " |
6799 'foo1' asFilename contents:#('one' 'two' 'three') |
6799 'foo1' asFilename contents:#('one' 'two' 'three') |
6800 'foo2' asFilename contents:'Hello world' |
6800 'foo2' asFilename contents:'Hello world' |
6801 'foo3' asFilename contents:#[1 2 3 4 5] |
6801 'foo3' asFilename contents:#[1 2 3 4 5] |
6802 " |
6802 " |
6803 |
6803 |
6804 "Created: / 11-12-2006 / 14:11:21 / cg" |
6804 "Created: / 11-12-2006 / 14:11:21 / cg" |
6805 "Modified: / 08-11-2007 / 13:28:41 / cg" |
6805 "Modified: / 08-11-2007 / 13:28:41 / cg" |
|
6806 "Modified (format): / 01-08-2018 / 18:11:58 / Claus Gittinger" |
6806 ! |
6807 ! |
6807 |
6808 |
6808 writingFileDo:aBlock |
6809 writingFileDo:aBlock |
6809 "create a write-stream on the receiver file, evaluate aBlock, passing that stream as arg, |
6810 "create a write-stream on the receiver file, evaluate aBlock, passing that stream as arg, |
6810 and return the block's value. |
6811 and return the block's value. |