alphaleonis / AlphaFS

AlphaFS is a .NET library providing more complete Win32 file system functionality to the .NET platform than the standard System.IO classes.
http://alphafs.alphaleonis.com/
MIT License
562 stars 99 forks source link

FileInfos from AlternateDataStreamInfo.FullPath are all named "$DATA" #443

Closed springy76 closed 6 years ago

springy76 commented 6 years ago

I think this needs some kind of special handling.

Yomodo commented 6 years ago

Could you elaborate a bit more? Currently the AlphaFS unit test shows this:

Input File Path: [C:\Users\jjangli\AppData\Local\Temp\File-EnumerateAlternateDataStreams-vmuejdrm.gjs]

A file is created and 2 streams are added.

Current stream Count(): [3]

Instance: [Alphaleonis.Win32.Filesystem.AlternateDataStreamInfo]

#001    FullPath   = [\\?\C:\Users\jjangli\AppData\Local\Temp\File-EnumerateAlternateDataStreams-vmuejdrm.gjs::$DATA]
#002    Size       = [10]
#003    StreamName = []

Instance: [Alphaleonis.Win32.Filesystem.AlternateDataStreamInfo]

#001    FullPath   = [\\?\C:\Users\jjangli\AppData\Local\Temp\File-EnumerateAlternateDataStreams-vmuejdrm.gjs:myStreamTWO-ïtïrücrd.büf:$DATA]
#002    Size       = [52]
#003    StreamName = [myStreamTWO-ïtïrücrd.büf]

Instance: [Alphaleonis.Win32.Filesystem.AlternateDataStreamInfo]

#001    FullPath   = [\\?\C:\Users\jjangli\AppData\Local\Temp\File-EnumerateAlternateDataStreams-vmuejdrm.gjs:ӍƔŞtrëƛɱ-ysärzkfr.ëyg:$DATA]
#002    Size       = [300]
#003    StreamName = [ӍƔŞtrëƛɱ-ysärzkfr.ëyg]
springy76 commented 6 years ago

new Alphaleonis.Win32.Filesystem.FileInfo(@"\\?\C:\Users\jjangli\AppData\Local\Temp\File-EnumerateAlternateDataStreams-vmuejdrm.gjs:myStreamTWO-ïtïrücrd.büf:$DATA", Alphaleonis.Win32.Filesystem.PathFormat.LongFullPath) -> Name property is "$DATA"

Yomodo commented 6 years ago

Omit the :$DATA and the Name property is ok.

springy76 commented 6 years ago

No it's not if it is an ADS of a directory -- then an additional backslash is needed before the ADS colon:

Works: more < \\server\share:AFP_AfpInfo:$DATA Works NOT: more < \\server\share:AFP_AfpInfo Works: more < \\server\share\:AFP_AfpInfo

.... oh damn, that even is OS specific. The above is true for Windows 10 (Pro), on Windows 2016 (Server) the backlash is needed always:

Works NOT: more < \\server\share:AFP_AfpInfo:$DATA Works: more < \\server\share\:AFP_AfpInfo:$DATA Works NOT: more < \\server\share:AFP_AfpInfo Works: more < \\server\share\:AFP_AfpInfo

(Don't know what the official specs say, just what I discovered by now)

Yomodo commented 6 years ago

I think it's safe to say that :$DATA can be omitted, given the many ADS examples on the net. It is an attribute, you access the stream by name, the backslash thingy is new to me. Is that more.com or an executable using AlphaFS?

springy76 commented 6 years ago

:$DATA should be the default if omitted. "more.com" exists since DOS times and is nearly the only way to test ADS directly on the OS. Code using AlphaFS behaves the same (throws errors when more does not work and vice versa).

Yomodo commented 6 years ago

SysInternals Streams v1.6 is a good one.

Is the issue, regarding FileInfo.Name solved now by omitting :$DATA ?

springy76 commented 6 years ago

"omitting"? I never introduced it. If I modify AlternateDataStreamInfo.FullPath by stripping away :$DATA and inserting the missing "\" before the rightmost ":", then it works.

I wonder if both of your classes could interact more smoothly.

springy76 commented 6 years ago

Regarding "SysInternals Streams": dir /r works too. But for testing the access (or viewing the contents) you cannot just use type file:ads.

It BTW is not "more.com" which supports ADS but only "piping" using " | ", " > " or " < ".

Yomodo commented 6 years ago

I'm sorry, I'm trying to understand what the issue, regarding AlphaFS and ADS, is.

If it's about using ADS from AlphaFS, then take a peek at the unit tests. Basically it just boils down to using methods such as File.WriteAllLines and File.ReadAllLines so that's why there aren't any conveniece methods.

Yomodo commented 6 years ago

Perhaps a good idea to let AlphaFS strip away :$DATA from the FullPath property.

https://github.com/alphaleonis/AlphaFS/blob/dd4f740fcf3fe2d91bebaebea4f6c2802efad033/AlphaFS/Filesystem/Link%20Stream/AlternateDataStreamInfo.cs#L62-L65