File: expr.dirname.md

package info (click to toggle)
watchman 4.9.0-9
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 9,992 kB
  • sloc: cpp: 27,459; python: 6,538; java: 3,404; php: 3,257; ansic: 2,803; javascript: 1,116; makefile: 671; ruby: 364; sh: 124; xml: 102; lisp: 4
file content (44 lines) | stat: -rw-r--r-- 1,563 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
---
pageid: expr.dirname
title: dirname & idirname
layout: docs
section: Expression Terms
permalink: docs/expr/dirname.html
---

*Since version 3.1*

The `dirname` term allows matching on the parent directory structure for a
given file.

For the examples below, given a file with a wholename (the relative path from
the project root) of `foo/bar/baz`, the dirname portion is `foo/bar`.

The following two terms will match any file whose dirname is either exactly a
match for `foo/bar` or is any child directory of `foo/bar`.  The first of these
two is a shortcut for the second:

      ["dirname", "foo/bar"]
      ["dirname", "foo/bar", ["depth", "ge", 0]]

The second of those terms uses a relational expression based on the depth of
the file within the specified dirname.  A file is considered to have
`depth == 0` if it is contained directly within the specified dirname.  It has
`depth == 1` if it is contained in a direct child directory of the specified
dirname, `depth == 2` if it is contained in a grand-child directory and so on.

The relational expression accepts the same relational operators as described in
the [size term](size.html).

If you wanted to match only files that were directly in the `foo/bar` dir:

      ["dirname", "foo/bar", ["depth", "eq", 0]]

If you wanted to match only files that were in a grand-child or deeper:

      ["dirname", "foo/bar", ["depth", "ge", 2]]

`idirname` is the case insensitive version of `dirname`.  If the watched root
is detected as a case insensitive fileystem, `dirname` is equivalent to `idirname`.