FileIterator

public protocol FileIterator : LuaWrapper, Disposable

File iterator.

  • The iteration mode for the current file.

    Declaration

    Swift

    var mode: FileIterateMode { get }
  • Returns the next available file, or nil if the iteration is over.

    Declaration

    Swift

    func next() throws -> VirtualFile?
  • toArray() Extension method

    Collect all iterated files to an array.

    Note

    This method calls dispose() automatically.

    Declaration

    Swift

    public func toArray() throws -> [VirtualFile]
  • take(first:) Extension method

    Collect first elements to an array.

    Note

    This method calls dispose() automatically.

    Declaration

    Swift

    public func take(first: Int) throws -> [VirtualFile]
  • Iterate over all files in the iterator. Returns true if the iteration is complete, false if it was cancelled.

    This method calls dispose() automatically.

    Declaration

    Swift

    func iterate(errorHandler: (Error) -> Bool, itemHandler: (VirtualFile) throws -> Bool) -> Bool

    Parameters

    errorHandler

    called when next() threw an error. Return true to continue iterating, false if the iteration should be stopped.

    itemHandler

    called each time next() returned a VirtualFile. Return true to continue iterating, false if the iteration should be stopped.