'From Squeak3.4alpha of 6 November 2002 [latest update: #5100] on 11 November 2002 at 2:19:24 am'! "Change Set: fromSqueakMap-gh Date: November 2002 Author: Gšran Hultgren Contains the code in the prevailing SqueakMap corpus that resides in generic classes."! !Date methodsFor: 'printing' stamp: 'gh 10/22/2002 17:49'! yyyymmdd "Format the date in ISO 8601 standard like '2002-10-22'." "Date today yyyymmdd" ^ self printFormat: #(3 2 1 $- 1 1 2)! ! !FileDirectory methodsFor: 'file name utilities' stamp: 'gh 1/22/2002 15:45'! lastNameFor: baseFileName extension: extension "Assumes a file name includes a version number encoded as '.' followed by digits preceding the file extension. Increment the version number and answer the new file name. If a version number is not found, set the version to 1 and answer a new file name" | files splits | files _ self fileNamesMatching: (baseFileName,'*', self class dot, extension). splits _ files collect: [:file | self splitNameVersionExtensionFor: file] thenSelect: [:split | (split at: 1) = baseFileName]. splits _ splits asSortedCollection: [:a :b | (a at: 2) < (b at: 2)]. ^splits isEmpty ifTrue: [nil] ifFalse: [(baseFileName, '.', (splits last at: 2) asString, self class dot, extension) asFileName]! ! !FileList2 class methodsFor: 'modal dialogs' stamp: 'gh 9/16/2002 10:33'! modalFolderSelector ^self modalFolderSelector: FileDirectory default! ! !FileList2 class methodsFor: 'modal dialogs' stamp: 'gh 8/27/2002 15:10'! modalFolderSelector: aDir | window fileModel | window _ self morphicViewFolderSelector: aDir. fileModel _ window model. window openInWorld: self currentWorld extent: 300@400. [window world notNil] whileTrue: [ window outermostWorldMorph doOneCycleNow. ]. ^fileModel getSelectedDirectory withoutListWrapper! ! !FileList2 class methodsFor: 'morphic ui' stamp: 'gh 9/16/2002 10:30'! morphicViewFolderSelector ^self morphicViewFolderSelector: FileDirectory default! ! !FileList2 class methodsFor: 'morphic ui' stamp: 'gh 8/27/2002 15:09'! morphicViewFolderSelector: aDir | aFileList window fixedSize | aFileList _ self new directory: aDir. aFileList optionalButtonSpecs: self specsForFolderSelector. window _ (SystemWindow labelled: aDir pathName) model: aFileList. aFileList modalView: window. fixedSize _ 25. self addFullPanesTo: window from: { {self textRow: 'Please select a folder'. 0 @ 0 corner: 1 @ 0. 0@0 corner: 0@fixedSize}. {aFileList optionalButtonRow. 0 @ 0 corner: 1 @ 0. 0@fixedSize corner: 0@(fixedSize * 2)}. {aFileList morphicDirectoryTreePane. 0@0 corner: 1@1. 0@(fixedSize * 2) corner: 0@0}. }. aFileList postOpen. ^ window ! ! !StandardFileStream methodsFor: 'read, write, position' stamp: 'gh 8/2/2002 14:21'! findString: string "Fast version of #upToAll: to find a String in a file starting from the beginning. Returns the position and also sets the position there. If string is not found 0 is returned and position is unchanged." | pos buffer count oldPos sz | oldPos _ self position. self reset. sz _ self size. pos _ 0. buffer _ String new: 2000. [ self nextInto: buffer. (count _ buffer findString: string) > 0 ifTrue: ["Found the string part way into buffer" self position: pos + count - 1. ^pos + count - 1]. pos _ ((pos + 2000) min: sz). pos = sz] whileFalse. "Never found it, and hit beginning of file" self position: oldPos. ^0! ! !StandardFileStream methodsFor: 'read, write, position' stamp: 'gh 3/20/2002 00:08'! findStringFromEnd: string "Fast version to find a String in a file starting from the end. Returns the position and also sets the position there. If string is not found 0 is returned and position is unchanged." | pos buffer count oldPos | oldPos _ self position. self setToEnd. pos _ self position. [ pos _ ((pos - 2000) max: 0). self position: pos. buffer _ self next: 2000. (count _ buffer findString: string) > 0 ifTrue: ["Found the delimiter part way into buffer" self position: pos + count. ^pos + count]. pos = 0] whileFalse. "Never found it, and hit beginning of file" self position: oldPos. ^0! !