ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

int ScanNTFSStreams ( Entry entry,
HANDLE  hFile 
)

Definition at line 36 of file winfs.cpp.

Referenced by WinDirectory::read_directory(), and ShellDirectory::read_directory().

{
    PVOID ctx = 0;
    DWORD read, seek_high;
    Entry** pnext = &entry->_down;
    int cnt = 0;

    for(;;) {
        struct NTFS_StreamHdr : public WIN32_STREAM_ID {
            WCHAR name_padding[_MAX_FNAME]; // room for reading stream name
        } hdr;

        if (!BackupRead(hFile, (LPBYTE)&hdr, (LPBYTE)&hdr.cStreamName-(LPBYTE)&hdr, &read, FALSE, FALSE, &ctx) ||
            (long)read!=(LPBYTE)&hdr.cStreamName-(LPBYTE)&hdr)
            break;

        if (hdr.dwStreamId == BACKUP_ALTERNATE_DATA) {
            if (hdr.dwStreamNameSize &&
                BackupRead(hFile, (LPBYTE)hdr.cStreamName, hdr.dwStreamNameSize, &read, FALSE, FALSE, &ctx) &&
                read==hdr.dwStreamNameSize)
            {
                ++cnt;

                int l = hdr.dwStreamNameSize / sizeof(WCHAR);
                LPCWSTR p = hdr.cStreamName;
                LPCWSTR e = hdr.cStreamName + l;

                if (l>0 && *p==':') {
                    ++p, --l;

                    e = p;

                    while(l>0 && *e!=':')
                        ++e, --l;

                    l = e - p;
                }

                Entry* stream_entry = new WinEntry(entry);

                memcpy(&stream_entry->_data, &entry->_data, sizeof(WIN32_FIND_DATA));
                lstrcpy(stream_entry->_data.cFileName, String(p, l));

                stream_entry->_down = NULL;
                stream_entry->_expanded = false;
                stream_entry->_scanned = false;
                stream_entry->_level = entry->_level + 1;

                *pnext = stream_entry;
                pnext = &stream_entry->_next;
            }
        }

         // jump to the next stream header
        if (!BackupSeek(hFile, ~0, ~0, &read, &seek_high, &ctx)) {
            DWORD error = GetLastError();

            if (error != ERROR_SEEK) {
                BackupRead(hFile, 0, 0, &read, TRUE, FALSE, &ctx);  // terminate BackupRead() loop
                THROW_EXCEPTION(error);
                //break;
            }

            hdr.Size.QuadPart -= read;
            hdr.Size.HighPart -= seek_high;

            BYTE buffer[4096];

            while(hdr.Size.QuadPart > 0) {
                if (!BackupRead(hFile, buffer, sizeof(buffer), &read, FALSE, FALSE, &ctx) || read!=sizeof(buffer))
                    break;

                hdr.Size.QuadPart -= read;
            }
        }
    }

    if (ctx)
        if (!BackupRead(hFile, 0, 0, &read, TRUE, FALSE, &ctx)) // terminate BackupRead() loop
            THROW_EXCEPTION(GetLastError());

    return cnt;
}

Generated on Fri May 25 2012 04:45:09 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.