streamlet-examples/__relpipe_in_filesystem_script_mime_type
branchv_0
changeset 33 f9cada1d46a4
child 36 8b97ab3cd9cc
equal deleted inserted replaced
32:bccda5688d71 33:f9cada1d46a4
       
     1 #!/bin/bash
       
     2 
       
     3 # Relational pipes
       
     4 # Copyright © 2020 František Kučera (Frantovo.cz, GlobalCode.info)
       
     5 #
       
     6 # This program is free software: you can redistribute it and/or modify
       
     7 # it under the terms of the GNU General Public License as published by
       
     8 # the Free Software Foundation, version 3 of the License.
       
     9 #
       
    10 # This program is distributed in the hope that it will be useful,
       
    11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
       
    13 # GNU General Public License for more details.
       
    14 #
       
    15 # You should have received a copy of the GNU General Public License
       
    16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
       
    17 
       
    18 
       
    19 # This streamlet provides a single attribute: inode number of given file
       
    20 
       
    21 
       
    22 . "$(dirname $0)/streamlet-common.sh"
       
    23 
       
    24 processMessage_WAITING_FOR_OUTPUT_ATTRIBUTES_METADATA() {
       
    25 	send OUTPUT_ATTRIBUTE_METADATA "${outputAttributeAliases[0]}"    "string"
       
    26 	send WAITING_FOR_INPUT_ATTRIBUTES
       
    27 }
       
    28 
       
    29 processMessage_WAITING_FOR_OUTPUT_ATTRIBUTES() {
       
    30 	value=$(file --preserve-date --brief --mime-type --dereference "$currentFile");
       
    31 	send OUTPUT_ATTRIBUTE "$value"    "false";
       
    32 	send WAITING_FOR_INPUT_ATTRIBUTES;
       
    33 }
       
    34 
       
    35 initialize
       
    36 processMessages