Directories, and iterating over files and folders
Typically, a filesystem groups files into collections, normally referred to as directories. One navigates through directories to find individual files. Once a target file is found, the file object must be wrapped by an interface exposing the file contents for reading and writing.
As Node development often involves the creation of servers that both accept and emit file data, it should be clear how important transfer speed at this active and important I/O layer is. As mentioned earlier, files can also be understood as objects, and objects have certain attributes.
Types of files
There are six types of files commonly encountered on a UNIX system:
- Ordinary files: These contain a one-dimensional array of bytes, and cannot contain other files.
- Directories: These are also files implemented in a special way such that they can describe collections of other files.
- Sockets: Used for IPC, allowing processes to exchange data.
- Named pipe: A command such as
ps...