new 'content' column to display symbolic link targets

svn path=/trunk/; revision=7954
This commit is contained in:
Martin Fuchs 2004-02-01 10:52:24 +00:00
parent 3e745d2acd
commit b88d580163
7 changed files with 140 additions and 145 deletions

View file

@ -47,6 +47,7 @@ Entry::Entry(ENTRY_TYPE etype)
_icon_id = ICID_UNKNOWN;
_display_name = _data.cFileName;
_type_name = NULL;
_content = NULL;
}
Entry::Entry(Entry* parent, ENTRY_TYPE etype)
@ -62,6 +63,7 @@ Entry::Entry(Entry* parent, ENTRY_TYPE etype)
_icon_id = ICID_UNKNOWN;
_display_name = _data.cFileName;
_type_name = NULL;
_content = NULL;
}
Entry::Entry(const Entry& other)
@ -83,6 +85,7 @@ Entry::Entry(const Entry& other)
_shell_attribs = other._shell_attribs;
_display_name = other._display_name==other._data.cFileName? _data.cFileName: _tcsdup(other._display_name);
_type_name = other._type_name? _tcsdup(other._type_name): NULL;
_content = other._content? _tcsdup(other._content): NULL;
_etype = other._etype;
_icon_id = other._icon_id;
@ -102,6 +105,9 @@ Entry::~Entry()
if (_type_name)
free(_type_name);
if (_content)
free(_content);
}

View file

@ -83,6 +83,7 @@ public:
SFGAOF _shell_attribs;
LPTSTR _display_name;
LPTSTR _type_name;
LPTSTR _content;
ENTRY_TYPE _etype;
int /*ICON_ID*/ _icon_id;

View file

@ -164,9 +164,10 @@ FileChildWindow::FileChildWindow(HWND hwnd, const FileChildWndInfo& info)
if (info._open_mode & OWM_EXPLORE) ///@todo Is not-explore-mode for FileChildWindow completely implemented?
_left_hwnd = *(_left=new Pane(_hwnd, IDW_TREE_LEFT, IDW_HEADER_LEFT, _root._entry, true, 0));
_left_hwnd = *(_left=new Pane(_hwnd, IDW_TREE_LEFT, IDW_HEADER_LEFT, _root._entry, true, COL_CONTENT));
_right_hwnd = *(_right=new Pane(_hwnd, IDW_TREE_RIGHT, IDW_HEADER_RIGHT, NULL, false, COL_SIZE|COL_DATE|COL_TIME|COL_ATTRIBUTES|COL_INDEX|COL_LINKS));
_right_hwnd = *(_right=new Pane(_hwnd, IDW_TREE_RIGHT, IDW_HEADER_RIGHT, NULL, false,
COL_TYPE|COL_SIZE|COL_DATE|COL_TIME|COL_ATTRIBUTES|COL_INDEX|COL_LINKS|COL_CONTENT));
_sortOrder = SORT_NAME;
_header_wdths_ok = false;

View file

@ -155,7 +155,7 @@ static DWORD NtOpenObject(OBJECT_TYPE type, HANDLE* phandle, DWORD access, LPCWS
UnicodeString ustr(path);
OpenStruct open_struct = {sizeof(OpenStruct), 0x00, &ustr, 0x40};
if (type==SYMBOLICLINK_OBJECT || type==DIRECTORY_OBJECT)
if (type==DIRECTORY_OBJECT || type==SYMBOLICLINK_OBJECT)
access |= FILE_LIST_DIRECTORY;
/* if (xflag)
@ -218,161 +218,127 @@ void NtObjDirectory::read_directory(int scan_flags)
*w++ = '\\';
#endif
if (_type == DIRECTORY_OBJECT) {
NtObjectInfo* info = (NtObjectInfo*)alloca(2048);
NtObjectInfo* info = (NtObjectInfo*)alloca(2048);
if (!(*g_NTDLL->NtQueryDirectoryObject)(dir_handle, info, 2048, TRUE, TRUE, &idx, NULL)) {
WIN32_FIND_DATA w32fd;
Entry* last = NULL;
Entry* entry;
if (!(*g_NTDLL->NtQueryDirectoryObject)(dir_handle, info, 2048, TRUE, TRUE, &idx, NULL)) {
WIN32_FIND_DATA w32fd;
Entry* last = NULL;
Entry* entry;
do {
memset(&w32fd, 0, sizeof(WIN32_FIND_DATA));
do {
memset(&w32fd, 0, sizeof(WIN32_FIND_DATA));
#ifdef UNICODE
wcscpyn(p, info->name.string_ptr, _MAX_PATH);
wcscpyn(p, info->name.string_ptr, _MAX_PATH);
#else
WideCharToMultiByte(CP_ACP, 0, info->name.string_ptr, info->name.string_len, p, MAX_PATH, 0, 0);
WideCharToMultiByte(CP_ACP, 0, info->name.string_ptr, info->name.string_len, p, MAX_PATH, 0, 0);
#endif
lstrcpy(w32fd.cFileName, p);
lstrcpy(w32fd.cFileName, p);
const LPCWSTR* tname = NTDLL::s_ObjectTypes;
OBJECT_TYPE type = UNKNOWN_OBJECT_TYPE;
const LPCWSTR* tname = NTDLL::s_ObjectTypes;
OBJECT_TYPE type = UNKNOWN_OBJECT_TYPE;
for(; *tname; tname++)
if (!wcsncmp(info->type.string_ptr, *tname, 32))
{type=OBJECT_TYPE(tname-NTDLL::s_ObjectTypes); break;}
for(; *tname; tname++)
if (!wcsncmp(info->type.string_ptr, *tname, 32))
{type=OBJECT_TYPE(tname-NTDLL::s_ObjectTypes); break;}
if (type == DIRECTORY_OBJECT) {
w32fd.dwFileAttributes |= FILE_ATTRIBUTE_DIRECTORY;
if (type == DIRECTORY_OBJECT) {
w32fd.dwFileAttributes |= FILE_ATTRIBUTE_DIRECTORY;
entry = new NtObjDirectory(this, buffer);
}
entry = new NtObjDirectory(this, buffer);
}
else if (type == SYMBOLICLINK_OBJECT) {
w32fd.dwFileAttributes |= ATTRIBUTE_SYMBOLIC_LINK;
else if (type == SYMBOLICLINK_OBJECT) {
w32fd.dwFileAttributes |= ATTRIBUTE_SYMBOLIC_LINK;
//@@_toscan |= INF_DESCRIPTION;
entry = NULL;
entry = NULL;
if (*w32fd.cFileName>='A' &&*w32fd.cFileName<='Z' && w32fd.cFileName[1]==':')
if (!_tcsncmp(buffer,TEXT("\\??\\"),4) || // NT4
!_tcsncmp(buffer,TEXT("\\GLOBAL??"),9)) { // XP
w32fd.dwFileAttributes |= FILE_ATTRIBUTE_DIRECTORY;
entry = new WinDirectory(this, w32fd.cFileName);
}
if (!entry)
entry = new NtObjDirectory(this, buffer);
}
else if (type == KEY_OBJECT) {
w32fd.dwFileAttributes |= FILE_ATTRIBUTE_DIRECTORY;
entry = new RegistryRoot(this, buffer);
}
else
entry = new NtObjEntry(this, type);
HANDLE handle;
#ifdef UNICODE
lstrcpyW(p, info->name.string_ptr);
if (!NtOpenObject(_type, &handle, 0, buffer))
#else
lstrcpyW(w, info->name.string_ptr);
if (!NtOpenObject(_type, &handle, 0, wbuffer))
#endif
{
NtObject object;
DWORD read;
if (!(*g_NTDLL->NtQueryObject)(handle, 0/*ObjectBasicInformation*/, &object, sizeof(NtObject), &read)) {
memcpy(&w32fd.ftCreationTime, &object.creation_time, sizeof(FILETIME));
memset(&entry->_bhfi, 0, sizeof(BY_HANDLE_FILE_INFORMATION));
entry->_bhfi.nNumberOfLinks = object.reference_count - 1;
entry->_bhfi_valid = true;
if (*w32fd.cFileName>='A' &&*w32fd.cFileName<='Z' && w32fd.cFileName[1]==':')
if (!_tcsncmp(buffer,TEXT("\\??\\"),4) || // NT4
!_tcsncmp(buffer,TEXT("\\GLOBAL??"),9)) { // XP
w32fd.dwFileAttributes |= FILE_ATTRIBUTE_DIRECTORY;
entry = new WinDirectory(this, w32fd.cFileName);
}
(*g_NTDLL->NtClose)(handle);
if (!entry)
entry = new NtObjDirectory(this, buffer);
}
else if (type == KEY_OBJECT) {
w32fd.dwFileAttributes |= FILE_ATTRIBUTE_DIRECTORY;
entry = new RegistryRoot(this, buffer);
}
else
entry = new NtObjEntry(this, type);
HANDLE handle;
#ifdef UNICODE
lstrcpyW(p, info->name.string_ptr);
if (!NtOpenObject(type, &handle, 0, buffer))
#else
lstrcpyW(w, info->name.string_ptr);
if (!NtOpenObject(type, &handle, 0, wbuffer))
#endif
{
NtObject object;
DWORD read;
if (!(*g_NTDLL->NtQueryObject)(handle, 0/*ObjectBasicInformation*/, &object, sizeof(NtObject), &read)) {
memcpy(&w32fd.ftCreationTime, &object.creation_time, sizeof(FILETIME));
memset(&entry->_bhfi, 0, sizeof(BY_HANDLE_FILE_INFORMATION));
entry->_bhfi.nNumberOfLinks = object.reference_count - 1;
entry->_bhfi_valid = true;
}
memcpy(&entry->_data, &w32fd, sizeof(WIN32_FIND_DATA));
if (type == SYMBOLICLINK_OBJECT) {
WCHAR wbuffer[_MAX_PATH];
UnicodeString link(_MAX_PATH, wbuffer);
if (!(*g_NTDLL->NtQuerySymbolicLinkObject)(handle, &link, NULL)) {
int len = link.string_len/sizeof(WCHAR);
entry->_content = (LPTSTR) malloc((len+1)*sizeof(TCHAR));
#ifdef UNICODE
entry->_type_name = _wcsdup(info->type.string_ptr);
wcsncpy(entry->_content, link, len);
#else
char type_name[32];
WideCharToMultiByte(CP_ACP, 0, info->type.string_ptr, info->type.string_len, type_name, 32, 0, 0);
entry->_type_name = strdup(type_name);
U2nA(link, entry->_content, len);
#endif
entry->_content[len] = '\0';
}
}
if (!first_entry)
first_entry = entry;
if (last)
last->_next = entry;
entry->_down = NULL;
entry->_expanded = false;
entry->_scanned = false;
entry->_level = level;
last = entry;
} while(!(*g_NTDLL->NtQueryDirectoryObject)(dir_handle, info, 2048, TRUE, FALSE, &idx, NULL));
last->_next = NULL;
}
} else {
/*@@
assert(_type==SYMBOLICLINK_OBJECT);
try {
wcscpy(wcpcpy(buffer, UNC(_name)), L"\\");
if (GetFileAttributesW(buffer) != 0xFFFFFFFF) {
#ifdef UNICODE
TLVEntry* entry = new FileSysEntry(system()->tlvctrlr(), buffer);
#else
TLVEntry* entry = new FileSysEntry(system()->tlvctrlr(), String(buffer));
#endif
*entry->pparent() = this;
*pchild() = entry;
expand();
} else
_toscan |= INF_REFRESH_SCAN_CHILD;
} catch(Exception& e) {
if (display_errors)
HandleException(e);
(*g_NTDLL->NtClose)(handle);
}
*/
}
/*@@
if (_toscan & INF_DESCRIPTION) {
_toscan &= ~INF_DESCRIPTION;
memcpy(&entry->_data, &w32fd, sizeof(WIN32_FIND_DATA));
if (_type == SYMBOLICLINK_OBJECT) {
DWORD len;
WCHAR wbuffer[_MAX_PATH];
UnicodeString link(_MAX_PATH, wbuffer);
if (!NtQuerySymbolicLinkObject(dir_handle, &link, &len)) {
#ifdef UNICODE
wcscpy(_description, link);
entry->_type_name = _wcsdup(info->type.string_ptr);
#else
U2T(link, _description, -1);
char type_name[32];
WideCharToMultiByte(CP_ACP, 0, info->type.string_ptr, info->type.string_len, type_name, 32, 0, 0);
entry->_type_name = strdup(type_name);
#endif
_inf |= INF_DESCRIPTION;
}
}
if (!first_entry)
first_entry = entry;
if (last)
last->_next = entry;
entry->_down = NULL;
entry->_expanded = false;
entry->_scanned = false;
entry->_level = level;
last = entry;
} while(!(*g_NTDLL->NtQueryDirectoryObject)(dir_handle, info, 2048, TRUE, FALSE, &idx, NULL));
last->_next = NULL;
}
*/
(*g_NTDLL->NtClose)(dir_handle);

View file

@ -56,7 +56,8 @@ static const LPTSTR g_pos_names[COLUMNS] = {
TEXT("Index/Inode"),
TEXT("Links"),
TEXT("Attributes"),
TEXT("Security")
TEXT("Security"),
TEXT("Content")
};
static const int g_pos_align[] = {
@ -70,7 +71,8 @@ static const int g_pos_align[] = {
HDF_LEFT, /* Index */
HDF_CENTER, /* Links */
HDF_CENTER, /* Attributes */
HDF_LEFT /* Security */
HDF_LEFT, /* Security */
HDF_LEFT /* Content / Description */
};
@ -477,7 +479,7 @@ void Pane::draw_item(LPDRAWITEMSTRUCT dis, Entry* entry, int calcWidthCol)
++col;
// ouput file name
// output file name
if (calcWidthCol == -1)
_out_wrkr.output_text(dis, _positions, col, entry->_display_name, 0);
else if (calcWidthCol==col || calcWidthCol==COLUMNS)
@ -485,11 +487,13 @@ void Pane::draw_item(LPDRAWITEMSTRUCT dis, Entry* entry, int calcWidthCol)
++col;
// ouput type/class name
if (calcWidthCol == -1)
_out_wrkr.output_text(dis, _positions, col, entry->_type_name, 0);
else if (calcWidthCol==col || calcWidthCol==COLUMNS)
calc_width(dis, col, entry->_type_name);
// output type/class name
if (visible_cols & COL_TYPE) {
if (calcWidthCol == -1)
_out_wrkr.output_text(dis, _positions, col, entry->_type_name, 0);
else if (calcWidthCol==col || calcWidthCol==COLUMNS)
calc_width(dis, col, entry->_type_name);
}
++col;
@ -609,6 +613,16 @@ void Pane::draw_item(LPDRAWITEMSTRUCT dis, Entry* entry, int calcWidthCol)
output_text(dis, col++, buffer, 0, psize);
}
*/
++col;
// output content / symbolic link target
if (visible_cols & COL_CONTENT) {
if (calcWidthCol == -1)
_out_wrkr.output_text(dis, _positions, col, entry->_content, 0);
else if (calcWidthCol==col || calcWidthCol==COLUMNS)
calc_width(dis, col, entry->_content);
}
}

View file

@ -33,14 +33,16 @@
enum COLUMN_FLAGS {
COL_SIZE = 0x01,
COL_DATE = 0x02,
COL_TIME = 0x04,
COL_ATTRIBUTES = 0x08,
COL_DOSNAMES = 0x10,
COL_INDEX = 0x20,
COL_LINKS = 0x40,
COL_ALL = COL_SIZE|COL_DATE|COL_TIME|COL_ATTRIBUTES|COL_DOSNAMES|COL_INDEX|COL_LINKS
COL_TYPE = 0x0001,
COL_SIZE = 0x0002,
COL_DATE = 0x0004,
COL_TIME = 0x0008,
COL_ATTRIBUTES = 0x0010,
COL_DOSNAMES = 0x0020,
COL_INDEX = 0x0040,
COL_LINKS = 0x0080,
COL_CONTENT = 0x0100,
COL_ALL = COL_TYPE|COL_SIZE|COL_DATE|COL_TIME|COL_ATTRIBUTES|COL_DOSNAMES|COL_INDEX|COL_LINKS|COL_CONTENT
};
@ -67,7 +69,7 @@ struct Pane : public SubclassedWindow
Pane(HWND hparent, int id, int id_header, Entry* rool, bool treePane, int visible_cols);
#define COLUMNS 11
#define COLUMNS 12
int _widths[COLUMNS];
int _positions[COLUMNS+1];

View file

@ -96,6 +96,11 @@ extern void _log_(LPCTSTR txt);
#endif
#endif
#define U2A(s, d, l) WideCharToMultiByte(CP_ACP, 0, s, -1, d, l, NULL, NULL)
#define U2nA(s, d, l) WideCharToMultiByte(CP_ACP, 0, s, l, d, l, NULL, NULL)
#define A2U(s, d, l) MultiByteToWideChar(CP_ACP, 0, s, -1, d, l)
#define A2nU(s, d, l) MultiByteToWideChar(CP_ACP, 0, s, l, d, l)
#ifdef __WINE__
#ifdef UNICODE