NTFS 文件数据流
?
NTFS文件系统与FAT,FAT32文件系统相比,增加了许多新功能。如NTFS文件系统支持文件多数据流,而FAT,FAT32则没有数据流这个概念。
?
我们在命令提示符下输入:
echo Hello World! >hello.txt:Test
用记事本打开hello.txt,空的,什么都没有。Hello.txt的文件属性中显示也是0字节。这是因为记事本中显示的是默认数据流里的数据,而我们并没有默认数据流中写入数据。
可用下面的命令显示其他数据流中的数据。
more <hello.txt:Test
?
由于FAT32文件系统不支持数据流,因此当我们将hello.txt拷贝到FAT32分区时,所有非默认数据流中的数据都将丢失。
?
有时,用移动硬盘拷电影时会弹出“XXX文件中存在隐藏的数据,是否继续拷贝?”的对话框。原因应该就是这些文件中有其他数据流信息。
?
枚举文件中的数据流:
// Streams.cpp : Defines the entry point for the console application.
//
?
// only WinXP, Win2003 and WinVista supported.
#define
_WIN32_WINNT 0x0501
?
#include
<tchar.h>
#include
<Windows.h>
?
int
_tmain(intargc, _TCHAR* argv[])
{
???????
if(argc != 2)
??????? {
???????????????
_tprintf(_T("Usage:\n\tStreams filename"));
???????????????
return 1;
??????? }
?
???????
WIN32_FIND_STREAM_DATA
streamData;
?
???????
HANDLE
hStream = FindFirstStreamW(????? argv[1],
???????????????????????????????????????????????
FindStreamInfoStandard,
??????????????????????????????????????????????? &streamData,
???????????????????????????????????????
??????? 0);//Reserved, must be 0.
???????
if( INVALID_HANDLE_VALUE == hStream)
??????? {
???????????????
return 1;
??????? }
?
???????
do
??????? {
???????????????
_tprintf(_T("%s%s\t %dbytes\n"),argv[1],streamData.cStreamName,streamData.StreamSize);
??????? }
???????
while(FindNextStreamW(hStream,&streamData));
?
???????
FindClose(hStream);
?
???????
return 0;
}
?
?
Streams.rar
如果使用VC6.0编译,需更新Windows Platform SDK。