The Magic of FileSystem

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

The Magic of FileSystem

Sean P. DeNigris
Administrator
This...
    localFileName: aString
        | dir entry parent fileNameWithoutTrailingSlash |
        super localFileName: aString.
        parent := FileDirectory default.
       
        self flag: 'directoryExists: fails if trailing slash. Replace this whole mess with FS'.
        fileNameWithoutTrailingSlash := fileName last = $/ ifTrue: [ fileName allButLast ] ifFalse: [ fileName ].
        (parent directoryExists: fileNameWithoutTrailingSlash) ifTrue: [
                dir := FileDirectory on: (parent fullNameFor: fileName).
                entry := dir directoryEntry.
                self modifiedAt: (DateAndTime fromSeconds: entry modificationTime) ].
        fileName last = $/ ifFalse: [ fileName := fileName, '/' ].
(which I *think* had an undiscovered bug, invisible due to the complexity)

vs. This...
    localFileName: aString

        | file |
        super localFileName: aString.
        file := aString asFileReference.
        file exists ifFalse: [ ^ self ].
        self modifiedAt: file entry modificationTime.

Ahhhh...

Cheers,
Sean
Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: The Magic of FileSystem

Stéphane Ducasse
:)
I want the same with OPAL :)

Stef


> This...
>    localFileName: aString
> | dir entry parent fileNameWithoutTrailingSlash |
> super localFileName: aString.
> parent := FileDirectory default.
>
> self flag: 'directoryExists: fails if trailing slash. Replace this whole
> mess with FS'.
> fileNameWithoutTrailingSlash := fileName last = $/ ifTrue: [ fileName
> allButLast ] ifFalse: [ fileName ].
> (parent directoryExists: fileNameWithoutTrailingSlash) ifTrue: [
> dir := FileDirectory on: (parent fullNameFor: fileName).
> entry := dir directoryEntry.
> self modifiedAt: (DateAndTime fromSeconds: entry modificationTime) ].
> fileName last = $/ ifFalse: [ fileName := fileName, '/' ].
> (which I *think* had an undiscovered bug, invisible due to the complexity)
>
> vs. This...
>    localFileName: aString
>
> | file |
> super localFileName: aString.
> file := aString asFileReference.
> file exists ifFalse: [ ^ self ].
> self modifiedAt: file entry modificationTime.
>
> Ahhhh...
>
> Cheers,
> Sean
>
> --
> View this message in context: http://forum.world.st/The-Magic-of-FileSystem-tp4635471.html
> Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
>