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.69 date: 2018/03/08 12:45:05
user: stefan
file: DirectoryContents.st directory: libbasic2
module: stx stc-classLibrary: libbasic2
Author:
Claus Atzkern

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.


Related information:

    Filename
    FileStream
    DirectoryStream
    OperatingSystem

Class protocol:

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

o  directoryNamed: aDirectory
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

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

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 open, 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

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

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.1.0.0; WebServer 1.663 at exept.de:8081; Mon, 19 Nov 2018 01:14:40 GMT