DirectoryContents.st
author Claus Gittinger <cg@exept.de>
Wed, 17 Aug 2011 09:47:30 +0200
changeset 2627 6d4adf17cfd6
parent 2499 9a5dcca2130a
child 2745 7fb1a2c5483d
permissions -rw-r--r--
comment
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
583
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
     1
"
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
     2
 COPYRIGHT (c) 1997 by eXept Software AG
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
     3
              All Rights Reserved
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
     4
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
     5
 This software is furnished under a license and may be used
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
    10
 hereby transferred.
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
    11
"
904
f4791de2295b category change
Claus Gittinger <cg@exept.de>
parents: 880
diff changeset
    12
"{ Package: 'stx:libbasic2' }"
f4791de2295b category change
Claus Gittinger <cg@exept.de>
parents: 880
diff changeset
    13
583
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
    14
Object subclass:#DirectoryContents
2079
ca
parents: 2078
diff changeset
    15
	instanceVariableNames:'directory timeStamp contents isReadable isRootDirectory accessKey'
957
88d941cdbe8f suspend processes reading same directory
ca
parents: 951
diff changeset
    16
	classVariableNames:'CachedDirectories LockSema ReadersList'
583
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
    17
	poolDictionaries:''
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
    18
	category:'System-Support'
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
    19
!
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
    20
1093
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
    21
Object subclass:#DirectoryContentsItem
1099
81e2d4217524 keep info instead of type alone
ca
parents: 1097
diff changeset
    22
	instanceVariableNames:'info fileName'
1431
049b89c5bf60 cache mountPoints; faster directoryRead & sort
Claus Gittinger <cg@exept.de>
parents: 1393
diff changeset
    23
	classVariableNames:'CachedRemoteMountPoints CachedRemoteMountPointsTimeStamp'
1093
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
    24
	poolDictionaries:''
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
    25
	privateIn:DirectoryContents
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
    26
!
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
    27
583
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
    28
!DirectoryContents class methodsFor:'documentation'!
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
    29
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
    30
copyright
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
    31
"
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
    32
 COPYRIGHT (c) 1997 by eXept Software AG
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
    33
              All Rights Reserved
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
    34
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
    35
 This software is furnished under a license and may be used
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
    36
 only in accordance with the terms of that license and with the
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
    37
 inclusion of the above copyright notice.   This software may not
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
    38
 be provided or otherwise made available to, or used by, any
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
    39
 other person.  No title to or ownership of the software is
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
    40
 hereby transferred.
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
    41
"
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
    42
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
    43
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
    44
!
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
    45
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
    46
documentation
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
    47
"
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
    48
    DirectoryContents provides a cached view onto a fileDirectory.
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
    49
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
    50
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
    51
    Notice:
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
    52
        This class is not available in other ST-systems;
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
    53
        Applications using it may not be portable.
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
    54
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
    55
    [author:]
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
    56
        Claus Atzkern
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
    57
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
    58
    [see also:]
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
    59
        Filename
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
    60
        FileStream DirectoryStream OperatingSystem
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
    61
"
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
    62
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
    63
! !
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
    64
957
88d941cdbe8f suspend processes reading same directory
ca
parents: 951
diff changeset
    65
!DirectoryContents class methodsFor:'initialization'!
88d941cdbe8f suspend processes reading same directory
ca
parents: 951
diff changeset
    66
88d941cdbe8f suspend processes reading same directory
ca
parents: 951
diff changeset
    67
initialize
88d941cdbe8f suspend processes reading same directory
ca
parents: 951
diff changeset
    68
    "setup lock-mechanism
88d941cdbe8f suspend processes reading same directory
ca
parents: 951
diff changeset
    69
    "
88d941cdbe8f suspend processes reading same directory
ca
parents: 951
diff changeset
    70
    LockSema    := RecursionLock new.
88d941cdbe8f suspend processes reading same directory
ca
parents: 951
diff changeset
    71
    ReadersList := Dictionary new.
88d941cdbe8f suspend processes reading same directory
ca
parents: 951
diff changeset
    72
! !
88d941cdbe8f suspend processes reading same directory
ca
parents: 951
diff changeset
    73
1093
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
    74
!DirectoryContents class methodsFor:'instance creation'!
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
    75
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
    76
new
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
    77
    ^ self basicNew initialize
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
    78
! !
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
    79
583
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
    80
!DirectoryContents class methodsFor:'accessing'!
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
    81
2080
20651a2e1c4f flushCachedDirectoryFor: force flush of directory
ca
parents: 2079
diff changeset
    82
cachedDirectoryNamed:aFileOrString
20651a2e1c4f flushCachedDirectoryFor: force flush of directory
ca
parents: 2079
diff changeset
    83
    "answer the valid cached directory or nil"
20651a2e1c4f flushCachedDirectoryFor: force flush of directory
ca
parents: 2079
diff changeset
    84
20651a2e1c4f flushCachedDirectoryFor: force flush of directory
ca
parents: 2079
diff changeset
    85
    ^ self directoryAt:aFileOrString
20651a2e1c4f flushCachedDirectoryFor: force flush of directory
ca
parents: 2079
diff changeset
    86
!
20651a2e1c4f flushCachedDirectoryFor: force flush of directory
ca
parents: 2079
diff changeset
    87
957
88d941cdbe8f suspend processes reading same directory
ca
parents: 951
diff changeset
    88
directoryNamed:aDirectory
583
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
    89
    "returns the DirectoryContents for a directory named 
957
88d941cdbe8f suspend processes reading same directory
ca
parents: 951
diff changeset
    90
     aDirectoryName, aString, nil or Filename
583
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
    91
    "
2081
746a24c36e8d *** empty log message ***
ca
parents: 2080
diff changeset
    92
    |directory contents lockRead pathName addToList|
583
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
    93
2078
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
    94
    aDirectory isNil ifTrue:[^ nil].
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
    95
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
    96
    directory := aDirectory asFilename.
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
    97
    directory exists ifFalse:[ ^ nil ].
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
    98
1105
556e633a86c7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1102
diff changeset
    99
    directory := directory asAbsoluteFilename.
957
88d941cdbe8f suspend processes reading same directory
ca
parents: 951
diff changeset
   100
    contents := nil.
620
2a40beccf337 - useing Filename to read contents of a directory
ca
parents: 616
diff changeset
   101
957
88d941cdbe8f suspend processes reading same directory
ca
parents: 951
diff changeset
   102
    LockSema critical:[
88d941cdbe8f suspend processes reading same directory
ca
parents: 951
diff changeset
   103
        CachedDirectories notNil ifTrue:[
2081
746a24c36e8d *** empty log message ***
ca
parents: 2080
diff changeset
   104
            "/ remove all obsolete directories - without doing a system call
746a24c36e8d *** empty log message ***
ca
parents: 2080
diff changeset
   105
            CachedDirectories := CachedDirectories select:[:aDir| aDir timeStamp notNil ].
746a24c36e8d *** empty log message ***
ca
parents: 2080
diff changeset
   106
957
88d941cdbe8f suspend processes reading same directory
ca
parents: 951
diff changeset
   107
            contents := self directoryAt:directory.
88d941cdbe8f suspend processes reading same directory
ca
parents: 951
diff changeset
   108
88d941cdbe8f suspend processes reading same directory
ca
parents: 951
diff changeset
   109
            contents isNil ifTrue:[
2081
746a24c36e8d *** empty log message ***
ca
parents: 2080
diff changeset
   110
                |n max|
2078
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   111
957
88d941cdbe8f suspend processes reading same directory
ca
parents: 951
diff changeset
   112
                max := self maxCachedDirectories.
583
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   113
957
88d941cdbe8f suspend processes reading same directory
ca
parents: 951
diff changeset
   114
                CachedDirectories size > max ifTrue:[
2081
746a24c36e8d *** empty log message ***
ca
parents: 2080
diff changeset
   115
                    "/ remove directories with contents less 64 and not obsolete (system call)
746a24c36e8d *** empty log message ***
ca
parents: 2080
diff changeset
   116
                    CachedDirectories := CachedDirectories
746a24c36e8d *** empty log message ***
ca
parents: 2080
diff changeset
   117
                        select:[:aDir| (aDir size > 64 and:[aDir isObsolete not]) ].
2078
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   118
2081
746a24c36e8d *** empty log message ***
ca
parents: 2080
diff changeset
   119
                    n := CachedDirectories size + 2 - max.
746a24c36e8d *** empty log message ***
ca
parents: 2080
diff changeset
   120
                    n > 0 ifTrue:[
746a24c36e8d *** empty log message ***
ca
parents: 2080
diff changeset
   121
                        "/ remove oldest directories
746a24c36e8d *** empty log message ***
ca
parents: 2080
diff changeset
   122
                        CachedDirectories removeLast:n.
2078
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   123
                    ].
957
88d941cdbe8f suspend processes reading same directory
ca
parents: 951
diff changeset
   124
                ].
88d941cdbe8f suspend processes reading same directory
ca
parents: 951
diff changeset
   125
            ].
583
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   126
        ].
957
88d941cdbe8f suspend processes reading same directory
ca
parents: 951
diff changeset
   127
        contents isNil ifTrue:[
88d941cdbe8f suspend processes reading same directory
ca
parents: 951
diff changeset
   128
            ReadersList isNil ifTrue:[ReadersList := Dictionary new].
88d941cdbe8f suspend processes reading same directory
ca
parents: 951
diff changeset
   129
            pathName := directory pathName.
88d941cdbe8f suspend processes reading same directory
ca
parents: 951
diff changeset
   130
            lockRead := ReadersList at:pathName ifAbsentPut:[Semaphore forMutualExclusion].
88d941cdbe8f suspend processes reading same directory
ca
parents: 951
diff changeset
   131
        ]
88d941cdbe8f suspend processes reading same directory
ca
parents: 951
diff changeset
   132
    ].
88d941cdbe8f suspend processes reading same directory
ca
parents: 951
diff changeset
   133
    contents notNil ifTrue:[^ contents].
88d941cdbe8f suspend processes reading same directory
ca
parents: 951
diff changeset
   134
    addToList := false.
583
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   135
957
88d941cdbe8f suspend processes reading same directory
ca
parents: 951
diff changeset
   136
    lockRead critical:[
1431
049b89c5bf60 cache mountPoints; faster directoryRead & sort
Claus Gittinger <cg@exept.de>
parents: 1393
diff changeset
   137
        [  "/ test whether another task got the semaphore and
957
88d941cdbe8f suspend processes reading same directory
ca
parents: 951
diff changeset
   138
           "/ has read the directory contents
88d941cdbe8f suspend processes reading same directory
ca
parents: 951
diff changeset
   139
           (contents := self directoryAt:directory) isNil ifTrue:[
88d941cdbe8f suspend processes reading same directory
ca
parents: 951
diff changeset
   140
                "/ read the directory contents
88d941cdbe8f suspend processes reading same directory
ca
parents: 951
diff changeset
   141
                contents  := self new directory:directory.
88d941cdbe8f suspend processes reading same directory
ca
parents: 951
diff changeset
   142
                "/ only cache if the mod'Time is valid.
88d941cdbe8f suspend processes reading same directory
ca
parents: 951
diff changeset
   143
                addToList := contents timeStamp notNil.
88d941cdbe8f suspend processes reading same directory
ca
parents: 951
diff changeset
   144
            ]
1022
6a288db5312a #valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents: 974
diff changeset
   145
        ] ensure:[
957
88d941cdbe8f suspend processes reading same directory
ca
parents: 951
diff changeset
   146
            LockSema critical:[
88d941cdbe8f suspend processes reading same directory
ca
parents: 951
diff changeset
   147
                addToList ifTrue:[
88d941cdbe8f suspend processes reading same directory
ca
parents: 951
diff changeset
   148
                    CachedDirectories isNil ifTrue:[
88d941cdbe8f suspend processes reading same directory
ca
parents: 951
diff changeset
   149
                        CachedDirectories := OrderedCollection new
88d941cdbe8f suspend processes reading same directory
ca
parents: 951
diff changeset
   150
                    ].
88d941cdbe8f suspend processes reading same directory
ca
parents: 951
diff changeset
   151
                    CachedDirectories add:contents
88d941cdbe8f suspend processes reading same directory
ca
parents: 951
diff changeset
   152
                ].
88d941cdbe8f suspend processes reading same directory
ca
parents: 951
diff changeset
   153
                (lockRead isEmpty and:[ReadersList notNil]) ifTrue:[
88d941cdbe8f suspend processes reading same directory
ca
parents: 951
diff changeset
   154
                    ReadersList removeKey:pathName ifAbsent:nil
88d941cdbe8f suspend processes reading same directory
ca
parents: 951
diff changeset
   155
                ]
583
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   156
            ]
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   157
        ]
957
88d941cdbe8f suspend processes reading same directory
ca
parents: 951
diff changeset
   158
    ].    
620
2a40beccf337 - useing Filename to read contents of a directory
ca
parents: 616
diff changeset
   159
957
88d941cdbe8f suspend processes reading same directory
ca
parents: 951
diff changeset
   160
    ^ contents
583
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   161
! !
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   162
616
cb0377b446bd flush cachedDirectory list when saving a snapshot
Claus Gittinger <cg@exept.de>
parents: 583
diff changeset
   163
!DirectoryContents class methodsFor:'cache flushing'!
cb0377b446bd flush cachedDirectory list when saving a snapshot
Claus Gittinger <cg@exept.de>
parents: 583
diff changeset
   164
880
8067101a5d8b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 727
diff changeset
   165
flushCache
2421
7d70e8269bec comment/format in: #isObsolete
Claus Gittinger <cg@exept.de>
parents: 2412
diff changeset
   166
    "flush list of remembered directory contents"
880
8067101a5d8b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 727
diff changeset
   167
957
88d941cdbe8f suspend processes reading same directory
ca
parents: 951
diff changeset
   168
    LockSema critical:[ CachedDirectories := nil ].
880
8067101a5d8b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 727
diff changeset
   169
8067101a5d8b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 727
diff changeset
   170
    "
8067101a5d8b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 727
diff changeset
   171
     self flushCache
8067101a5d8b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 727
diff changeset
   172
    "
8067101a5d8b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 727
diff changeset
   173
8067101a5d8b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 727
diff changeset
   174
    "Created: / 11.2.2000 / 00:13:59 / cg"
8067101a5d8b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 727
diff changeset
   175
!
8067101a5d8b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 727
diff changeset
   176
1105
556e633a86c7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1102
diff changeset
   177
flushCachedDirectoryFor:aDirectoryOrString
958
989ff0f0d173 add new method: remove a specified directory from cash
ca
parents: 957
diff changeset
   178
    "remove directory from cache
989ff0f0d173 add new method: remove a specified directory from cash
ca
parents: 957
diff changeset
   179
    "
2130
dcbfec8558f9 added: #directoryAt:checkForValidContentsDo:
fm
parents: 2083
diff changeset
   180
    |directory|
958
989ff0f0d173 add new method: remove a specified directory from cash
ca
parents: 957
diff changeset
   181
2130
dcbfec8558f9 added: #directoryAt:checkForValidContentsDo:
fm
parents: 2083
diff changeset
   182
    aDirectoryOrString isNil ifTrue:[^ self ].                   
958
989ff0f0d173 add new method: remove a specified directory from cash
ca
parents: 957
diff changeset
   183
2078
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   184
    directory := aDirectoryOrString asFilename.
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   185
    directory isSymbolicLink ifTrue:[^ self].
958
989ff0f0d173 add new method: remove a specified directory from cash
ca
parents: 957
diff changeset
   186
2130
dcbfec8558f9 added: #directoryAt:checkForValidContentsDo:
fm
parents: 2083
diff changeset
   187
    self
dcbfec8558f9 added: #directoryAt:checkForValidContentsDo:
fm
parents: 2083
diff changeset
   188
        directoryAt:directory
dcbfec8558f9 added: #directoryAt:checkForValidContentsDo:
fm
parents: 2083
diff changeset
   189
        checkForValidContentsDo:[:aDirectory| false ].  "/ should be removed from cache
958
989ff0f0d173 add new method: remove a specified directory from cash
ca
parents: 957
diff changeset
   190
!
989ff0f0d173 add new method: remove a specified directory from cash
ca
parents: 957
diff changeset
   191
695
368ddb719976 only cache dir if its mod'time is known (for win32)
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
   192
lowSpaceCleanup
1575
Stefan Vogel <sv@exept.de>
parents: 1468
diff changeset
   193
    "flush list of remembered directory contents when low on memory"
695
368ddb719976 only cache dir if its mod'time is known (for win32)
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
   194
1134
66f96c472a47 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1105
diff changeset
   195
    self flushCache
695
368ddb719976 only cache dir if its mod'time is known (for win32)
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
   196
368ddb719976 only cache dir if its mod'time is known (for win32)
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
   197
    "
368ddb719976 only cache dir if its mod'time is known (for win32)
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
   198
     self lowSpaceCleanup
368ddb719976 only cache dir if its mod'time is known (for win32)
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
   199
    "
368ddb719976 only cache dir if its mod'time is known (for win32)
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
   200
368ddb719976 only cache dir if its mod'time is known (for win32)
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
   201
    "Created: / 18.2.1998 / 18:17:05 / cg"
368ddb719976 only cache dir if its mod'time is known (for win32)
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
   202
    "Modified: / 24.9.1998 / 17:51:15 / cg"
368ddb719976 only cache dir if its mod'time is known (for win32)
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
   203
!
368ddb719976 only cache dir if its mod'time is known (for win32)
Claus Gittinger <cg@exept.de>
parents: 679
diff changeset
   204
616
cb0377b446bd flush cachedDirectory list when saving a snapshot
Claus Gittinger <cg@exept.de>
parents: 583
diff changeset
   205
preSnapshot
1919
d52cda5ce0e7 comment
Stefan Vogel <sv@exept.de>
parents: 1575
diff changeset
   206
    "flush list of cached directory contents before saving a snapshot"
616
cb0377b446bd flush cachedDirectory list when saving a snapshot
Claus Gittinger <cg@exept.de>
parents: 583
diff changeset
   207
1349
42d24a10a4be *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1347
diff changeset
   208
    self flushCache.
616
cb0377b446bd flush cachedDirectory list when saving a snapshot
Claus Gittinger <cg@exept.de>
parents: 583
diff changeset
   209
! !
cb0377b446bd flush cachedDirectory list when saving a snapshot
Claus Gittinger <cg@exept.de>
parents: 583
diff changeset
   210
583
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   211
!DirectoryContents class methodsFor:'constants'!
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   212
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   213
maxCachedDirectories
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   214
    "returns number of maximum cached directories
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   215
    "
616
cb0377b446bd flush cachedDirectory list when saving a snapshot
Claus Gittinger <cg@exept.de>
parents: 583
diff changeset
   216
    ^ 20
cb0377b446bd flush cachedDirectory list when saving a snapshot
Claus Gittinger <cg@exept.de>
parents: 583
diff changeset
   217
cb0377b446bd flush cachedDirectory list when saving a snapshot
Claus Gittinger <cg@exept.de>
parents: 583
diff changeset
   218
    "Modified: / 25.2.1998 / 19:56:24 / cg"
583
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   219
! !
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   220
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   221
!DirectoryContents class methodsFor:'private'!
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   222
2079
ca
parents: 2078
diff changeset
   223
accessKeyForDirectory:aDirectoryOrString
ca
parents: 2078
diff changeset
   224
    "computes a fast access key to retrieve the directory in the cache
ca
parents: 2078
diff changeset
   225
    "
ca
parents: 2078
diff changeset
   226
    |key last|
ca
parents: 2078
diff changeset
   227
    
ca
parents: 2078
diff changeset
   228
    aDirectoryOrString isNil ifTrue:[^ nil ].
ca
parents: 2078
diff changeset
   229
ca
parents: 2078
diff changeset
   230
    aDirectoryOrString isFilename ifTrue:[ key := aDirectoryOrString nameString ]
ca
parents: 2078
diff changeset
   231
                                 ifFalse:[ key := aDirectoryOrString ].
ca
parents: 2078
diff changeset
   232
ca
parents: 2078
diff changeset
   233
    key size > 1 ifTrue:[
ca
parents: 2078
diff changeset
   234
        last := key last.
ca
parents: 2078
diff changeset
   235
        (last == $/ or:[last == $\]) ifTrue:[
ca
parents: 2078
diff changeset
   236
            ^ key copyWithoutLast:1.
ca
parents: 2078
diff changeset
   237
        ].
ca
parents: 2078
diff changeset
   238
    ].
ca
parents: 2078
diff changeset
   239
    ^ key
ca
parents: 2078
diff changeset
   240
!
ca
parents: 2078
diff changeset
   241
2078
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   242
directoryAt:aFileOrString
583
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   243
    "checks whether directory already exists and is valid.
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   244
     If true the directory is returned otherwise nil
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   245
    "
2130
dcbfec8558f9 added: #directoryAt:checkForValidContentsDo:
fm
parents: 2083
diff changeset
   246
    ^ self
dcbfec8558f9 added: #directoryAt:checkForValidContentsDo:
fm
parents: 2083
diff changeset
   247
        directoryAt:aFileOrString
dcbfec8558f9 added: #directoryAt:checkForValidContentsDo:
fm
parents: 2083
diff changeset
   248
        checkForValidContentsDo:[:aContents| aContents isObsolete not ].
dcbfec8558f9 added: #directoryAt:checkForValidContentsDo:
fm
parents: 2083
diff changeset
   249
!
dcbfec8558f9 added: #directoryAt:checkForValidContentsDo:
fm
parents: 2083
diff changeset
   250
dcbfec8558f9 added: #directoryAt:checkForValidContentsDo:
fm
parents: 2083
diff changeset
   251
directoryAt:aFileOrString checkForValidContentsDo:checkIsValidBlock
dcbfec8558f9 added: #directoryAt:checkForValidContentsDo:
fm
parents: 2083
diff changeset
   252
    "answer the directoryContents stored under aFileOrString in the cache.
dcbfec8558f9 added: #directoryAt:checkForValidContentsDo:
fm
parents: 2083
diff changeset
   253
     If the evaluation of the checkIsValidBlock returns false, the contents
dcbfec8558f9 added: #directoryAt:checkForValidContentsDo:
fm
parents: 2083
diff changeset
   254
     will be removed from the cache and nil is returned."
dcbfec8558f9 added: #directoryAt:checkForValidContentsDo:
fm
parents: 2083
diff changeset
   255
2079
ca
parents: 2078
diff changeset
   256
    |index directory file fastKey|
583
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   257
2079
ca
parents: 2078
diff changeset
   258
    fastKey := self accessKeyForDirectory:aFileOrString.
ca
parents: 2078
diff changeset
   259
    fastKey isNil ifTrue:[^ nil ].  "/ the name is nil
2078
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   260
957
88d941cdbe8f suspend processes reading same directory
ca
parents: 951
diff changeset
   261
    directory := nil.
88d941cdbe8f suspend processes reading same directory
ca
parents: 951
diff changeset
   262
88d941cdbe8f suspend processes reading same directory
ca
parents: 951
diff changeset
   263
    LockSema critical:[
88d941cdbe8f suspend processes reading same directory
ca
parents: 951
diff changeset
   264
        CachedDirectories notNil ifTrue:[
2079
ca
parents: 2078
diff changeset
   265
            index := CachedDirectories findFirst:[:d| d accessKey = fastKey ].
ca
parents: 2078
diff changeset
   266
2078
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   267
            index == 0 ifTrue:[
2079
ca
parents: 2078
diff changeset
   268
                file  := aFileOrString asFilename asAbsoluteFilename.
ca
parents: 2078
diff changeset
   269
                index := CachedDirectories findFirst:[:d| d directory = file ].
2078
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   270
            ].
583
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   271
957
88d941cdbe8f suspend processes reading same directory
ca
parents: 951
diff changeset
   272
            index ~~ 0 ifTrue:[
2078
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   273
                directory := CachedDirectories removeAtIndex:index.
583
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   274
2130
dcbfec8558f9 added: #directoryAt:checkForValidContentsDo:
fm
parents: 2083
diff changeset
   275
                (checkIsValidBlock value:directory) ifTrue:[
2078
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   276
                    "/ keep the last accessed directory at end
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   277
                    CachedDirectories add:directory.
2133
a739d816088e bugfix and queries
ca
parents: 2130
diff changeset
   278
                ] ifFalse:[
a739d816088e bugfix and queries
ca
parents: 2130
diff changeset
   279
                    "/ validation block answers false - return nil and removed from cache
a739d816088e bugfix and queries
ca
parents: 2130
diff changeset
   280
                    directory := nil.
2078
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   281
                ].
2133
a739d816088e bugfix and queries
ca
parents: 2130
diff changeset
   282
            ].
a739d816088e bugfix and queries
ca
parents: 2130
diff changeset
   283
        ].
583
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   284
    ].
957
88d941cdbe8f suspend processes reading same directory
ca
parents: 951
diff changeset
   285
    ^ directory
583
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   286
! !
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   287
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   288
!DirectoryContents class methodsFor:'queries'!
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   289
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   290
directoryNamed:aDirectoryName detect:aTwoArgBlock
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   291
    "evaluate the block, [:filename :isDirectory] on the directory
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   292
     contents of a directory named aDirectoryName, until the block
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   293
     returns true. If nothing detected false is returned
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   294
    "
2078
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   295
    ^ self directoryNamed:aDirectoryName detect:aTwoArgBlock onOpenErrorDo:nil
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   296
!
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   297
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   298
directoryNamed:aDirectoryName detect:aTwoArgBlock onOpenErrorDo:exceptionBlock
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   299
    "evaluate the block, [:filename :isDirectory] on the directory
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   300
     contents of a directory named aDirectoryName, until the block
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   301
     returns true. If nothing detected false is returned.
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   302
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   303
     if the directory cannot be open, the exceptionBlock is processed
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   304
     with the filename.
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   305
    "
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   306
    |directory contents isReadable file|
583
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   307
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   308
    directory := aDirectoryName asFilename.
2078
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   309
    contents  := self directoryAt:directory.
620
2a40beccf337 - useing Filename to read contents of a directory
ca
parents: 616
diff changeset
   310
2078
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   311
    contents notNil ifTrue:[
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   312
        (isReadable := contents isReadable) ifTrue:[
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   313
            contents contentsDo:[:aFile :isDir|
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   314
                (aTwoArgBlock value:aFile value:isDir) ifTrue:[^ true]
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   315
            ].
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   316
            ^ false.
1155
edcf3cfe1e93 Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents: 1147
diff changeset
   317
        ].
2078
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   318
    ] ifFalse:[
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   319
        (isReadable := directory exists) ifTrue:[
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   320
            [
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   321
                directory directoryContentsDo:[:fn |
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   322
                    file := directory construct:fn.
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   323
                    (aTwoArgBlock value:file value:(file isDirectory)) ifTrue:[
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   324
                        ^ true
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   325
                    ]
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   326
                ].
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   327
            ] on:FileStream openErrorSignal do:[:ex|
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   328
                isReadable := false.
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   329
            ].
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   330
        ].
583
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   331
    ].
2078
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   332
    (isReadable not and:[exceptionBlock notNil]) ifTrue:[
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   333
        exceptionBlock value:directory.
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   334
    ].
583
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   335
    ^ false
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   336
! !
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   337
1102
2ec96742a420 utility to get an item
Claus Gittinger <cg@exept.de>
parents: 1101
diff changeset
   338
!DirectoryContents class methodsFor:'utilities'!
2ec96742a420 utility to get an item
Claus Gittinger <cg@exept.de>
parents: 1101
diff changeset
   339
2ec96742a420 utility to get an item
Claus Gittinger <cg@exept.de>
parents: 1101
diff changeset
   340
contentsItemForFileName:aFilenameOrString 
2ec96742a420 utility to get an item
Claus Gittinger <cg@exept.de>
parents: 1101
diff changeset
   341
    | aFilename directory directoryContents|
2ec96742a420 utility to get an item
Claus Gittinger <cg@exept.de>
parents: 1101
diff changeset
   342
2ec96742a420 utility to get an item
Claus Gittinger <cg@exept.de>
parents: 1101
diff changeset
   343
    aFilename := aFilenameOrString asFilename.
2ec96742a420 utility to get an item
Claus Gittinger <cg@exept.de>
parents: 1101
diff changeset
   344
    directory := aFilename directory.
2078
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   345
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   346
    directoryContents := self directoryAt:directory.
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   347
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   348
    directoryContents notNil ifTrue:[
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   349
        directoryContents itemsDo:[:fileItemThere |
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   350
            fileItemThere fileName = aFilename ifTrue:[
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   351
                ^ fileItemThere.
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   352
            ].
1393
bb7048aaf86a care for directory without parent (network-dirs on WIN32)
Claus Gittinger <cg@exept.de>
parents: 1352
diff changeset
   353
        ].
bb7048aaf86a care for directory without parent (network-dirs on WIN32)
Claus Gittinger <cg@exept.de>
parents: 1352
diff changeset
   354
    ].
1252
933afe6d5bd6 care for directory being removed
Claus Gittinger <cg@exept.de>
parents: 1198
diff changeset
   355
2078
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   356
    aFilename exists ifFalse:[
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   357
        directoryContents notNil ifTrue:[ directoryContents beObsolete ].
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   358
        ^ nil
1102
2ec96742a420 utility to get an item
Claus Gittinger <cg@exept.de>
parents: 1101
diff changeset
   359
    ].
1105
556e633a86c7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1102
diff changeset
   360
    ^ (DirectoryContentsItem new fileName:aFilename) info:aFilename info.
1102
2ec96742a420 utility to get an item
Claus Gittinger <cg@exept.de>
parents: 1101
diff changeset
   361
! !
2ec96742a420 utility to get an item
Claus Gittinger <cg@exept.de>
parents: 1101
diff changeset
   362
583
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   363
!DirectoryContents methodsFor:'accessing'!
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   364
2079
ca
parents: 2078
diff changeset
   365
accessKey
ca
parents: 2078
diff changeset
   366
    ^ accessKey
ca
parents: 2078
diff changeset
   367
!
ca
parents: 2078
diff changeset
   368
2421
7d70e8269bec comment/format in: #isObsolete
Claus Gittinger <cg@exept.de>
parents: 2412
diff changeset
   369
beObsolete
7d70e8269bec comment/format in: #isObsolete
Claus Gittinger <cg@exept.de>
parents: 2412
diff changeset
   370
    "mark self as obsolete
7d70e8269bec comment/format in: #isObsolete
Claus Gittinger <cg@exept.de>
parents: 2412
diff changeset
   371
     clear contents and reset time"
7d70e8269bec comment/format in: #isObsolete
Claus Gittinger <cg@exept.de>
parents: 2412
diff changeset
   372
7d70e8269bec comment/format in: #isObsolete
Claus Gittinger <cg@exept.de>
parents: 2412
diff changeset
   373
    |saveCont|
7d70e8269bec comment/format in: #isObsolete
Claus Gittinger <cg@exept.de>
parents: 2412
diff changeset
   374
7d70e8269bec comment/format in: #isObsolete
Claus Gittinger <cg@exept.de>
parents: 2412
diff changeset
   375
    timeStamp := nil.
7d70e8269bec comment/format in: #isObsolete
Claus Gittinger <cg@exept.de>
parents: 2412
diff changeset
   376
    saveCont  := contents.
7d70e8269bec comment/format in: #isObsolete
Claus Gittinger <cg@exept.de>
parents: 2412
diff changeset
   377
    contents  := #().
7d70e8269bec comment/format in: #isObsolete
Claus Gittinger <cg@exept.de>
parents: 2412
diff changeset
   378
7d70e8269bec comment/format in: #isObsolete
Claus Gittinger <cg@exept.de>
parents: 2412
diff changeset
   379
    saveCont notEmptyOrNil ifTrue:[
7d70e8269bec comment/format in: #isObsolete
Claus Gittinger <cg@exept.de>
parents: 2412
diff changeset
   380
        "/ clear the info - if someone has a reference to the item
7d70e8269bec comment/format in: #isObsolete
Claus Gittinger <cg@exept.de>
parents: 2412
diff changeset
   381
        saveCont do:[:eachItem | eachItem resetInfo ].
7d70e8269bec comment/format in: #isObsolete
Claus Gittinger <cg@exept.de>
parents: 2412
diff changeset
   382
    ].
7d70e8269bec comment/format in: #isObsolete
Claus Gittinger <cg@exept.de>
parents: 2412
diff changeset
   383
!
7d70e8269bec comment/format in: #isObsolete
Claus Gittinger <cg@exept.de>
parents: 2412
diff changeset
   384
583
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   385
directory
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   386
    "returns the directoy name as Filename
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   387
    "
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   388
    ^ directory
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   389
!
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   390
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   391
modificationTime
2499
9a5dcca2130a changed:
Stefan Vogel <sv@exept.de>
parents: 2421
diff changeset
   392
    "get the last modification time of the directory.
9a5dcca2130a changed:
Stefan Vogel <sv@exept.de>
parents: 2421
diff changeset
   393
     Note that sometimes a root directory does not return
9a5dcca2130a changed:
Stefan Vogel <sv@exept.de>
parents: 2421
diff changeset
   394
     a valid modification time - so do not cache it."
9a5dcca2130a changed:
Stefan Vogel <sv@exept.de>
parents: 2421
diff changeset
   395
2078
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   396
    |modifyTime|
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   397
2499
9a5dcca2130a changed:
Stefan Vogel <sv@exept.de>
parents: 2421
diff changeset
   398
    timeStamp isNil ifTrue:[^ nil].
2071
f58e3dcf48b0 handling isRootDirectory & modificationTime
ca
parents: 2047
diff changeset
   399
2499
9a5dcca2130a changed:
Stefan Vogel <sv@exept.de>
parents: 2421
diff changeset
   400
    modifyTime := directory modificationTime.
9a5dcca2130a changed:
Stefan Vogel <sv@exept.de>
parents: 2421
diff changeset
   401
    modifyTime notNil ifTrue:[
9a5dcca2130a changed:
Stefan Vogel <sv@exept.de>
parents: 2421
diff changeset
   402
        ^ modifyTime 
9a5dcca2130a changed:
Stefan Vogel <sv@exept.de>
parents: 2421
diff changeset
   403
   ].
9a5dcca2130a changed:
Stefan Vogel <sv@exept.de>
parents: 2421
diff changeset
   404
9a5dcca2130a changed:
Stefan Vogel <sv@exept.de>
parents: 2421
diff changeset
   405
    isRootDirectory ifFalse:[
9a5dcca2130a changed:
Stefan Vogel <sv@exept.de>
parents: 2421
diff changeset
   406
        "if it is not a root directory, assume that we have no access"
9a5dcca2130a changed:
Stefan Vogel <sv@exept.de>
parents: 2421
diff changeset
   407
        isReadable := false.
9a5dcca2130a changed:
Stefan Vogel <sv@exept.de>
parents: 2421
diff changeset
   408
        self beObsolete.
2071
f58e3dcf48b0 handling isRootDirectory & modificationTime
ca
parents: 2047
diff changeset
   409
    ].
2078
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   410
    ^ nil
951
37870a37b930 consider contents as obsolete, if modification
martin
parents: 906
diff changeset
   411
!
37870a37b930 consider contents as obsolete, if modification
martin
parents: 906
diff changeset
   412
37870a37b930 consider contents as obsolete, if modification
martin
parents: 906
diff changeset
   413
timeStamp
37870a37b930 consider contents as obsolete, if modification
martin
parents: 906
diff changeset
   414
    "get the last timeStamp (when the directory info was read) of the directory
37870a37b930 consider contents as obsolete, if modification
martin
parents: 906
diff changeset
   415
    "
583
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   416
    ^ timeStamp
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   417
! !
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   418
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   419
!DirectoryContents methodsFor:'enumerating'!
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   420
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   421
contentsAndBaseNamesDo:aThreeArgBlock
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   422
    "evaluate the block on each file; the argument to the block is the
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   423
     filename, the baseName and true in case of a directory
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   424
     block arguments: [:fileName :aBaseName :isDirectory|
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   425
    "
1350
61e51decadea lazy generation of info
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   426
1093
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   427
    self itemsDo:[:eachItem |
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   428
        aThreeArgBlock 
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   429
            value:(eachItem fileName) 
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   430
            value:(eachItem baseName ) 
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   431
            value:(eachItem isDirectory)
583
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   432
    ].
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   433
!
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   434
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   435
contentsDo:aTwoArgBlock
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   436
    "evaluate the block on each file; the argument to the block is the
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   437
     filename and true in case of a directory
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   438
     block arguments: [:fileName :isDirectory|
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   439
    "
1350
61e51decadea lazy generation of info
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   440
1093
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   441
    self itemsDo:[:eachItem |
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   442
        aTwoArgBlock
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   443
            value:(eachItem fileName) 
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   444
            value:(eachItem isDirectory)
583
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   445
    ].
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   446
!
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   447
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   448
directoriesAndBasenamesDo:aTwoArgBlock
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   449
    "evaluate block on each directory; a Filename and Basename.
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   450
     The directories are sorted
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   451
    "
1350
61e51decadea lazy generation of info
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   452
1093
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   453
    self itemsDo:[:eachItem |
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   454
        eachItem isDirectory ifTrue:[
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   455
            aTwoArgBlock value:(eachItem fileName) value:(eachItem baseName)
583
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   456
        ]
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   457
    ]
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   458
!
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   459
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   460
directoriesDo:aOneArgBlock
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   461
    "evaluate block on each directory; a Filename. The directories are sorted
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   462
    "
1350
61e51decadea lazy generation of info
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   463
1093
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   464
    self itemsDo:[:eachItem |
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   465
        eachItem isDirectory ifTrue:[
1350
61e51decadea lazy generation of info
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   466
            aOneArgBlock value:(eachItem fileName) 
583
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   467
        ]
1093
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   468
    ].
583
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   469
!
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   470
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   471
filesAndBasenamesDo:aTwoArgBlock
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   472
    "evaluate block on each file; a Filename and a Basename.
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   473
     The files are sorted.
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   474
    "
1350
61e51decadea lazy generation of info
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   475
1093
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   476
    self itemsDo:[:eachItem |
1324
e51285e95b3f not ifTrue -> ifFalse
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
   477
        eachItem isDirectory ifFalse:[
1093
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   478
            aTwoArgBlock value:(eachItem fileName) value:(eachItem baseName)
583
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   479
        ]
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   480
    ]
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   481
!
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   482
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   483
filesDo:aOneArgBlock
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   484
    "evaluate block on each file; a Filename. The files are sorted.
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   485
    "
1350
61e51decadea lazy generation of info
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   486
1093
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   487
    self itemsDo:[:eachItem |
1324
e51285e95b3f not ifTrue -> ifFalse
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
   488
        eachItem isDirectory ifFalse:[
1093
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   489
            aOneArgBlock value:(eachItem fileName)
583
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   490
        ]
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   491
    ]
1093
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   492
!
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   493
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   494
itemsDo:aBlock
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   495
    "evaluate the block on each contentsItem, which contains the fileName and type info"
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   496
2421
7d70e8269bec comment/format in: #isObsolete
Claus Gittinger <cg@exept.de>
parents: 2412
diff changeset
   497
    contents do:aBlock.
583
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   498
! !
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   499
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   500
!DirectoryContents methodsFor:'instance creation'!
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   501
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   502
directory:aFilename
1155
edcf3cfe1e93 Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents: 1147
diff changeset
   503
    "instance creation; setup attributes"
edcf3cfe1e93 Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents: 1147
diff changeset
   504
2082
396cb3c74f93 instance creation - read directory contents
ca
parents: 2081
diff changeset
   505
    |time stream bname fitem|
1155
edcf3cfe1e93 Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents: 1147
diff changeset
   506
2078
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   507
    directory       := aFilename asFilename.
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   508
    isRootDirectory := directory isRootDirectory.
2079
ca
parents: 2078
diff changeset
   509
    accessKey       := self class accessKeyForDirectory:directory.
2421
7d70e8269bec comment/format in: #isObsolete
Claus Gittinger <cg@exept.de>
parents: 2412
diff changeset
   510
    contents        := OrderedCollection new.
2082
396cb3c74f93 instance creation - read directory contents
ca
parents: 2081
diff changeset
   511
    isReadable      := false.
396cb3c74f93 instance creation - read directory contents
ca
parents: 2081
diff changeset
   512
    time            := Timestamp now.   "/ directory modificationTime.
2078
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   513
1155
edcf3cfe1e93 Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents: 1147
diff changeset
   514
    [
2082
396cb3c74f93 instance creation - read directory contents
ca
parents: 2081
diff changeset
   515
        [
396cb3c74f93 instance creation - read directory contents
ca
parents: 2081
diff changeset
   516
            stream := DirectoryStream directoryNamed:(directory osNameForDirectoryContents).
396cb3c74f93 instance creation - read directory contents
ca
parents: 2081
diff changeset
   517
396cb3c74f93 instance creation - read directory contents
ca
parents: 2081
diff changeset
   518
            stream notNil ifTrue:[
396cb3c74f93 instance creation - read directory contents
ca
parents: 2081
diff changeset
   519
                [ (stream atEnd or:[(bname := stream nextLine) isNil]) ] whileFalse:[
396cb3c74f93 instance creation - read directory contents
ca
parents: 2081
diff changeset
   520
                    (bname = '.' or:[bname = '..']) ifFalse:[
396cb3c74f93 instance creation - read directory contents
ca
parents: 2081
diff changeset
   521
                        fitem := DirectoryContentsItem fileName:(directory construct:bname).
1431
049b89c5bf60 cache mountPoints; faster directoryRead & sort
Claus Gittinger <cg@exept.de>
parents: 1393
diff changeset
   522
2082
396cb3c74f93 instance creation - read directory contents
ca
parents: 2081
diff changeset
   523
                        "/ get info now - cashed under window (apithreads.c)
2083
fb059bbd81e6 *** empty log message ***
ca
parents: 2082
diff changeset
   524
                        fitem updateInfo.
2082
396cb3c74f93 instance creation - read directory contents
ca
parents: 2081
diff changeset
   525
                        contents add:fitem.
396cb3c74f93 instance creation - read directory contents
ca
parents: 2081
diff changeset
   526
                    ].
396cb3c74f93 instance creation - read directory contents
ca
parents: 2081
diff changeset
   527
                ].
396cb3c74f93 instance creation - read directory contents
ca
parents: 2081
diff changeset
   528
                isReadable := true.
396cb3c74f93 instance creation - read directory contents
ca
parents: 2081
diff changeset
   529
            ].
396cb3c74f93 instance creation - read directory contents
ca
parents: 2081
diff changeset
   530
        ] on:FileStream openErrorSignal do:[:ex|
396cb3c74f93 instance creation - read directory contents
ca
parents: 2081
diff changeset
   531
            isReadable := false.
2078
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   532
        ].
2082
396cb3c74f93 instance creation - read directory contents
ca
parents: 2081
diff changeset
   533
    ] ensure:[
396cb3c74f93 instance creation - read directory contents
ca
parents: 2081
diff changeset
   534
        stream notNil ifTrue:[ stream close ].
396cb3c74f93 instance creation - read directory contents
ca
parents: 2081
diff changeset
   535
        isReadable ifFalse:[ contents := #() ].
1093
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   536
    ].
2421
7d70e8269bec comment/format in: #isObsolete
Claus Gittinger <cg@exept.de>
parents: 2412
diff changeset
   537
    contents sort:[:a :b| a nameString < b nameString ].
7d70e8269bec comment/format in: #isObsolete
Claus Gittinger <cg@exept.de>
parents: 2412
diff changeset
   538
    contents := contents asArray.
2082
396cb3c74f93 instance creation - read directory contents
ca
parents: 2081
diff changeset
   539
    timeStamp := time.
1093
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   540
! !
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   541
2078
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   542
!DirectoryContents methodsFor:'obsolete'!
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   543
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   544
updateContents
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   545
    <resource:#obsolete>
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   546
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   547
    "ensure that the file-info os present for every item
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   548
     ** obsolete - access info if required"
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   549
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   550
    "/    contents do:[:eachItem | eachItem updateInfo ].
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   551
! !
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   552
1093
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   553
!DirectoryContents methodsFor:'printing'!
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   554
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   555
printOn:aStream
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   556
    aStream nextPutAll:'DirectoryContents of: '.
2078
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   557
    aStream nextPutAll:(directory pathName).
583
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   558
! !
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   559
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   560
!DirectoryContents methodsFor:'queries'!
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   561
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   562
isObsolete
1350
61e51decadea lazy generation of info
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   563
    "returns true if the directory contents represented by the receiver is obsolete
61e51decadea lazy generation of info
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   564
     (i.e. if the fileSystems directory has been changed in the meanwhile)
583
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   565
    "
974
c4be514ddd96 fix for windows bug (directory has no modification time)
Claus Gittinger <cg@exept.de>
parents: 958
diff changeset
   566
    |mt|
679
ce7aed726aff checkin from browser
Claus Gittinger <cg@exept.de>
parents: 620
diff changeset
   567
974
c4be514ddd96 fix for windows bug (directory has no modification time)
Claus Gittinger <cg@exept.de>
parents: 958
diff changeset
   568
    timeStamp isNil ifTrue:[^ true].
2071
f58e3dcf48b0 handling isRootDirectory & modificationTime
ca
parents: 2047
diff changeset
   569
f58e3dcf48b0 handling isRootDirectory & modificationTime
ca
parents: 2047
diff changeset
   570
    mt := self modificationTime.
f58e3dcf48b0 handling isRootDirectory & modificationTime
ca
parents: 2047
diff changeset
   571
    mt isNil ifTrue:[^ true ].
f58e3dcf48b0 handling isRootDirectory & modificationTime
ca
parents: 2047
diff changeset
   572
2499
9a5dcca2130a changed:
Stefan Vogel <sv@exept.de>
parents: 2421
diff changeset
   573
    "we compare only seconds, since the modification time is not as (millisecond) accurate as the timestamp"
9a5dcca2130a changed:
Stefan Vogel <sv@exept.de>
parents: 2421
diff changeset
   574
    timeStamp getSeconds < mt getSeconds ifTrue:[
9a5dcca2130a changed:
Stefan Vogel <sv@exept.de>
parents: 2421
diff changeset
   575
        self beObsolete.
9a5dcca2130a changed:
Stefan Vogel <sv@exept.de>
parents: 2421
diff changeset
   576
        ^ true.
2071
f58e3dcf48b0 handling isRootDirectory & modificationTime
ca
parents: 2047
diff changeset
   577
    ].
974
c4be514ddd96 fix for windows bug (directory has no modification time)
Claus Gittinger <cg@exept.de>
parents: 958
diff changeset
   578
    ^ false
2071
f58e3dcf48b0 handling isRootDirectory & modificationTime
ca
parents: 2047
diff changeset
   579
!
974
c4be514ddd96 fix for windows bug (directory has no modification time)
Claus Gittinger <cg@exept.de>
parents: 958
diff changeset
   580
2078
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   581
isReadable
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   582
    "answer true if the directory is readable
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   583
     no open error raised during reading the directory"
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   584
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   585
    ^ isReadable
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   586
!
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   587
2071
f58e3dcf48b0 handling isRootDirectory & modificationTime
ca
parents: 2047
diff changeset
   588
isRootDirectory
2078
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   589
    ^ isRootDirectory
906
30c1ab2aee8d category change
Claus Gittinger <cg@exept.de>
parents: 904
diff changeset
   590
!
30c1ab2aee8d category change
Claus Gittinger <cg@exept.de>
parents: 904
diff changeset
   591
30c1ab2aee8d category change
Claus Gittinger <cg@exept.de>
parents: 904
diff changeset
   592
size
30c1ab2aee8d category change
Claus Gittinger <cg@exept.de>
parents: 904
diff changeset
   593
    "get number of files including directories in the directory
30c1ab2aee8d category change
Claus Gittinger <cg@exept.de>
parents: 904
diff changeset
   594
    "
1093
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   595
    ^ contents size
904
f4791de2295b category change
Claus Gittinger <cg@exept.de>
parents: 880
diff changeset
   596
! !
f4791de2295b category change
Claus Gittinger <cg@exept.de>
parents: 880
diff changeset
   597
f4791de2295b category change
Claus Gittinger <cg@exept.de>
parents: 880
diff changeset
   598
!DirectoryContents methodsFor:'testing'!
f4791de2295b category change
Claus Gittinger <cg@exept.de>
parents: 880
diff changeset
   599
2080
20651a2e1c4f flushCachedDirectoryFor: force flush of directory
ca
parents: 2079
diff changeset
   600
includesIdentical:anItem
20651a2e1c4f flushCachedDirectoryFor: force flush of directory
ca
parents: 2079
diff changeset
   601
    ^ contents includesIdentical:anItem
20651a2e1c4f flushCachedDirectoryFor: force flush of directory
ca
parents: 2079
diff changeset
   602
!
20651a2e1c4f flushCachedDirectoryFor: force flush of directory
ca
parents: 2079
diff changeset
   603
904
f4791de2295b category change
Claus Gittinger <cg@exept.de>
parents: 880
diff changeset
   604
isEmpty
2421
7d70e8269bec comment/format in: #isObsolete
Claus Gittinger <cg@exept.de>
parents: 2412
diff changeset
   605
    "returns true if directory is empty
904
f4791de2295b category change
Claus Gittinger <cg@exept.de>
parents: 880
diff changeset
   606
    "
1093
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   607
    ^ contents size == 0
583
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   608
!
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   609
2133
a739d816088e bugfix and queries
ca
parents: 2130
diff changeset
   610
isEmptyOrNil
2627
6d4adf17cfd6 comment
Claus Gittinger <cg@exept.de>
parents: 2499
diff changeset
   611
    "return true if I am nil or an empty collection" 
6d4adf17cfd6 comment
Claus Gittinger <cg@exept.de>
parents: 2499
diff changeset
   612
2133
a739d816088e bugfix and queries
ca
parents: 2130
diff changeset
   613
    ^ contents size == 0
2627
6d4adf17cfd6 comment
Claus Gittinger <cg@exept.de>
parents: 2499
diff changeset
   614
6d4adf17cfd6 comment
Claus Gittinger <cg@exept.de>
parents: 2499
diff changeset
   615
    "Modified (comment): / 17-08-2011 / 09:30:15 / cg"
2133
a739d816088e bugfix and queries
ca
parents: 2130
diff changeset
   616
!
a739d816088e bugfix and queries
ca
parents: 2130
diff changeset
   617
583
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   618
notEmpty
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   619
    "returns true if directory is not empty
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   620
    "
1093
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   621
    ^ contents size ~~ 0
2133
a739d816088e bugfix and queries
ca
parents: 2130
diff changeset
   622
!
a739d816088e bugfix and queries
ca
parents: 2130
diff changeset
   623
a739d816088e bugfix and queries
ca
parents: 2130
diff changeset
   624
notEmptyOrNil
a739d816088e bugfix and queries
ca
parents: 2130
diff changeset
   625
    "returns true if directory is not empty
a739d816088e bugfix and queries
ca
parents: 2130
diff changeset
   626
    "
a739d816088e bugfix and queries
ca
parents: 2130
diff changeset
   627
    ^ contents size ~~ 0
1093
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   628
! !
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   629
2082
396cb3c74f93 instance creation - read directory contents
ca
parents: 2081
diff changeset
   630
!DirectoryContents::DirectoryContentsItem class methodsFor:'instance creation'!
396cb3c74f93 instance creation - read directory contents
ca
parents: 2081
diff changeset
   631
396cb3c74f93 instance creation - read directory contents
ca
parents: 2081
diff changeset
   632
fileName:aFilename
396cb3c74f93 instance creation - read directory contents
ca
parents: 2081
diff changeset
   633
    ^ self new fileName:aFilename.
396cb3c74f93 instance creation - read directory contents
ca
parents: 2081
diff changeset
   634
! !
396cb3c74f93 instance creation - read directory contents
ca
parents: 2081
diff changeset
   635
1093
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   636
!DirectoryContents::DirectoryContentsItem methodsFor:'accessing'!
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   637
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   638
baseName
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   639
    ^ fileName baseName
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   640
!
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   641
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   642
fileName
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   643
    ^ fileName
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   644
!
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   645
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   646
fileName:something
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   647
    "set the value of the instance variable 'fileName' (automatically generated)"
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   648
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   649
    fileName := something.
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   650
!
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   651
1100
a8c44ef83781 checkin from browser
ca
parents: 1099
diff changeset
   652
info
1350
61e51decadea lazy generation of info
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   653
    info isNil ifTrue:[
61e51decadea lazy generation of info
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   654
        self updateInfo.
61e51decadea lazy generation of info
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   655
    ].
1100
a8c44ef83781 checkin from browser
ca
parents: 1099
diff changeset
   656
    info isSymbol ifTrue:[^ nil]. "/ a remote directory
a8c44ef83781 checkin from browser
ca
parents: 1099
diff changeset
   657
    ^ info
a8c44ef83781 checkin from browser
ca
parents: 1099
diff changeset
   658
!
a8c44ef83781 checkin from browser
ca
parents: 1099
diff changeset
   659
1099
81e2d4217524 keep info instead of type alone
ca
parents: 1097
diff changeset
   660
info:something
81e2d4217524 keep info instead of type alone
ca
parents: 1097
diff changeset
   661
    "set the value of the instance variable 'type' (automatically generated)"
81e2d4217524 keep info instead of type alone
ca
parents: 1097
diff changeset
   662
81e2d4217524 keep info instead of type alone
ca
parents: 1097
diff changeset
   663
    info := something.
81e2d4217524 keep info instead of type alone
ca
parents: 1097
diff changeset
   664
!
81e2d4217524 keep info instead of type alone
ca
parents: 1097
diff changeset
   665
2082
396cb3c74f93 instance creation - read directory contents
ca
parents: 2081
diff changeset
   666
nameString
396cb3c74f93 instance creation - read directory contents
ca
parents: 2081
diff changeset
   667
    "raw access to nameString"
396cb3c74f93 instance creation - read directory contents
ca
parents: 2081
diff changeset
   668
396cb3c74f93 instance creation - read directory contents
ca
parents: 2081
diff changeset
   669
    ^ fileName nameString
396cb3c74f93 instance creation - read directory contents
ca
parents: 2081
diff changeset
   670
!
396cb3c74f93 instance creation - read directory contents
ca
parents: 2081
diff changeset
   671
1093
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   672
type
1350
61e51decadea lazy generation of info
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   673
    info isNil ifTrue:[
61e51decadea lazy generation of info
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   674
        self updateInfo.
61e51decadea lazy generation of info
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   675
    ].
1099
81e2d4217524 keep info instead of type alone
ca
parents: 1097
diff changeset
   676
    info isSymbol ifTrue:[^ info].
81e2d4217524 keep info instead of type alone
ca
parents: 1097
diff changeset
   677
    ^ info type
1093
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   678
! !
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   679
1350
61e51decadea lazy generation of info
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   680
!DirectoryContents::DirectoryContentsItem methodsFor:'misc'!
61e51decadea lazy generation of info
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   681
1431
049b89c5bf60 cache mountPoints; faster directoryRead & sort
Claus Gittinger <cg@exept.de>
parents: 1393
diff changeset
   682
cachedRemoteMountPoints
049b89c5bf60 cache mountPoints; faster directoryRead & sort
Claus Gittinger <cg@exept.de>
parents: 1393
diff changeset
   683
    |mountPoints now|
049b89c5bf60 cache mountPoints; faster directoryRead & sort
Claus Gittinger <cg@exept.de>
parents: 1393
diff changeset
   684
049b89c5bf60 cache mountPoints; faster directoryRead & sort
Claus Gittinger <cg@exept.de>
parents: 1393
diff changeset
   685
    mountPoints := CachedRemoteMountPoints.
049b89c5bf60 cache mountPoints; faster directoryRead & sort
Claus Gittinger <cg@exept.de>
parents: 1393
diff changeset
   686
049b89c5bf60 cache mountPoints; faster directoryRead & sort
Claus Gittinger <cg@exept.de>
parents: 1393
diff changeset
   687
    (mountPoints isNil
049b89c5bf60 cache mountPoints; faster directoryRead & sort
Claus Gittinger <cg@exept.de>
parents: 1393
diff changeset
   688
    or:[ CachedRemoteMountPointsTimeStamp isNil
049b89c5bf60 cache mountPoints; faster directoryRead & sort
Claus Gittinger <cg@exept.de>
parents: 1393
diff changeset
   689
    or:[ now := Timestamp now.
049b89c5bf60 cache mountPoints; faster directoryRead & sort
Claus Gittinger <cg@exept.de>
parents: 1393
diff changeset
   690
         (now - CachedRemoteMountPointsTimeStamp) > 30 
049b89c5bf60 cache mountPoints; faster directoryRead & sort
Claus Gittinger <cg@exept.de>
parents: 1393
diff changeset
   691
    ]]) ifTrue:[
049b89c5bf60 cache mountPoints; faster directoryRead & sort
Claus Gittinger <cg@exept.de>
parents: 1393
diff changeset
   692
        CachedRemoteMountPointsTimeStamp := now.
049b89c5bf60 cache mountPoints; faster directoryRead & sort
Claus Gittinger <cg@exept.de>
parents: 1393
diff changeset
   693
        mountPoints := OperatingSystem mountPoints.
049b89c5bf60 cache mountPoints; faster directoryRead & sort
Claus Gittinger <cg@exept.de>
parents: 1393
diff changeset
   694
        mountPoints := mountPoints select:[:mp | mp isRemote].
049b89c5bf60 cache mountPoints; faster directoryRead & sort
Claus Gittinger <cg@exept.de>
parents: 1393
diff changeset
   695
        CachedRemoteMountPoints := mountPoints.
049b89c5bf60 cache mountPoints; faster directoryRead & sort
Claus Gittinger <cg@exept.de>
parents: 1393
diff changeset
   696
    ].
049b89c5bf60 cache mountPoints; faster directoryRead & sort
Claus Gittinger <cg@exept.de>
parents: 1393
diff changeset
   697
049b89c5bf60 cache mountPoints; faster directoryRead & sort
Claus Gittinger <cg@exept.de>
parents: 1393
diff changeset
   698
    ^ mountPoints.
049b89c5bf60 cache mountPoints; faster directoryRead & sort
Claus Gittinger <cg@exept.de>
parents: 1393
diff changeset
   699
!
049b89c5bf60 cache mountPoints; faster directoryRead & sort
Claus Gittinger <cg@exept.de>
parents: 1393
diff changeset
   700
2078
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   701
resetAttributes
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   702
    "reset the attributes... done if I'am a normal file"
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   703
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   704
    (info isNil or:[info isSymbol]) ifTrue:[^ self ].
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   705
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   706
    self isDirectory ifFalse:[
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   707
        info := nil.
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   708
    ].
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   709
!
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   710
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   711
resetInfo
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   712
    info := nil.
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   713
!
a196d0ebe6fc rework - optimization and bugfixes concerning cache
ca
parents: 2074
diff changeset
   714
1350
61e51decadea lazy generation of info
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   715
updateInfo
2047
16c159894d3f *** empty log message ***
ca
parents: 2046
diff changeset
   716
    "ensure that the file-info is present
16c159894d3f *** empty log message ***
ca
parents: 2046
diff changeset
   717
DirectoryContents flushCache
16c159894d3f *** empty log message ***
ca
parents: 2046
diff changeset
   718
"
1468
476e360d4aeb #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 1435
diff changeset
   719
    
2083
fb059bbd81e6 *** empty log message ***
ca
parents: 2082
diff changeset
   720
    |mountPoint nameString linkName|
1350
61e51decadea lazy generation of info
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   721
61e51decadea lazy generation of info
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   722
    info isNil ifTrue:[
2083
fb059bbd81e6 *** empty log message ***
ca
parents: 2082
diff changeset
   723
"/        self assert:[fileName isAbsolute].    -> is a windows call
1468
476e360d4aeb #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 1435
diff changeset
   724
        info := fileName linkInfo.
2047
16c159894d3f *** empty log message ***
ca
parents: 2046
diff changeset
   725
1468
476e360d4aeb #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 1435
diff changeset
   726
        (info notNil and:[info isSymbolicLink]) ifTrue:[
2047
16c159894d3f *** empty log message ***
ca
parents: 2046
diff changeset
   727
            OperatingSystem isMSWINDOWSlike ifFalse:[
16c159894d3f *** empty log message ***
ca
parents: 2046
diff changeset
   728
                linkName := info path.
2046
0ca98ed5fb80 handling of symbolic links
ca
parents: 1919
diff changeset
   729
2047
16c159894d3f *** empty log message ***
ca
parents: 2046
diff changeset
   730
                linkName notNil ifTrue:[
16c159894d3f *** empty log message ***
ca
parents: 2046
diff changeset
   731
                    "have to check for both link and link target"
2083
fb059bbd81e6 *** empty log message ***
ca
parents: 2082
diff changeset
   732
                    mountPoint := self cachedRemoteMountPoints 
2047
16c159894d3f *** empty log message ***
ca
parents: 2046
diff changeset
   733
                                detect:[:mInfo | |p|
16c159894d3f *** empty log message ***
ca
parents: 2046
diff changeset
   734
                                    p := mInfo mountPointPath.
16c159894d3f *** empty log message ***
ca
parents: 2046
diff changeset
   735
                                    ((linkName startsWith:p) and:[ linkName startsWith:(p , '/') ])
16c159894d3f *** empty log message ***
ca
parents: 2046
diff changeset
   736
                                ]
16c159894d3f *** empty log message ***
ca
parents: 2046
diff changeset
   737
                                ifNone:nil.
16c159894d3f *** empty log message ***
ca
parents: 2046
diff changeset
   738
16c159894d3f *** empty log message ***
ca
parents: 2046
diff changeset
   739
                    info := fileName info.  "get the info of the link target"   
16c159894d3f *** empty log message ***
ca
parents: 2046
diff changeset
   740
                ].
16c159894d3f *** empty log message ***
ca
parents: 2046
diff changeset
   741
            ].
1351
9741c3cbc395 avoid blocking on mounted directories;
Claus Gittinger <cg@exept.de>
parents: 1350
diff changeset
   742
        ] ifFalse:[
1468
476e360d4aeb #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 1435
diff changeset
   743
            "have to check for mountPoint only"
2083
fb059bbd81e6 *** empty log message ***
ca
parents: 2082
diff changeset
   744
            nameString := fileName name.
fb059bbd81e6 *** empty log message ***
ca
parents: 2082
diff changeset
   745
fb059bbd81e6 *** empty log message ***
ca
parents: 2082
diff changeset
   746
            mountPoint := self cachedRemoteMountPoints 
1468
476e360d4aeb #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 1435
diff changeset
   747
                        detect:[:mInfo | mInfo mountPointPath = nameString ]
476e360d4aeb #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 1435
diff changeset
   748
                        ifNone:nil.
1351
9741c3cbc395 avoid blocking on mounted directories;
Claus Gittinger <cg@exept.de>
parents: 1350
diff changeset
   749
        ].
2047
16c159894d3f *** empty log message ***
ca
parents: 2046
diff changeset
   750
        mountPoint notNil ifTrue:[
1350
61e51decadea lazy generation of info
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   751
            info := #remoteDirectory.
61e51decadea lazy generation of info
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   752
        ] ifFalse:[
61e51decadea lazy generation of info
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   753
            info isNil ifTrue:[
61e51decadea lazy generation of info
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   754
                "/ broken symbolic link
61e51decadea lazy generation of info
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   755
                info := #symbolicLink.
61e51decadea lazy generation of info
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   756
            ]
61e51decadea lazy generation of info
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   757
        ].
61e51decadea lazy generation of info
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   758
    ].
61e51decadea lazy generation of info
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   759
! !
61e51decadea lazy generation of info
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   760
1093
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   761
!DirectoryContents::DirectoryContentsItem methodsFor:'printing'!
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   762
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   763
printOn:aStream
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   764
    aStream nextPutAll:'DirectoryContentsItem for: '.
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   765
    fileName printOn:aStream.
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   766
! !
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   767
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   768
!DirectoryContents::DirectoryContentsItem methodsFor:'queries'!
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   769
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   770
isDirectory
1099
81e2d4217524 keep info instead of type alone
ca
parents: 1097
diff changeset
   771
    |t|
81e2d4217524 keep info instead of type alone
ca
parents: 1097
diff changeset
   772
81e2d4217524 keep info instead of type alone
ca
parents: 1097
diff changeset
   773
    t := self type.
81e2d4217524 keep info instead of type alone
ca
parents: 1097
diff changeset
   774
    ^ (t == #directory or:[t == #remoteDirectory])
1093
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   775
!
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   776
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   777
isRemoteDirectory
2074
8a4ffdd9fddc isSymbolicLink
ca
parents: 2071
diff changeset
   778
    ^ self type == #remoteDirectory
8a4ffdd9fddc isSymbolicLink
ca
parents: 2071
diff changeset
   779
!
8a4ffdd9fddc isSymbolicLink
ca
parents: 2071
diff changeset
   780
2080
20651a2e1c4f flushCachedDirectoryFor: force flush of directory
ca
parents: 2079
diff changeset
   781
isSpecialFile
2412
6814ebed2138 bugfix: isSymbolicLink
ca
parents: 2133
diff changeset
   782
    |type|
6814ebed2138 bugfix: isSymbolicLink
ca
parents: 2133
diff changeset
   783
6814ebed2138 bugfix: isSymbolicLink
ca
parents: 2133
diff changeset
   784
    type := self type.
2080
20651a2e1c4f flushCachedDirectoryFor: force flush of directory
ca
parents: 2079
diff changeset
   785
2412
6814ebed2138 bugfix: isSymbolicLink
ca
parents: 2133
diff changeset
   786
    ^ (type ~~ #directory
6814ebed2138 bugfix: isSymbolicLink
ca
parents: 2133
diff changeset
   787
        and:[type ~~ #remoteDirectory
6814ebed2138 bugfix: isSymbolicLink
ca
parents: 2133
diff changeset
   788
        and:[type ~~ #regular
6814ebed2138 bugfix: isSymbolicLink
ca
parents: 2133
diff changeset
   789
        and:[type ~~ #symbolicLink
6814ebed2138 bugfix: isSymbolicLink
ca
parents: 2133
diff changeset
   790
    ]]])
2080
20651a2e1c4f flushCachedDirectoryFor: force flush of directory
ca
parents: 2079
diff changeset
   791
!
20651a2e1c4f flushCachedDirectoryFor: force flush of directory
ca
parents: 2079
diff changeset
   792
2074
8a4ffdd9fddc isSymbolicLink
ca
parents: 2071
diff changeset
   793
isSymbolicLink
2412
6814ebed2138 bugfix: isSymbolicLink
ca
parents: 2133
diff changeset
   794
    ^ self type == #symbolicLink
583
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   795
! !
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   796
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   797
!DirectoryContents class methodsFor:'documentation'!
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   798
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   799
version
2627
6d4adf17cfd6 comment
Claus Gittinger <cg@exept.de>
parents: 2499
diff changeset
   800
    ^ '$Header: /cvs/stx/stx/libbasic2/DirectoryContents.st,v 1.58 2011-08-17 07:47:30 cg Exp $'
2412
6814ebed2138 bugfix: isSymbolicLink
ca
parents: 2133
diff changeset
   801
!
6814ebed2138 bugfix: isSymbolicLink
ca
parents: 2133
diff changeset
   802
6814ebed2138 bugfix: isSymbolicLink
ca
parents: 2133
diff changeset
   803
version_CVS
2627
6d4adf17cfd6 comment
Claus Gittinger <cg@exept.de>
parents: 2499
diff changeset
   804
    ^ '$Header: /cvs/stx/stx/libbasic2/DirectoryContents.st,v 1.58 2011-08-17 07:47:30 cg Exp $'
583
3298b0ca7927 intitial checkin
ca
parents:
diff changeset
   805
! !
1093
052299fc7594 mark remoteDirectories specially
penk
parents: 1022
diff changeset
   806
957
88d941cdbe8f suspend processes reading same directory
ca
parents: 951
diff changeset
   807
DirectoryContents initialize!