The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
/* Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

parcel Lucy;

/** Iterate over the files in a directory.
 */
abstract class Lucy::Store::DirHandle nickname DH
    inherits Clownfish::Obj {

    String   *dir;
    String   *entry;

    /** Abstract constructor.
     *
     * @param dir The path to the directory.
     */
    inert DirHandle*
    init(DirHandle *self, String *dir);

    /** Proceed to the next entry in the directory.
     *
     * @return true on success, false when finished.
     */
    abstract bool
    Next(DirHandle *self);

    /** Attempt to close the DirHandle.  Returns true on success, sets
     * Err_error and returns false on failure.
     */
    abstract bool
    Close(DirHandle *self);

    /** Return the object's <code>dir</code> attribute.
     */
    String*
    Get_Dir(DirHandle *self);

    /** Return the path of the current entry.  The value is only valid when
     * Next() has returned successfully.
     */
    incremented String*
    Get_Entry(DirHandle *self);

    /** Returns true if the current entry is a directory, false otherwise.
     */
    abstract bool
    Entry_Is_Dir(DirHandle *self);

    /** Returns true if the current entry is a symbolic link (or a Windows
     * junction), false otherwise.
     */
    abstract bool
    Entry_Is_Symlink(DirHandle *self);

    /** Invokes Close(), but ignores any errors.
     */
    public void
    Destroy(DirHandle *self);
}