The configuration files will be stored in the file system in the following way:
Code: Select all
sys/config/ftypes/
html.id
htm.id -> html.id # A filesystem link to another file type
jpg.id
png.id
txt.id
What I wanted to know is what type of configuration file would be the most useful?
I started with a design using something like a shell script:
Code: Select all
txt.id:
#! bin/syscfg ftypes
# Header ID
head.id = "" # Text files have no defined header
# Commands
cmd.open = "textview $1"
cmd.edit = "textedit $1"
jpg.id:
#! bin/syscfg ftypes
# Header ID
head.id = ?,?,"JFIF" # If the first 6 bytes do not match then this entry is ignored
# Commands
cmd.open = "picview $1"
cmd.edit = "picedit $1"
png.id:
#! bin/syscfg ftypes
# Header ID
head.id = 137, 80, 78, 71, 13, 10, 26, 10 # If the first 8 bytes do not match then this entry is ignored
# Commands
cmd.open = "pngview $1"
cmd.edit = "pngedit $1"
The other option I considered was XML with the following layout:
Code: Select all
txt.id:
<ftype media:"text/plain" ext="txt">
<!-- No head entry because text files have no defined header -->
<action>
<cmd open="textview $1"/>
<cmd edit="textedit $1"/>
</action>
</ftype>
# This entry could appear in a default.id file that includes defaults for a number of different file types and is loaded when the system is initialised
image.id:
<!-- default action for all images -->
<ftype media:"image">
<action>
<cmd open="picview $1"/>
<cmd edit="picedit $1"/>
</action>
</ftype>
jpg.id:
<ftype media:"image/jpeg" ext="jpg;jpeg">
<head>
<id>?,?,"JFIF"
</id>
</head>
<!-- Use default image actions -->
</ftype>
png.id:
<ftype media:"image/png" ext="png">
<head>
<id>137, 80, 78, 71, 13, 10, 26, 10
</id>
</head>
<action>
<cmd open="pngview $1"/>
<cmd edit="pngedit $1"/>
</action>
</ftype>
The format would be used for all configuration files loaded to the system database so the user and group files would be similar in XML:
Code: Select all
users.cfg:
<user id="user1" password="1%34timeocg12f4gygu" name="First user">
<attrib>
<something>This is something that this user has, but not all user have</something>
</attrib>
</user>
<user id="user2" password="aehn234%&gpgjk" name="Another user"/>
<user id="user3" password="atn.ud@#g,'.k" name="This user"/>