/* Is followed by {case-ignorable}* cased  ? (dir determines looking forward/backward)
337096
private final boolean isFollowedByCasedLetter(ContextIterator iter, int dir) {
        int c;

        if(iter==null) {
            return false;
        }

        for(iter.reset(dir); (c=iter.next())>=0;) {
            int type=getTypeOrIgnorable(c);
            if((type&4)!=0) {
                /* case-ignorable, continue with the loop */
            } else if(type!=NONE) {
                return true; /* followed by cased letter */
            } else {
                return false; /* uncased and not case-ignorable */
            }
        }

        return false; /* not followed by cased letter */
    }
537088
private boolean forwardMatch(String match, boolean ignoreCase, boolean resetOnTrue)
      throws
      IOException
  {
    Mark mark = reader.mark();
    List<Integer> cbuf = Lists.newArrayList();
    StringBuilder builder = new StringBuilder();

    boolean result = true;
    boolean seenChar = false;

    while (true)
    {
      cbuf.add(reader.next());

      char ch = (char) reader.curChar;

      if (reader.curChar == -1)
      {
        result = false;
        break;
      }
      else if (WHITESPACE.matches(ch))
      {
        if (seenChar)
        {
          builder.append(ch);
        }
      }
      else
      {
        if (builder.length() == 0)
        {
          seenChar = true;
        }
        builder.append(ch);
        int index = builder.length() - 1;

        if (!ignoreCase
            && (builder.charAt(index) == match.charAt(index)))
        {
          result = false;
          break;
        }

        if (ignoreCase
            && (Ascii.toLowerCase(builder.charAt(index)) != Ascii
            .toLowerCase(match.charAt(index))))
        {
          result = false;
          break;
        }
      }

      if (builder.length() == match.length())
      {
        if (!match.equalsIgnoreCase(builder.toString()))
        {
          result = false;
        }
        break;
      }
    }

    if (!result || resetOnTrue)
    {
      reader.unread(cbuf, mark);
    }

    return result;
  }
904616
function isValidDir(dir) {
    var fs = require("fs");
    try {
        return fs.statSync(dir).isDirectory();
    } catch (err) {
        return false;
    }
}
432300
def isignored(self, relpath, directory=False):
    """"""
    relpath = self._relpath_no_dot(relpath)
    if directory:
      relpath = self._append_trailing_slash(relpath)
    return self.ignore.match_file(relpath)
829106
function mkdirIf(dir, parent) {
	var path = parent ? parent : ".";
	if (getDirectories(path).indexOf(dir) == -1) fs.mkdirSync(path + "/" + dir);
}
228506
function getNextWhile(tokens, index, direction, matcher) {
		var count = 1, 
			token;
		
		direction = direction || 1;
		while (token = tokens[index + (direction * count++)]) {
			if (!matcher(token)) {
				return token;
			}
		}
		
		return undefined;
	}
113328
function mk(dir) {
      var absDir = path.resolve(dir);
      if (!fs.existsSync(absDir)) {
        try {
          fs.mkdirSync(absDir);
        }
        catch (e) {
          mk(path.dirname(absDir));
          fs.mkdirSync(absDir);
        }
      }
    }
287432
def dirs(self, before=time.time(), exited=True):
        
        timestamp = iso(before)
        root = os.path.join(self.root, "start-time")
        os.chdir(root)
        by_t = (d for d in glob.iglob("????-??-??T*.*Z") if d < timestamp)
        if exited is None:
            def predicate(directory):
                return True
        else:
            def predicate(directory):
                exit = os.path.join(directory, "exit")
                return os.path.exists(exit) is exited
        return (os.path.join(root, d) for d in by_t if predicate(d))
951840
function (filePath)
    {
        if (0 === filePath.indexOf(process.cwd()))
        {
            filePath = path.relative(process.cwd(), filePath);
        }

        if (0 !== filePath.indexOf("./") && 0 !== filePath.indexOf("/"))
        {
            filePath = "./" + filePath;
        }

        return filePath;
    }
265351
private boolean mkdir(boolean parent)
  {
    synchronized (_rootNode) {
      String fullPath = getFullPath();

      int head = 0;
      Node node = this._rootNode;

      while (node != null && head < fullPath.length()) {
        int tail = fullPath.indexOf('/', head);
        String name;

        if (tail == head) {
          head = tail + 1;
          continue;
        }
        if (tail == -1) {
          name = fullPath.substring(head);
          if (node.lookup(name) != null)
            return false;
          node.createDir(name);
          return true;
        }

        name = fullPath.substring(head, tail);
        Node next = node.lookup(name);

        if (next == null && parent)
          next = node.createDir(name);

        if (next == null || next.type != next.DIR)
          return false;

        node = next;
        head = tail + 1;
      }

      return false;
    }
  }
1276332
function(stat)
{
	if(stat)
	{
		if(stat.isDirectory)
		{
			return stat.isDirectory()
		}
		if(stat.type)
		{
			if(stat.type=="dir")
			{
				return true
			}
		}
	}
	return false
}
907052
function mkdir(dirPath, callback) {
  // Credits: https://github.com/substack/node-mkdirp

  // Recursively go through the parents.
  const recurse = () => {
    mkdir(path.dirname(dirPath), (error) => {
      if (error) {
        async.nextTick(callback, error);
        return;
      }

      // Try again.
      mkdir(dirPath, callback);
    });
  };

  // Plan B for when things seem to go wrong.
  const fallBack = () => {
    fs.stat(dirPath, (error, stat) => {
      if (error || !stat.isDirectory()) {
        async.nextTick(
          callback,
          new Error(`${dirPath}: Could not create the directory`)
        );
        return;
      }

      async.nextTick(callback, null);
    });
  };

  fs.mkdir(dirPath, (error) => {
    if (!error) {
      async.nextTick(callback, null);
      return;
    }

    switch (error.code) {
      case 'ENOENT':
        recurse();
        break;
      default:
        fallBack();
        break;
    }
  });
}
634416
def is_readable_dir(path):
  """"""
  return os.path.isdir(path) and os.access(path, os.R_OK) and os.access(path, os.X_OK)
377888
function isFileOrDir(filePath) {
	let fsStat;
	try {
		fsStat = fs.statSync(filePath);
	} catch (error) {
		return error;
	}

	let r = 'file';
	if (fsStat.isDirectory()) {
		r = 'directory';
	}

	return r;
}
1137059
def is_retaincase(bunchdt, data, commdct, idfobject, fieldname):
    """"""
    thiscommdct = getfieldcomm(bunchdt, data, commdct, idfobject, fieldname)
    return 'retaincase' in thiscommdct
584365
function isInsideDir(dir, targetDir) {
  if (targetDir == dir) return false
  if (targetDir == '.') return dir
  const relative = path.relative(targetDir, dir)
  if (/^\.\./.test(relative)) return false
  return relative
}
904167
function ensureDir(dir) {
        try {
            if (!fs_1.existsSync(dir))
                fs_1.mkdirSync(dir);
            return true;
        }
        catch (ex) {
            return false;
        }
    }