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,7 +218,6 @@ void NtObjDirectory::read_directory(int scan_flags)
*w++ = '\\';
#endif
if (_type == DIRECTORY_OBJECT) {
NtObjectInfo* info = (NtObjectInfo*)alloca(2048);
if (!(*g_NTDLL->NtQueryDirectoryObject)(dir_handle, info, 2048, TRUE, TRUE, &idx, NULL)) {
@ -253,8 +252,6 @@ void NtObjDirectory::read_directory(int scan_flags)
else if (type == SYMBOLICLINK_OBJECT) {
w32fd.dwFileAttributes |= ATTRIBUTE_SYMBOLIC_LINK;
//@@_toscan |= INF_DESCRIPTION;
entry = NULL;
if (*w32fd.cFileName>='A' &&*w32fd.cFileName<='Z' && w32fd.cFileName[1]==':')
@ -280,10 +277,10 @@ void NtObjDirectory::read_directory(int scan_flags)
#ifdef UNICODE
lstrcpyW(p, info->name.string_ptr);
if (!NtOpenObject(_type, &handle, 0, buffer))
if (!NtOpenObject(type, &handle, 0, buffer))
#else
lstrcpyW(w, info->name.string_ptr);
if (!NtOpenObject(_type, &handle, 0, wbuffer))
if (!NtOpenObject(type, &handle, 0, wbuffer))
#endif
{
NtObject object;
@ -297,6 +294,22 @@ void NtObjDirectory::read_directory(int scan_flags)
entry->_bhfi_valid = true;
}
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
wcsncpy(entry->_content, link, len);
#else
U2nA(link, entry->_content, len);
#endif
entry->_content[len] = '\0';
}
}
(*g_NTDLL->NtClose)(handle);
}
@ -326,53 +339,6 @@ void NtObjDirectory::read_directory(int scan_flags)
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);
}
*/
}
/*@@
if (_toscan & INF_DESCRIPTION) {
_toscan &= ~INF_DESCRIPTION;
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);
#else
U2T(link, _description, -1);
#endif
_inf |= INF_DESCRIPTION;
}
}
}
*/
(*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
// 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