'From Squeak3.2alpha of 8 October 2001 [latest update: #4418] on 16 October 2001 at 4:21:36 pm'! !ExternalSettings class methodsFor: 'accessing' stamp: 'hg 9/29/2001 14:35'! preferenceDirectory | prefDirName prefDir | prefDirName _ 'prefs'. ^(FileDirectory default directoryExists: prefDirName) ifTrue: [FileDirectory default directoryNamed: prefDirName] ifFalse: [ ((FileDirectory on: Smalltalk vmPath) directoryExists: prefDirName) ifTrue: [(FileDirectory on: Smalltalk vmPath) directoryNamed: prefDirName] ifFalse: [ prefDir _ FileDirectory default directoryNamed: prefDirName. prefDir assureExistence. prefDir]] ! ! !FileDirectory methodsFor: 'testing' stamp: 'hg 9/29/2001 15:04'! exists ^self containingDirectory directoryExists: self localName! ! !FileDirectory methodsFor: 'file directory' stamp: 'hg 9/29/2001 14:34'! assureExistence "Make sure the current directory exists. If necessary, create all parts inbetween" ^self containingDirectory assurePathExists: self localName! ! !FileDirectory methodsFor: 'file directory' stamp: 'hg 9/29/2001 14:33'! assurePathExists: localPath "Make sure the local directory exists. If necessary, create all parts inbetween" (self directoryNames includes: localPath) ifTrue:[^self]. "exists" "otherwise check parent first and then create local dir" self containingDirectory assurePathExists: self localName. self createDirectory: localPath.! ! !FileDirectory class methodsFor: 'name utilities' stamp: 'hg 9/29/2001 14:35'! startUp "Establish the platform-specific FileDirectory subclass. Do any platform-specific startup." self setDefaultDirectoryFrom: Smalltalk imageName. Preferences startInUntrustedDirectory ifTrue:[ self setDefaultDirectory: SecurityManager default untrustedUserDirectory. "Make sure we have a place to go to" DefaultDirectory assureExistence]. Smalltalk openSourceFiles. ! ! !MacFileDirectory class methodsFor: 'platform specific' stamp: 'hg 9/28/2001 15:23'! maxFileNameLength ^31! ! !Password methodsFor: 'accessing' stamp: 'hg 9/29/2001 21:56'! passwordFor: serverDir "Returned the password from one of many sources. OK if send in a nil arg." | sp msg | cache ifNotNil: [^ cache]. sequence ifNotNil: [ (sp _ self serverPasswords) ifNotNil: [ sequence <= sp size ifTrue: [^ sp at: sequence]]]. msg _ (serverDir isKindOf: ServerDirectory) ifTrue: [serverDir moniker] ifFalse: ['this directory']. (serverDir user = 'anonymous') & (serverDir typeWithDefault == #ftp) ifTrue: [ ^ cache _ FillInTheBlank request: 'Please let this anonymous ftp\server know your email address.\This is the polite thing to do.' withCRs initialAnswer: 'yourName@company.com']. ^ cache _ FillInTheBlank requestPassword: 'Password for ', serverDir user, ' at ', msg, ':'. "Diff between empty string and abort?"! ! !SecurityManager methodsFor: 'fileIn/out' stamp: 'hg 9/29/2001 14:35'! storeSecurityKeys "SecurityManager default storeSecurityKeys" "Store the keys file for the current user" | fd loc file | self isInRestrictedMode ifTrue:[^self]. "no point in even trying" loc _ self secureUserDirectory. "where to put it" loc last = FileDirectory pathNameDelimiter ifFalse:[ loc _ loc copyWith: FileDirectory pathNameDelimiter. ]. fd _ FileDirectory on: loc. fd assureExistence. fd deleteFileNamed: self keysFileName ifAbsent:[]. file _ fd newFileNamed: self keysFileName. {privateKeyPair. trustedKeys} storeOn: file. file close.! ! !ServerDirectory methodsFor: 'do ftp' stamp: 'hg 9/29/2001 16:25'! fileExists: fileName "Does the file exist on this server directory? fileName must be simple with no / or references to other directories." self isTypeFile ifTrue: [^ self fileNames includes: fileName]. self isTypeHTTP ifTrue: [^ (self readOnlyFileNamed: fileName) class ~~ String]. "ftp" ^ self entries anySatisfy: [:entry | entry name = fileName]! ! !ServerDirectory methodsFor: 'file directory' stamp: 'hg 9/29/2001 22:54'! assureExistence "Make sure the current directory exists. If necessary, create all parts inbetween" [self exists ifTrue: [^true]] on: FTPConnectionException do: [:ex | self isRoot ifFalse: [ self containingDirectory assurePathExists: self localName]]! ! !ServerDirectory methodsFor: 'file directory' stamp: 'hg 9/29/2001 15:57'! assurePathExists: localPath "Make sure the local directory exists. If necessary, create all parts inbetween" localPath = (String with: self pathNameDelimiter) ifTrue: [^self]. self assureExistence. (self localPathExists: localPath) ifFalse: [ self createDirectory: localPath].! ! !ServerDirectory methodsFor: 'file directory' stamp: 'hg 9/29/2001 15:23'! containingDirectory self splitName: directory to: [:parentPath :localName | ^self copy directory: parentPath]! ! !ServerDirectory methodsFor: 'file directory' stamp: 'hg 9/29/2001 15:35'! localName directory isEmpty ifTrue: [self error: 'no directory']. ^self localNameFor: directory! ! !ServerDirectory methodsFor: 'file directory' stamp: 'hg 9/29/2001 14:57'! localPathExists: localPath ^self directoryNames includes: localPath! ! !ServerDirectory methodsFor: 'testing' stamp: 'hg 9/29/2001 15:58'! isRoot ^directory = (String with: self pathNameDelimiter)! ! !ServerDirectory class methodsFor: 'misc' stamp: 'hg 9/21/2001 16:40'! on: pathString ^self new on: pathString! ! !ServerDirectory class methodsFor: 'server prefs' stamp: 'hg 9/29/2001 14:35'! transferServerDefinitionsToExternal "ServerDirectory transferServerDefinitionsToExternal" | serverDir | serverDir _ ExternalSettings preferenceDirectory directoryNamed: self serverConfDirectoryName. serverDir assureExistence. ServerDirectory storeCurrentServersIn: serverDir! !