| Цитата(artsb @ 12.5.2008, 23:08) | Цитата(ksili @ 12.5.2008, 10:26 ) | | Другое дело, что он не сможет нагадить осмысленно |
Я о том же.
Цитата(xvr @ 12.5.2008, 14:00 ) | | Запиши данные в файловый стрим (имя файла в виде "qqq:mydata"), пользователь увидит только файл qqq нулевой длинны. |
Вот это интересно, правда непонятно. xvr, объясни плиз. Если можно на конкретном примере.
|
MSDN: A Programmer's Perspective on NTFS 2000 Part 1: Stream and Hard Link
| Цитата | Under an NTFS file system each file can have multiple streams of data. It's worth pointing out that streams are not a feature of NTFS 2000, but they have been in existence since Windows NT 3.1. When you read the content of a file under a non-NTFS volume (say, a disk partition of a Windows 98 machine) you're able to access only one stream of data. Consequently, you perceive it as the real and "unique" content for that file. Such a main stream has no name and is the only one that non-NTFS file systems can handle. But when you create a file on an NTFS volume, things might be different. A multi-stream file is a sort of collection of single-stream files all embedded in the same file system entry. They definitely look like a unique and atomic unit, yet comprise a number of independent sub-units you can create, delete, and modify separately. There are a number of common programming scenarios where streams are more than handy. However, if you plan to use them, bear in mind that as soon as you copy a multi-stream file to a non-NTFS storage device (such as a CD, a floppy, or a non-NTFS disk partition), all extra streams will be unrecoverable if lost. Unfortunately, such a compatibility issue makes streams much less attractive in practice. For server-side applications designed and destined to run only on NTFS volumes, streams are an excellent tool to leverage to build great and creative solutions. To identify a named stream within a file you should follow a particular naming convention and add at the end of the file name a colon followed by the stream name. For example, to access a stream called VersionInfo on a file called test.txt you should use the file name: Test.txt:VersionInfo Use it with any Microsoft Win32® API function that manipulates files. To access the content of the VersionInfo stream, pass that name on to CreateFile() and then use ReadFile() and WriteFile() to accomplish reading and writing as usual. If you want to check whether a certain stream exists within a file, compose the file stream name as just shown and use CreateFile() to check it for existence:
| Код | HANDLE hfile = CreateFile(szFileStreamName, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, 0); CloseHandle(hfile); if (hfile == NULL) MessageBox(hWnd, "Error", NULL, MB_OK);
|
|
| Цитата | Пробовал с помощью функций fread и fwrite записывать структуру в файл поблоково. Но почему-то они не хотят рабоать с AnsiString, а char меня не устраивает. Как быть?
|
Запись:
| Код | AnsiString data=...; fwrite(data.c_str(),1,data.size(),file);
|
Чтение:
| Код | fseek(file,0,SEEK_END); int fsize=ftell(file); fseek(file,0,SEEK_SET); AnsiString data=AnsiString::StringOfChar(' ',fsize); fread(data.c_str(),1,fsize,file);
|
|