relpipe-data/examples-filesystem-xattr.xml
branchv_0
changeset 244 d4f401b5f90c
parent 241 f71d300205b7
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/relpipe-data/examples-filesystem-xattr.xml	Tue Feb 05 19:18:28 2019 +0100
@@ -0,0 +1,67 @@
+<stránka
+	xmlns="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/strana"
+	xmlns:m="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/makro">
+	
+	<nadpis>Reading extended attributes using relpipe-in-filesystem</nadpis>
+	<perex>accessing xattr of given files e.g. xdg.origin.url</perex>
+	<m:pořadí-příkladu>01300</m:pořadí-příkladu>
+
+	<text xmlns="http://www.w3.org/1999/xhtml">
+		
+		
+		<p>
+			Extended attributes (xattr) are additional <em>key=value</em> pairs that can be attached to our files.
+			They are not stored inside the files, but on the filesystem.
+			Thus they are independent of particular file format (which might not support metadata)
+			and we can use them e.g. for tagging, cataloguing or adding some notes to our files.
+			Some tools like GNU Wget use extended attributes to store metadata like the original URL from which the file was downloaded.
+		</p>
+		
+		<m:pre jazyk="bash"><![CDATA[wget --recursive --level=1 https://relational-pipes.globalcode.info/
+find -type f -printf '%P\0' \
+	| relpipe-in-filesystem --file path --file size --xattr xdg.origin.url  \
+	| relpipe-out-tabular
+]]></m:pre>
+
+		<p>And now we know, where the files on our disk came from:</p>
+
+		<pre><![CDATA[filesystem:
+ ╭───────────────────────────┬────────────────┬────────────────────────────────────────────────────────────────────╮
+ │ path             (string) │ size (integer) │ xdg.origin.url                                            (string) │
+ ├───────────────────────────┼────────────────┼────────────────────────────────────────────────────────────────────┤
+ │ index.html                │          12159 │ https://relational-pipes.globalcode.info/v_0/                      │
+ │ v_0/atom.xml              │           4613 │ https://relational-pipes.globalcode.info/v_0/atom.xml              │
+ │ v_0/rss.xml               │           4926 │ https://relational-pipes.globalcode.info/v_0/rss.xml               │
+ │ v_0/js/skript.js          │           2126 │ https://relational-pipes.globalcode.info/v_0/js/skript.js          │
+ │ v_0/css/styl.css          │           2988 │ https://relational-pipes.globalcode.info/v_0/css/styl.css          │
+ │ v_0/css/relpipe.css       │           1095 │ https://relational-pipes.globalcode.info/v_0/css/relpipe.css       │
+ │ v_0/css/syntaxe.css       │           3584 │ https://relational-pipes.globalcode.info/v_0/css/syntaxe.css       │
+ │ v_0/index.xhtml           │          12159 │ https://relational-pipes.globalcode.info/v_0/index.xhtml           │
+ │ v_0/grafika/logo.png      │           3298 │ https://relational-pipes.globalcode.info/v_0/grafika/logo.png      │
+ │ v_0/principles.xhtml      │          17171 │ https://relational-pipes.globalcode.info/v_0/principles.xhtml      │
+ │ v_0/roadmap.xhtml         │          11097 │ https://relational-pipes.globalcode.info/v_0/roadmap.xhtml         │
+ │ v_0/faq.xhtml             │          11080 │ https://relational-pipes.globalcode.info/v_0/faq.xhtml             │
+ │ v_0/specification.xhtml   │          12983 │ https://relational-pipes.globalcode.info/v_0/specification.xhtml   │
+ │ v_0/implementation.xhtml  │          10810 │ https://relational-pipes.globalcode.info/v_0/implementation.xhtml  │
+ │ v_0/examples.xhtml        │          76958 │ https://relational-pipes.globalcode.info/v_0/examples.xhtml        │
+ │ v_0/license.xhtml         │          65580 │ https://relational-pipes.globalcode.info/v_0/license.xhtml         │
+ │ v_0/screenshots.xhtml     │           5708 │ https://relational-pipes.globalcode.info/v_0/screenshots.xhtml     │
+ │ v_0/download.xhtml        │           5204 │ https://relational-pipes.globalcode.info/v_0/download.xhtml        │
+ │ v_0/contact.xhtml         │           4940 │ https://relational-pipes.globalcode.info/v_0/contact.xhtml         │
+ │ v_0/classic-example.xhtml │           9539 │ https://relational-pipes.globalcode.info/v_0/classic-example.xhtml │
+ ╰───────────────────────────┴────────────────┴────────────────────────────────────────────────────────────────────╯
+Record count: 20]]></pre>
+
+		<p>
+			If we like the BeOS/Haiku style, we can create empty files with some attributes attached and use our filesystem as a simple database
+			and query it using relational tools.
+			It will lack indexing, but for basic scenarios like <em>address book</em> it will be fast enough
+			and we can feel a bit of BeOS/Haiku atmosphere in our contemporary GNU/Linux systems.
+			But be careful with that because some editors delete and recreate files while saving them, which destroys the xattrs.
+			Tools like <code>rsync</code> or <code>tar</code> with <code>--xattrs</code> option will backup our attributes securely.
+		</p>
+
+		
+	</text>
+
+</stránka>