All Downloads are FREE. Search and download functionalities are using the official Maven repository.

convex.dlfs.impl.DLDirectoryStream Maven / Gradle / Ivy

The newest version!
package convex.dlfs.impl;

import java.io.IOException;
import java.nio.file.DirectoryStream;
import java.nio.file.Path;
import java.util.Iterator;
import java.util.NoSuchElementException;

import convex.core.data.ACell;
import convex.core.data.AHashMap;
import convex.core.data.AString;
import convex.core.data.AVector;
import convex.dlfs.DLFSNode;
import convex.dlfs.DLPath;

public class DLDirectoryStream implements DirectoryStream {

	public class DIterator implements Iterator {
		long pos=0;
		
		@Override
		public boolean hasNext() {
			return pos=dirs.count()) throw new NoSuchElementException();
			return base.resolve(dirs.entryAt(pos++).getKey());
		}

	}

	private AHashMap> dirs;
	private DLPath base;

	public DLDirectoryStream(DLPath base, AHashMap> dirs) {
		this.base=base;
		this.dirs=dirs;
	}

	@Override
	public void close() throws IOException {
		// Ignore

	}

	@Override
	public DIterator iterator() {
		return new DIterator();
	}

	public static DLDirectoryStream create(DLPath base, AVector dirNode) {
		AHashMap> dirs = DLFSNode.getDirectoryEntries(dirNode);
		if (dirs==null) return null;
		return new DLDirectoryStream(base,dirs);
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy