Platforms to show: All Mac Windows Linux Cross-Platform

Back to NSDirectoryEnumeratorMBS class.

NSDirectoryEnumeratorMBS.Constructor(folder as folderitem)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacBase Plugin 9.8 ✅ Yes ❌ No ❌ No ✅ Yes All
Creates and returns an NSDirectoryEnumerator object that enumerates the contents of the directory at a given path.
Example
dim d as new NSDirectoryEnumeratorMBS(SpecialFolder.Desktop)

MsgBox d.nextObject // shows ".DS_Store" or some other file name

An NSDirectoryEnumerator object that enumerates the contents of the directory at path.
If path is a filename, the method returns an enumerator object that enumerates no files—the first call to nextObject will return nil.

Because the enumeration is deep—that is, it lists the contents of all subdirectories—this enumerator object is useful for performing actions that involve large file-system subtrees. This method does not resolve symbolic links encountered in the traversal process, nor does it recurse through them if they point to a directory.

See also:

NSDirectoryEnumeratorMBS.Constructor(path as string)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacBase Plugin 9.8 ✅ Yes ❌ No ❌ No ✅ Yes All
Creates and returns an NSDirectoryEnumerator object that enumerates the contents of the directory at a given path.
Example
dim d as new NSDirectoryEnumeratorMBS("/Applications")
dim f as FolderItem = d.nextFile

while f<>Nil
List.AddRow f.Name

// if this is a folder, we skip the sub folders
d.skipDescendents

f=d.nextFile
wend

An NSDirectoryEnumerator object that enumerates the contents of the directory at path.
If path is a filename, the method returns an enumerator object that enumerates no files—the first call to nextObject will return nil.

Because the enumeration is deep—that is, it lists the contents of all subdirectories—this enumerator object is useful for performing actions that involve large file-system subtrees. This method does not resolve symbolic links encountered in the traversal process, nor does it recurse through them if they point to a directory.

See also:

NSDirectoryEnumeratorMBS.Destructor

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacBase Plugin 9.8 ✅ Yes ❌ No ❌ No ✅ Yes All
The destructor for this class.

NSDirectoryEnumeratorMBS.directoryAttributes as dictionary

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacBase Plugin 9.8 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns an Dictionary object that contains the attributes of the directory at which enumeration started.

NSDirectoryEnumeratorMBS.fileAttributes as dictionary

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacBase Plugin 9.8 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns an object that contains the attributes of the most recently returned file or subdirectory (as referenced by the pathname).
Example
dim d as new NSDirectoryEnumeratorMBS(SpecialFolder.Desktop)
dim f as FolderItem = d.nextFile

while f<>Nil
List.AddRow f.Name

dim di as Dictionary = d.fileAttributes
dim size as int64 = di.Value(d.NSFileSize)

List.AddRow f.Name+" ("+str(size)+" Bytes)"

f=d.nextFile
wend

NSDirectoryEnumeratorMBS.level as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacBase Plugin 9.8 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns the number of levels deep the current object is in the directory hierarchy being enumerated.
Example
dim d as new NSDirectoryEnumeratorMBS(SpecialFolder.Desktop)
dim f as FolderItem = d.nextFile

while f<>Nil
List.AddRow f.Name+" "+str(d.level)

f=d.nextFile
wend

Available in Mac OS X v10.6 and later.

NSDirectoryEnumeratorMBS.nextFile as folderitem

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacBase Plugin 9.8 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns the next folderitem from the collection being enumerated.
Example
dim d as new NSDirectoryEnumeratorMBS(SpecialFolder.Desktop)
dim f as string = d.nextObject

while len(f)>0
List.AddRow f

f=d.nextObject
wend

The next folderitem from the collection being enumerated, or nil when all objects have been enumerated.

Same as nextObject, but returns a folderitem.

Some examples using this method:

NSDirectoryEnumeratorMBS.Path as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacBase Plugin 9.8 ✅ Yes ❌ No ❌ No ✅ Yes All
The path used in the constructor.

NSDirectoryEnumeratorMBS.skipDescendents

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacBase Plugin 9.8 ✅ Yes ❌ No ❌ No ✅ Yes All
Causes the receiver to skip recursion into the most recently obtained subdirectory.

The items on this page are in the following plugins: MBS MacBase Plugin.


The biggest plugin in space...