## Chapter 12: DirInfo Documentation

Chapter 11 << | Index | >> ------- -

### DirInfo Revision 2 Draft 5

### 1 Introduction

DirInfo is a simple, bash-written directory-indexing system, I thought
might be useful for some (and me). Basically you create a .dirinfo file
for each directory to be indexed, let dirinfo scan them (and create them
index). Then you can easily search for directories matching given properties.

### 2 DirInfo Files

DirInfo files are simple plain-text files called .dirinfo in the directory
to be indexed. You can semi-automatically create (or edit) them using the
`dirinfo --create' function. Alternatively here's an example how a manually
created .dirinfo file has to look like:
Owner="Christopher Roy Bratusek"
Type="share"
Tags=( project python bash )
Created="2007-05-01"
Notes="BashStyle-NG GIT-Repo"
as you can see the syntax is straight-forward and pretty self-descriptive.
It is required for the Tags-Field to be an array, don't separate them with
commas or enclose them with " " characters, as you might get unwanted or
incomplete/missing search results.
The Type-Field can contain anything, but for the following types, there's a nice
ASCII-Graphic provided, which is displayed by `lscd':
- book
- document
- download
- game
- home
- mediaplayer
- music
- picture
- private
- share
- video
check $BSNG_RC_DIR/ascii/ for them, in case you want to edit and/or create extra ones.
Since most FileSystems do not store the CreationDate (I know only about NTFS, Ext4 and
BTRFS doing so), you can get the date of the last modification via `dirinfo --get-date',
respectively `dirinfo --set-date'.

### 3 DirInfo Flags

With Revision 2, DirInfo Flags have been added. those permit actions on the directories
marked and all file inside them (filestrucuture-depth: 1 level). Here's the list of flags:
- #NoCopy
- #NoMove
- #NoDelete
- #NoShred
NoCopy prevents `cp' from working, NoMove `mv', NoDelete `rm' and NoShred `shred'.
In order to make things work (those flags are of course not supported by the original
versions of those four), wrappers are installed. As of now, the wrappers for `rm' and
`shred' work 100%, while the wrappers for `cp' and `mv' have some syntax-incompatibilities
thus they (all four) are installed, but disabled. If you feel brave enough, pass
`--dirinfo-enable' to BashStyle-NGs configure-script.
It is highly recommended to restart the system once the wrappers are enabled.
If done so, they become valid for all users (yes, all does include root), this
is achieved by `bashstyle.sh', which resides in /etc/profile.d.
To add flags, simply open the directory's .dirinfo file and append the desired flag,
one per line

### 4 Indexing

The index is stored in $HOME/.dirindex, with the following syntax:
directory :: tags :: type :: date :: owner
Only your home directory is being scanned (as of now, there's no way to ex- or include
directories explicitly, but it might come up in Revision 3)
You can create the index by running `dirinfo --generate'. To rebuild the index
based on an already existing index, run `dirinfo --rebuild' instead (this.
command won't scan for new directories to index, thus `rebuild').
You can get the list of all indexed directory via `dirinfo --list'.

### 5 Searching

Now we actually make use of DirInfo (finally). You can search through all fields at once,
by using `dirinfo --search <search term>, or only a specific field, by running
`dirinfo --search +<field> <search term>, where filed is one of tag, type,
date or owner (note the `+').