Public Member Functions

WinDirectory Struct Reference

Windows file system directory-entry. More...

#include <winfs.h>

Inheritance diagram for WinDirectory:
Inheritance graph
[legend]
Collaboration diagram for WinDirectory:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 WinDirectory (LPCTSTR root_path)
 WinDirectory (Entry *parent, LPCTSTR path)
 ~WinDirectory ()
virtual void read_directory (int scan_flags=0)
virtual const void * get_next_path_component (const void *) const
virtual Entryfind_entry (const void *)

Detailed Description

Windows file system directory-entry.

Definition at line 43 of file winfs.h.


Constructor & Destructor Documentation

WinDirectory::WinDirectory ( LPCTSTR  root_path ) [inline]

Definition at line 45 of file winfs.h.

References Directory::_path.

Referenced by read_directory().

     :  WinEntry()
    {
        _path = _tcsdup(root_path);
    }

Here is the caller graph for this function:

WinDirectory::WinDirectory ( Entry parent,
LPCTSTR  path 
) [inline]

Definition at line 51 of file winfs.h.

References Directory::_path.

     :  WinEntry(parent)
    {
        _path = _tcsdup(path);
    }
WinDirectory::~WinDirectory (  ) [inline]

Definition at line 57 of file winfs.h.

References Directory::_path.

    {
        free(_path);
        _path = NULL;
    }

Member Function Documentation

Entry * WinDirectory::find_entry ( const void *  p ) [virtual]

Reimplemented from Entry.

Definition at line 208 of file winfs.cpp.

References Entry::_data, Entry::_down, Entry::_next, and TEXT.

{
    LPCTSTR name = (LPCTSTR)p;

    for(Entry*entry=_down; entry; entry=entry->_next) {
        LPCTSTR p = name;
        LPCTSTR q = entry->_data.cFileName;

        do {
            if (!*p || *p==TEXT('\\') || *p==TEXT('/'))
                return entry;
        } while(tolower(*p++) == tolower(*q++));

        p = name;
        q = entry->_data.cAlternateFileName;

        do {
            if (!*p || *p==TEXT('\\') || *p==TEXT('/'))
                return entry;
        } while(tolower(*p++) == tolower(*q++));
    }

    return NULL;
}
const void * WinDirectory::get_next_path_component ( const void *  p ) const [virtual]

Reimplemented from Entry.

Definition at line 191 of file winfs.cpp.

References TEXT.

{
    LPCTSTR s = (LPCTSTR) p;

    while(*s && *s!=TEXT('\\') && *s!=TEXT('/'))
        ++s;

    while(*s==TEXT('\\') || *s==TEXT('/'))
        ++s;

    if (!*s)
        return NULL;

    return s;
}
void WinDirectory::read_directory ( int  scan_flags = 0 ) [virtual]

Reimplemented from Entry.

Definition at line 121 of file winfs.cpp.

References Entry::_bhfi, Entry::_bhfi_valid, Entry::_data, Entry::_down, ExplorerGlobals::_ftype_mgr, Entry::_level, Entry::_next, Directory::_path, Entry::_scanned, CONTEXT, g_Globals, SCAN_DONT_ACCESS, ScanNTFSStreams(), FileTypeManager::set_type(), TEXT, WinDirectory(), and WinEntry::WinEntry().

{
    CONTEXT("WinDirectory::read_directory()");

    int level = _level + 1;

    Entry* first_entry = NULL;
    Entry* last = NULL;
    Entry* entry;

    LPCTSTR path = (LPCTSTR)_path;
    TCHAR buffer[MAX_PATH], *pname;
    for(pname=buffer; *path; )
        *pname++ = *path++;

    lstrcpy(pname, TEXT("\\*"));

    WIN32_FIND_DATA w32fd;
    HANDLE hFind = FindFirstFile(buffer, &w32fd);

    if (hFind != INVALID_HANDLE_VALUE) {
        do {
            lstrcpy(pname+1, w32fd.cFileName);

            if (w32fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
                entry = new WinDirectory(this, buffer);
            else
                entry = new WinEntry(this);

            if (!first_entry)
                first_entry = entry;

            if (last)
                last->_next = entry;

            memcpy(&entry->_data, &w32fd, sizeof(WIN32_FIND_DATA));
            entry->_level = level;

             // display file type names, but don't hide file extensions
            g_Globals._ftype_mgr.set_type(entry, true);

            if (!(scan_flags & SCAN_DONT_ACCESS)) {
                HANDLE hFile = CreateFile(buffer, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
                                            0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0);

                if (hFile != INVALID_HANDLE_VALUE) {
                    if (GetFileInformationByHandle(hFile, &entry->_bhfi))
                        entry->_bhfi_valid = true;

                    if (ScanNTFSStreams(entry, hFile))
                        entry->_scanned = true; // There exist named NTFS sub-streams in this file.

                    CloseHandle(hFile);
                }
            }

            last = entry;   // There is always at least one entry, because FindFirstFile() succeeded and we don't filter the file entries.
        } while(FindNextFile(hFind, &w32fd));

        if (last)
            last->_next = NULL;

        FindClose(hFind);
    }

    _down = first_entry;
    _scanned = true;
}

Here is the call graph for this function:


The documentation for this struct was generated from the following files:

ROS Explorer Source Code Documentation
generated on 02.01.2013 by doxygen

ROS Explorer Homepage