<commit_before>import express from 'express';
import config from 'config';
import fs from 'fs';
import path from 'path';
import { execSync } from 'child_process';
import {
  handleBiosLine, getEsSystems, getRoms, getSystemGamelist,
  parseGameReleaseDate
} from '../lib/utils';

const osutils = require('../lib/osutils');

const router = express.Router();

router.get('/', async (req, res) => {
  const option = req.query.option;
  const params = {};
  const queryParams = req.query.params || '';

  queryParams.split(',').map((param) => {
    const parts = param.split('=');

    params[[parts[0]]] = parts[1];
  });
  let data;
  let srcpath;

  switch (option) {
    case 'hostname':
      data = req.hostname;
      break;
    case 'directoryListing':
      let directoryPath = path.join(config.get('recalbox.romsPath'), params.subpath || '');
      data = fs.readdirSync(directoryPath).filter((file) => {
        return fs.statSync(path.join(directoryPath, file)).isDirectory();
      });

      // add favorites "virtual" folder
      if (params.addFavorites) {
        data.push('favorites');
      }

      data.sort();
      break;
    case 'readFile':
      data = fs.readFileSync(params.file).toString();<commit_msg>Add excluded folders on directoryListing<commit_after>import express from 'express';
import config from 'config';
import fs from 'fs';
import path from 'path';
import { execSync } from 'child_process';
import {
  handleBiosLine, getEsSystems, getRoms, getSystemGamelist,
  parseGameReleaseDate
} from '../lib/utils';

const osutils = require('../lib/osutils');

const router = express.Router();

router.get('/', async (req, res) => {
  const option = req.query.option;
  const params = {};
  const queryParams = req.query.params || '';

  queryParams.split(',').map((param) => {
    const parts = param.split('=');

    params[[parts[0]]] = parts[1];
  });
  let data;
  let srcpath;

  switch (option) {
    case 'hostname':
      data = req.hostname;
      break;
    case 'directoryListing':
      const directoryPath = path.join(config.get('recalbox.romsPath'), params.subpath || '');
      const excluded = config.get('recalbox.romsExcludedFolders');
      data = fs.readdirSync(directoryPath).filter((file) => {
        return -1 === excluded.indexOf(file) && fs.statSync(path.join(directoryPath, file)).isDirectory();
      });

      // add favorites "virtual" folder
      if (params.addFavorites) {
        data.push('favorites');
      }

      data.sort();
      break;
    case 'readFile':
      data = fs.readFileSync(params.file).toString();
{'fraction_non_alphanumeric': 0.16066589237320944, 'fraction_numerical': 0.0019357336430507162, 'mean_word_length': 3.3722504230118444, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '1410347', 'n_tokens_mistral': 809, 'n_tokens_neox': 799, 'n_words': 182}