eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'DirectoryContents':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: DirectoryContents


Inheritance:

   Object
   |
   +--DirectoryContents

Package:
stx:libbasic2
Category:
System-Support
Version:
rev: 1.79 date: 2022/10/14 19:21:32
user: stefan
file: DirectoryContents.st directory: libbasic2
module: stx stc-classLibrary: libbasic2

Description:


DirectoryContents provides a cached view onto a fileDirectory.


Notice:
    This class is not available in other ST-systems;
    Applications using it may not be portable.

copyright

COPYRIGHT (c) 1997 by eXept Software AG All Rights Reserved This software is furnished under a license and may be used only in accordance with the terms of that license and with the inclusion of the above copyright notice. This software may not be provided or otherwise made available to, or used by, any other person. No title to or ownership of the software is hereby transferred.

Class protocol:

accessing
o  cachedDirectoryNamed: aFileOrString
answer the valid cached directory or nil

o  directoryNamed: aDirectoryFilenameOrString
returns the DirectoryContents for a directory named
aDirectoryName, aString, nil or Filename

Usage example(s):

        self directoryNamed:'/tmp'.
        self directoryNamed:'/home'.
        self directoryNamed:'/etc'.

cache flushing
o  flushCache
flush list of remembered directory contents

Usage example(s):

     self flushCache

o  flushCachedDirectoryFor: aDirectoryOrString
remove directory from cache

cleanup
o  lowSpaceCleanup
flush list of remembered directory contents when low on memory

Usage example(s):

     self lowSpaceCleanup

constants
o  maxCachedDirectories
returns number of maximum cached directories

initialization
o  initialize
Modified (comment): / 08-02-2017 / 15:47:06 / stefan

instance creation
o  new
(comment from inherited method)
return an instance of myself without indexed variables

private
o  accessKeyForDirectory: aDirectoryOrString
computes a fast access key to retrieve the directory in the cache

o  directoryAt: aFileOrString
checks whether directory already exists and is valid.
If true the directory is returned otherwise nil

o  directoryAt: aFileOrString checkForValidContentsDo: checkIsValidBlock
answer the directoryContents stored under aFileOrString in the cache.
If the evaluation of the checkIsValidBlock returns false, the contents
will be removed from the cache and nil is returned.

queries
o  directoryNamed: aDirectoryName detect: aTwoArgBlock
evaluate the block, [:filename :isDirectory] on the directory
contents of a directory named aDirectoryName, until the block
returns true. If nothing detected false is returned

o  directoryNamed: aDirectoryName detect: aTwoArgBlock onOpenErrorDo: exceptionBlock
evaluate the block, [:filename :isDirectory] on the directory
contents of a directory named aDirectoryName, until the block
returns true. If nothing detected false is returned.

if the directory cannot be opened, the exceptionBlock is processed
with the filename.

startup & release
o  preSnapshot
flush list of cached directory contents before saving a snapshot
(do not save them in the image)

utilities
o  contentsItemForFileName: aFilenameOrString


Instance protocol:

accessing
o  accessKey

o  beObsolete
mark self as obsolete
clear contents and reset time

o  directory
returns the directoy name as Filename

o  modificationTime
get the last modification time of the directory.
Note that sometimes a root directory does not return
a valid modification time - so do not cache it.

o  timeStamp
get the last timeStamp (when the directory info was read) of the directory

enumerating
o  contentsAndBaseNamesDo: aThreeArgBlock
evaluate the block on each file; the argument to the block is the
filename, the baseName and true in case of a directory
block arguments: [:fileName :aBaseName :isDirectory|

o  contentsDo: aTwoArgBlock
evaluate the block on each file; the argument to the block is the
filename and true in case of a directory
block arguments: [:fileName :isDirectory|

o  directoriesAndBasenamesDo: aTwoArgBlock
evaluate block on each directory; a Filename and Basename.
The directories are sorted

o  directoriesDo: aOneArgBlock
evaluate block on each directory; a Filename. The directories are sorted

o  filesAndBasenamesDo: aTwoArgBlock
evaluate block on each file; a Filename and a Basename.
The files are sorted.

o  filesDo: aOneArgBlock
evaluate block on each file; a Filename. The files are sorted.

o  itemsDo: aBlock
evaluate the block on each contentsItem, which contains the fileName and type info

instance creation
o  directory: aFilename
DirectoryContents new directory:'.'

obsolete
o  updateContents
ensure that the file-info os present for every item
** obsolete - access info if required

** This is an obsolete interface - do not use it (it may vanish in future versions) **

printing
o  printOn: aStream
(comment from inherited method)
append a user printed representation of the receiver to aStream.
The format is suitable for a human - not meant to be read back.

The default here is to output the receiver's class name.
BUT: this method is heavily redefined for objects which
can print prettier.

queries
o  isObsolete
returns true if the directory contents represented by the receiver is obsolete
(i.e. if the fileSystem's directory has been changed in the meanwhile)

o  isReadable
answer true if the directory is readable
no open error raised during reading the directory

o  isRootDirectory

o  size
get number of files including directories in the directory

testing
o  includesIdentical: anItem

o  isEmpty
returns true if directory is empty

o  isEmptyOrNil
return true if I am nil or an empty collection

o  notEmpty
returns true if directory is not empty

o  notEmptyOrNil
returns true if directory is not empty


Private classes:

    DirectoryContentsItem


ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Sat, 21 Dec 2024 16:09:22 GMT