5.2. Explicitly Creating File and Directory Nodes
Prev | Chapter 5. Node Objects | Next

## 5.2. Explicitly Creating File and Directory Nodes

It's worth mentioning here that SCons maintains a clear distinction between Nodes that represent files and Nodes that represent directories. SCons supports `File` and `Dir` functions that, respectively, return a file or directory Node:

    hello_c = File('hello.c')
    Program(hello_c)

    classes = Dir('classes')
    Java(classes, 'src')

Normally, you don't need to call `File` or `Dir` directly, because calling a builder method automatically treats strings as the names of files or directories, and translates them into the Node objects for you. The `File` and `Dir` functions can come in handy in situations where you need to explicitly instruct SCons about the type of Node being passed to a builder or other function, or unambiguously refer to a specific file in a directory tree.

There are also times when you may need to refer to an entry in a file system without knowing in advance whether it's a file or a directory. For those situations, SCons also supports an `Entry` function, which returns a Node that can represent either a file or a directory.

    xyzzy = Entry('xyzzy')

The returned `xyzzy` Node will be turned into a file or directory Node the first time it is used by a builder method or other function that requires one vs. the other.

Prev | Up | Next
Chapter 5. Node Objects | Home | 5.3. Printing `Node` File Names