La traducció d'aquesta pàgina encara no està acabada. Fins que ho sigui, algunes part correspondrà a la versió anglesa.


Els atributs són camps de dades que pertanyen a un fitxer, però no formen part d'aquest fitxer, per exemple, no es compten en la mida del fitxer i poden ser copiats o canviats sense tocar el propi fitxer. El sistema utilitza aquests atributs per emmagatzemar, per exemple, la mida del fitxer, tipus del fitxer o la data de l'última modificació. Això és similar a d'altres sistemes operatius i els seus sistemes de fitxers.

La diferència és que podeu afegir qualsevol tipus d'atribut per a qualsevol fitxer i mostrar-ho o fer-ho editable a una finestra del Tracker. Només cal definir el tipus d'atribut que es vol afegir a un tipus de fitxer (per exemple, cadena, un enter o hora) i donar-li un nom i una descripció.

The file itself doesn't even need any contents at all. Take a look at these People files for example:


As you can see, these are all 0-sized files with attached attributes, the E-mail attribute of "John Nox" being edited right in Tracker.

If you index these attributes, as People, Email or audio files are by default, they are also searchable with Haiku's fast query system.

index Atributs al Tracker

Attributes are displayed quite similar to a database or spreadsheet. Using Tracker you can choose which attributes to display (columns) and sort file listings (rows) accordingly.

To do this, open a Tracker window, click on the Attributes menu, and select the attributes you want to display. Alternatively, simply right-click onto a column heading and mark the items in the context menu. You can rearrange the columns by a simple drag & drop of the column heading. Moving a column out of a window, is a fast way to get rid of columns you don't need.

Double-click on the line between two attributes in the heading to automatically resize a column to its optimal width.

Click on a column heading to toggle the sorting order from ascending to descending. You can establish a secondary sort order by pressing the SHIFT key while clicking on a column heading. You can sort your People files by company and within that order sort by contact name, for instance. See the above screenshot as an example. The secondary sort order is marked by a lighter colored indicator beside the heading.

Editing these attributes is as simple as renaming a file: Either click on an entry or press ALT E and move between the attributes with TAB and SHIFT TAB. ESC leaves the editing mode without applying the changes.

index Atributs al Terminal

If you prefer to use the commandline or plan to work with many files using scripting, there are several commands for controlling attributes from Terminal.

More information on these commands and their options can be found by typing the command name followed by "-h" or "--help".

index listattr

listattr lists a file's attributes, but by default doesn't show the contents of the attributes. For that, you need to add the parameter -l or --long.

usage: listattr [-l|--long] 'filename' ['filename' ...]

Al nostre exemple de la captura anterior:

 ~/people ->listattr Clara\\ Botters
File: Clara Botters
   Type         Size                 Name
-----------  ---------  -------------------------------
MIME String         21  "BEOS:TYPE"
        Text         14  "META:name"
        Text          6  "META:nickname"
        Text          1  "META:company"

        Text         18  "META:address"
        Text          8  "META:city"
        Text          1  "META:state"
        Text          1  "META:zip"
        Text          1  "META:country"

        Text          1  "META:hphone"
        Text         13  "META:wphone"
        Text          1  "META:fax"
        Text         19  "META:email"
        Text          1  "META:url"

        Text          5  "META:group"
    Raw Data         20  "_trk/pinfo_le"
131 bytes total in attributes.

Besides all the "META:*" attributes that hold the contact's information, there are two attributes that are managed by the system:

Note the backslash after "Clara". In Terminal you have to "escape" special characters like '"*\$?!. The space between "Clara" and "Botters" is also one of those. Therefore the backslash is really in front of the space character, and not after "Clara".

index catattr

catattr displays the contents of a specific attribute of a file.

usage: catattr [--raw|-r] attr_name file1 [file2...]

De nou el nostre exemple:

 ~/people ->catattr META:city Clara\\ Botters
Clara Botters : string : Whelton

index addattr

addattr adds an attribute to a file and/or fills it with a value.

usage: addattr [-t type] attr value file1 [file2...]
    or: addattr [-f value-from-file] [-t type] attr file1 [file2...]
         Type is one of:
                 string, mime, int, llong, float, double, bool, icon, raw
                 or a numeric value (ie. 0x1234, 42, 'ABCD', ...)
         The default is "string"

So, say dear Clara took a job with the multi-national Barkelbaer Inc., you fill the formerly empty "Company" attribute with that data (which is of type "string"):

 ~/people ->addattr -t string META:company Barkelbaer\\ Inc. Clara\\ Botters

index rmattr

rmattr suprimeix totalment un atribut d'un fitxer.

usage: rmattr [-p] attr filename1 [filename2...]

Though in all practicality it would be enough to just not fill the "Fax" attribute, you can completely remove it from Clara's file by typing:

 ~/people ->rmattr META:fax Clara\\ Botters

index copyattr

copyattr copies attributes from one or more files to another. By default, the actual contents of the file is not copied.

Usage: copyattr <options> <source> [ ... ] <destination>

If you do want to copy the attributes plus the data of the file itself, you can add the option "-d" or "--data".