I’m making some basic design decisions about a new database file structure for a dataMine substitute. I’ve settled on the Graphite/Whisper concept which, amongst other things, uses a hierarchical directory structure. A natural outcome of this is that an ideal database directory tree for Vera would be of the form “machineId/deviceNo/serviceId/variable”.
My question is this: Am I wise to allow an unfiltered serviceId into the directory name, viz: “Vera-12345/42/urn:micasaverde-com:serviceId:EnergyMetering1/Watts” ?
I’ve tried this on Vera itself and my iMac (and it’s fine) but not on a Windows machine. Given that the directory structure could end up residing almost anywhere on the network, am I likely to run into problems? I know this was a limitation of older file systems. I can obviously substitute any other character (say, underscore) for the colon, but I want to be absolutely certain that it’s not one which might turn up as part of a variable name or serviceId.
I’m certainly not expert in any operating/file system, so advice is welcomed and much needed. TIA.
I know colons ( are not allowed for file names in windows. So you may have to use some sort of substitution. it may be wise to remove the special characters with a substitute. Maybe replace with an underscore.
Service IDs are URIs (source: UPnP spec). URIs can contain these characters: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~:/?#[]@!$&'()*+,;= (source: RFC 3986) and % has special meaning.
Candidate ASCII characters you could use instead of colon: ^ { } `
Or you could invent an escaping system, where : is replaced with (say) = and = is replaced with ==.
There’s a long history of colons in special filenames on Unix. Dig through /proc or /dev and you’ll see bucketloads of them. But certain filesystem protocols (SSH, CIFS spring to mind) treat colon magically, making it hard to use them literally in all cases.
Thanks to all the illustrious names who’ve helped to answer this question… I think this confirms that it was worth asking.
(Or, quite possibly, that you are very kind and I am very stupid.)
If I can get away with a simple [tt]gsub[/tt] to do the transformation, unambiguously, both ways, that would be best.
So I think that @futzle’s impeccable information (as always), along with that of oTi@, leads me to the use of the caret:
x = "urn:micasaverde-com:serviceId:Volume1"
y = x:gsub (':','^')
z = y:gsub ('%^',':')
giving:
y = "urn^micasaverde-com^serviceId^Volume1"
z = "urn:micasaverde-com:serviceId:Volume1"
I simply couldn’t have lived with the asymmetry that ‘{’ or ‘}’ implied in the resultant filename.
Job done! Thanks again everyone.
Best Home Automation shopping experience. Shop at Ezlo!