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

org.cryptomator.jfuse.mac.DirFillerImpl Maven / Gradle / Ivy

package org.cryptomator.jfuse.mac;

import org.cryptomator.jfuse.api.DirFiller;
import org.cryptomator.jfuse.api.Stat;
import org.cryptomator.jfuse.mac.extr.fuse_fill_dir_t;
import org.cryptomator.jfuse.mac.extr.stat;

import java.lang.foreign.MemoryAddress;
import java.lang.foreign.MemorySession;
import java.util.function.Consumer;

record DirFillerImpl(MemoryAddress buf, fuse_fill_dir_t callback, MemorySession scope) implements DirFiller {

	DirFillerImpl(MemoryAddress buf, MemoryAddress callback, MemorySession scope) {
		this(buf, fuse_fill_dir_t.ofAddress(callback, scope), scope);
	}

	@Override
	public int fill(String name, Consumer statFiller, long offset, int flags) {
		var statSegment = stat.allocate(scope);
		statFiller.accept(new StatImpl(statSegment));
		return callback.apply(buf, scope.allocateUtf8String(name).address(), statSegment.address(), offset);
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy