Access alternate data stream in Programmable column

Discussion & Support for xplorer² professional

Moderators: fgagnon, nikos, Site Mods

Post Reply
otlaolap
Silver Member
Silver Member
Posts: 237
Joined: 2007 Aug 11, 21:37

Access alternate data stream in Programmable column

Post by otlaolap »

I am trying to read an alternate data stream in the Programmable column. For clarity I will use a file name "G:\TEST.TXT" with an alternate datastream "testdata". An editor can open "G:\TEST.TXT:testdata" and NirSoft's AlternateStreamVIew can see it. But for some reason this does not work in the Programmable column:

file2("fbytes(0,4)",${Path}+${Name}+":testdata")

I have (I believe) verified that the ${Path}+${Name}+":testdata" by itself generates the proper name of the file but the fbytes does not seem to fetch anything.

(What I am trying to do is simply display the number of lines in the file in the programmable column. I can get this number via the SYSTEM function in the programmable column, but this is slower than it might be. I can store this number into an Alternate Data Stream because I generate these files of interest. But I cannot seem to fetch it from a stream using the programmable column functions.)
User avatar
nikos
Site Admin
Site Admin
Posts: 15800
Joined: 2002 Feb 07, 15:57
Location: UK
Contact:

Re: Access alternate data stream in Programmable column

Post by nikos »

top marks for improvisation there :)
unfortunately, the way FILE2 works, doesn't allow such use to read ADS, sorry!
why don't you store the information you want in the comment column? That's usually stored as ADS for plain text files
otlaolap
Silver Member
Silver Member
Posts: 237
Joined: 2007 Aug 11, 21:37

Re: Access alternate data stream in Programmable column

Post by otlaolap »

Since I posted this, I have been working to do just that -- use the comment column. A lot of hiccups, though, but I think now I have all the elements needed to hack this. Sample hiccup: the stream for the comments property includes a hex 05 in the file name ("=SummaryInformation", where = is hex 05), and some of the software I have been using rejects this character as invalid. If only there were a simple way to set the comment via programming. One more avenue to try before I turn to the complete hack job.
User avatar
nikos
Site Admin
Site Admin
Posts: 15800
Joined: 2002 Feb 07, 15:57
Location: UK
Contact:

Re: Access alternate data stream in Programmable column

Post by nikos »

I don't know how you set properties like comments but you can perhaps do it through powershell:
www.zabkat.com/blog/touch-jpg-date-taken.htm

ps. For use in xplorer2 only, if the file doesn't have a summaryinformation stream for the comment, you can use the special stream called x2_AFScomment and store your text there as a wide string (unicode)
otlaolap
Silver Member
Silver Member
Posts: 237
Joined: 2007 Aug 11, 21:37

Re: Access alternate data stream in Programmable column

Post by otlaolap »

Hack job is complete (using AutoHotkey).

First, I created an empty file, gave it by hand a comment "0000000000000000" (sixteen zeros), and saved this as a template. It has three streams at this point: the (zero-lenth) data stream and two streams created because the comment has been created. One of these is ":*SummaryInformation" (where the * is 0x05); it is 148 bytes long and contains the actual comment string. This (three-stream) file is permanently saved as a template for my hack.

Next, when I create a file for which I want to add a comment to display in the comment column, I copy the template to the target location and append to it the file data I wish it to actually contain. This replaces the data stream (the stream we think of as the file) but leaves the two other streams intact.

Finally, when the file is complete, I open its SummaryInformation stream, read it in binary, overwrite the specific bytes containing the comment zeroes with blanks or digits as appropriate to create the string I want to see as a comment, and then write it back in binary. I've no idea what all the other bytes of control information do in this 148-byte file are but then I don't need to know it.

One final nicety. I've discovered that the font used for X2 on my system displays the blank character at exactly one-half the pixel width of the digit characters (which are all the same width). So I fake up right-justification of this comment column by prepending the correct number of blank pairs (two blanks per missing leading digit) to the digit string to make the actual digits appear right-aligned. It is this combined string that gets overwritten onto the zeroes stored in the template. Because of the natural-number sorting option in X2, this resulting comment column, in addition to appearing right-justified, sorts correctly as numbers.

This is a truly nice result for my work, taking only a day and a half or two of false trails and rework. It's a hobby not a living. Thanks for the great program.
User avatar
nikos
Site Admin
Site Admin
Posts: 15800
Joined: 2002 Feb 07, 15:57
Location: UK
Contact:

Re: Access alternate data stream in Programmable column

Post by nikos »

you earned the degree of Master of file management :D
Post Reply