rubyisforfun/manuscript/013.txt
Roman Pushkin 07330ecb4b Save
2018-12-21 11:45:38 -08:00

15 lines
2.2 KiB
Text

## File system essentials
Software engineers say that file system looks like a tree. Every branch is directory, each directory may have one or more sub-directories (other branches) or files (leaves). Directory can be empty. The top, main directory often called _root_ directory (don't confuse it with _home_ directory, which is the root place for all the files for the _current user_).
And here is where miscommunication begins. If file system is tree-like, why the main directory is called root and not the trunk? In fact, branches always grow off the trunk. Also, when we imagine the tree, we assume that tree grows up. However, in all file managers branches (directories) grow down. You need to press Down key to move your cursor one position down the directory tree. Maybe it's better to say that the top directory is not the root, but trunk?
![Tree structure. Children's art from one of Silicon Valley kindergartens. Curious programmer will ask "where is the root here?" The point is that the root node is located at the very top, which is unusual for the tree. Or do we talk about branches that grow up? There is some uncertainty, but don't let that cool you off.](images/013-tree.png)
Regardless of how you call it, trees do have less branches at the top, and more at the bottom, which is not the case for the file system. In a file system all files and directories are usually sorted in alphabetical and ascending order. Probably there is no any other good analogy, and now we assume that file system is a tree-like, and it is sort of true.
By the way, we highly recommend to find out how to sort files in your file manager. One of the tricks here is to sort by modification date in descending order. With this sort order you'll see recently modified files at the top. And a programmer usually works with the most recent files.
Sometimes only knowing the names of recently modified files in your work directory can give you a sense of what is going on with your project (and it's one of the reasons why every beginner needs a file manager). Believe us, when you'll try this sort mode, you will never look back, it's so useful!
![Sorting files by modification date in descending order in Finder (MacOS)](images/013-sort-order.png)