<commit_before>var fuse = require('fuse-bindings');
var fs = require('fs');
var mkdirp = require('mkdirp');
var torrents = require('torrent-stream');
var path = require('path');

var ENOENT = -2;
var EPERM = -1;
var EINVAL = -22;

module.exports = function(source, mnt, isLazy) {
	if (!mnt) mnt = '.';

	var handlers = {};
	var engine = torrents(source);

	engine.on('ready', function() {
		if (engine.torrent.name === (engine.files[0] && engine.files[0].path)) {
			var dir = engine.torrent.name.replace(/\.[^.]+$/, '');
			engine.torrent.files.forEach(function(file) {
				file.path = path.join(dir, file.path);
			});
			engine.torrent.name = dir;
		}

		mnt = path.join(mnt, path.resolve('/', engine.torrent.name));
		fuse.unmount(mnt, function() {
			mkdirp(mnt, function() {
				fuse.mount(mnt, handlers);
				engine.emit('mount', mnt);
			});
		});
        if(!isLazy) {
            engine.files.forEach(function (file) {
                file.path = file.path.slice(engine.torrent.name.length + 1);
                file.select();
            });
        }
		engine.on('uninterested', function() {
			engine.swarm.pause();
		});
		engine.on('interested', function() {
			engine.swarm.resume();
		});
	});

	var find = function(path) {
		return engine.files.reduce(function(result, file) {
			return result || (file.path === path && file);
		}, null);
	};

	handlers.getattr = function(path, cb) {
		path = path.slice(1);

		var stat = {};
		var file = find(path);

		if (file) {
			stat.size = file.length;
			stat.mode = 0100666;
			return cb(0, stat);
		}

		stat.size = 4096;
		stat.mode = 040755;

		if (!path) return cb(0, stat);

		var dir = engine.files.some(function(file) {
			return file.path.indexOf(path+'/') === 0;
		});

		if (!dir) return cb(ENOENT);
		cb(0, stat);
	};

	var files = {};<commit_msg>use displayFolder in #19 as well<commit_after>var fuse = require('fuse-bindings');
var fs = require('fs');
var mkdirp = require('mkdirp');
var torrents = require('torrent-stream');
var path = require('path');

var ENOENT = -2;
var EPERM = -1;
var EINVAL = -22;

module.exports = function(source, mnt, isLazy) {
	if (!mnt) mnt = '.';

	var handlers = {};
	var engine = torrents(source);

	engine.on('ready', function() {
		if (engine.torrent.name === (engine.files[0] && engine.files[0].path)) {
			var dir = engine.torrent.name.replace(/\.[^.]+$/, '');
			engine.torrent.files.forEach(function(file) {
				file.path = path.join(dir, file.path);
			});
			engine.torrent.name = dir;
		}

		mnt = path.join(mnt, path.resolve('/', engine.torrent.name));
		fuse.unmount(mnt, function() {
			mkdirp(mnt, function() {
				fuse.mount(mnt, handlers);
				engine.emit('mount', mnt);
			});
		});
        if(!isLazy) {
            engine.files.forEach(function (file) {
                file.path = file.path.slice(engine.torrent.name.length + 1);
                file.select();
            });
        }
		engine.on('uninterested', function() {
			engine.swarm.pause();
		});
		engine.on('interested', function() {
			engine.swarm.resume();
		});
	});

	var find = function(path) {
		return engine.files.reduce(function(result, file) {
			return result || (file.path === path && file);
		}, null);
	};

  handlers.displayFolder = true

	handlers.getattr = function(path, cb) {
		path = path.slice(1);

		var stat = {};
		var file = find(path);

		if (file) {
			stat.size = file.length;
			stat.mode = 0100666;
			return cb(0, stat);
		}

		stat.size = 4096;
		stat.mode = 040755;

		if (!path) return cb(0, stat);

		var dir = engine.files.some(function(file) {
			return file.path.indexOf(path+'/') === 0;
		});

		if (!dir) return cb(ENOENT);
		cb(0, stat);
	};

	var files = {};
{'fraction_non_alphanumeric': 0.1947453954496208, 'fraction_numerical': 0.016251354279523293, 'mean_word_length': 2.9752421959095803, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3118607', 'n_tokens_mistral': 1511, 'n_tokens_neox': 1316, 'n_words': 267}