|
1 <stránka |
|
2 xmlns="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/strana" |
|
3 xmlns:m="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/makro"> |
|
4 |
|
5 <nadpis>Reading extended attributes using relpipe-in-filesystem</nadpis> |
|
6 <perex>accessing xattr of given files e.g. xdg.origin.url</perex> |
|
7 <m:pořadí-příkladu>01300</m:pořadí-příkladu> |
|
8 |
|
9 <text xmlns="http://www.w3.org/1999/xhtml"> |
|
10 |
|
11 |
|
12 <p> |
|
13 Extended attributes (xattr) are additional <em>key=value</em> pairs that can be attached to our files. |
|
14 They are not stored inside the files, but on the filesystem. |
|
15 Thus they are independent of particular file format (which might not support metadata) |
|
16 and we can use them e.g. for tagging, cataloguing or adding some notes to our files. |
|
17 Some tools like GNU Wget use extended attributes to store metadata like the original URL from which the file was downloaded. |
|
18 </p> |
|
19 |
|
20 <m:pre jazyk="bash"><![CDATA[wget --recursive --level=1 https://relational-pipes.globalcode.info/ |
|
21 find -type f -printf '%P\0' \ |
|
22 | relpipe-in-filesystem --file path --file size --xattr xdg.origin.url \ |
|
23 | relpipe-out-tabular |
|
24 ]]></m:pre> |
|
25 |
|
26 <p>And now we know, where the files on our disk came from:</p> |
|
27 |
|
28 <pre><![CDATA[filesystem: |
|
29 ╭───────────────────────────┬────────────────┬────────────────────────────────────────────────────────────────────╮ |
|
30 │ path (string) │ size (integer) │ xdg.origin.url (string) │ |
|
31 ├───────────────────────────┼────────────────┼────────────────────────────────────────────────────────────────────┤ |
|
32 │ index.html │ 12159 │ https://relational-pipes.globalcode.info/v_0/ │ |
|
33 │ v_0/atom.xml │ 4613 │ https://relational-pipes.globalcode.info/v_0/atom.xml │ |
|
34 │ v_0/rss.xml │ 4926 │ https://relational-pipes.globalcode.info/v_0/rss.xml │ |
|
35 │ v_0/js/skript.js │ 2126 │ https://relational-pipes.globalcode.info/v_0/js/skript.js │ |
|
36 │ v_0/css/styl.css │ 2988 │ https://relational-pipes.globalcode.info/v_0/css/styl.css │ |
|
37 │ v_0/css/relpipe.css │ 1095 │ https://relational-pipes.globalcode.info/v_0/css/relpipe.css │ |
|
38 │ v_0/css/syntaxe.css │ 3584 │ https://relational-pipes.globalcode.info/v_0/css/syntaxe.css │ |
|
39 │ v_0/index.xhtml │ 12159 │ https://relational-pipes.globalcode.info/v_0/index.xhtml │ |
|
40 │ v_0/grafika/logo.png │ 3298 │ https://relational-pipes.globalcode.info/v_0/grafika/logo.png │ |
|
41 │ v_0/principles.xhtml │ 17171 │ https://relational-pipes.globalcode.info/v_0/principles.xhtml │ |
|
42 │ v_0/roadmap.xhtml │ 11097 │ https://relational-pipes.globalcode.info/v_0/roadmap.xhtml │ |
|
43 │ v_0/faq.xhtml │ 11080 │ https://relational-pipes.globalcode.info/v_0/faq.xhtml │ |
|
44 │ v_0/specification.xhtml │ 12983 │ https://relational-pipes.globalcode.info/v_0/specification.xhtml │ |
|
45 │ v_0/implementation.xhtml │ 10810 │ https://relational-pipes.globalcode.info/v_0/implementation.xhtml │ |
|
46 │ v_0/examples.xhtml │ 76958 │ https://relational-pipes.globalcode.info/v_0/examples.xhtml │ |
|
47 │ v_0/license.xhtml │ 65580 │ https://relational-pipes.globalcode.info/v_0/license.xhtml │ |
|
48 │ v_0/screenshots.xhtml │ 5708 │ https://relational-pipes.globalcode.info/v_0/screenshots.xhtml │ |
|
49 │ v_0/download.xhtml │ 5204 │ https://relational-pipes.globalcode.info/v_0/download.xhtml │ |
|
50 │ v_0/contact.xhtml │ 4940 │ https://relational-pipes.globalcode.info/v_0/contact.xhtml │ |
|
51 │ v_0/classic-example.xhtml │ 9539 │ https://relational-pipes.globalcode.info/v_0/classic-example.xhtml │ |
|
52 ╰───────────────────────────┴────────────────┴────────────────────────────────────────────────────────────────────╯ |
|
53 Record count: 20]]></pre> |
|
54 |
|
55 <p> |
|
56 If we like the BeOS/Haiku style, we can create empty files with some attributes attached and use our filesystem as a simple database |
|
57 and query it using relational tools. |
|
58 It will lack indexing, but for basic scenarios like <em>address book</em> it will be fast enough |
|
59 and we can feel a bit of BeOS/Haiku atmosphere in our contemporary GNU/Linux systems. |
|
60 But be careful with that because some editors delete and recreate files while saving them, which destroys the xattrs. |
|
61 Tools like <code>rsync</code> or <code>tar</code> with <code>--xattrs</code> option will backup our attributes securely. |
|
62 </p> |
|
63 |
|
64 |
|
65 </text> |
|
66 |
|
67 </stránka> |