mirror of
https://git.openafs.org/openafs.git
synced 2025-01-19 15:30:14 +00:00
windows-shell-ext-remove-mtpt-20050420
Conditionalize the AFS->Mount Point->Remove menu item based upon whether or not the selected item(s) contain mount points
This commit is contained in:
parent
1099227e08
commit
9198f00b19
@ -1226,6 +1226,39 @@ BOOL IsSymlink(const char * true_name)
|
||||
}
|
||||
|
||||
|
||||
BOOL IsMountPoint(const char * name)
|
||||
{
|
||||
register LONG code = 0;
|
||||
struct ViceIoctl blob;
|
||||
char tbuffer[1024];
|
||||
char lsbuffer[1024];
|
||||
register char *tp;
|
||||
char szCurItem[1024];
|
||||
strcpy(szCurItem, name);
|
||||
|
||||
tp = (char *)strrchr(szCurItem, '\\');
|
||||
if (tp) {
|
||||
strncpy(tbuffer, szCurItem, code = tp - szCurItem + 1); /* the dir name */
|
||||
tbuffer[code] = 0;
|
||||
tp++; /* skip the slash */
|
||||
} else {
|
||||
fs_ExtractDriveLetter(szCurItem, tbuffer);
|
||||
strcat(tbuffer, ".");
|
||||
tp = szCurItem;
|
||||
fs_StripDriveLetter(tp, tp, 0);
|
||||
}
|
||||
|
||||
blob.in = tp;
|
||||
blob.in_size = strlen(tp)+1;
|
||||
blob.out = lsbuffer;
|
||||
blob.out_size = sizeof(lsbuffer);
|
||||
|
||||
code = pioctl(tbuffer, VIOC_AFS_STAT_MT_PT, &blob, 0);
|
||||
|
||||
return (code==0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Delete AFS mount points. Variables are used as follows:
|
||||
* tbuffer: Set to point to the null-terminated directory name of the mount point
|
||||
@ -1247,28 +1280,7 @@ BOOL RemoveMount(CStringArray& files)
|
||||
HOURGLASS hourglass;
|
||||
|
||||
for (int i = 0; i < files.GetSize(); i++) {
|
||||
char szCurItem[1024];
|
||||
strcpy(szCurItem, files[i]);
|
||||
|
||||
tp = (char *)strrchr(szCurItem, '\\');
|
||||
if (tp) {
|
||||
strncpy(tbuffer, szCurItem, code = tp - szCurItem + 1); /* the dir name */
|
||||
tbuffer[code] = 0;
|
||||
tp++; /* skip the slash */
|
||||
} else {
|
||||
fs_ExtractDriveLetter(szCurItem, tbuffer);
|
||||
strcat(tbuffer, ".");
|
||||
tp = szCurItem;
|
||||
fs_StripDriveLetter(tp, tp, 0);
|
||||
}
|
||||
|
||||
blob.in = tp;
|
||||
blob.in_size = strlen(tp)+1;
|
||||
blob.out = lsbuffer;
|
||||
blob.out_size = sizeof(lsbuffer);
|
||||
|
||||
code = pioctl(tbuffer, VIOC_AFS_STAT_MT_PT, &blob, 0);
|
||||
if (code) {
|
||||
if (!IsMountPoint(files[i])) {
|
||||
error = TRUE;
|
||||
if (errno == EINVAL)
|
||||
results.Add(GetMessageString(IDS_NOT_MOUNT_POINT_ERROR, StripPath(files[i])));
|
||||
|
@ -39,6 +39,7 @@ int GetCellName(char *baseNamep, struct afsconf_cell *infop);
|
||||
long fs_StripDriveLetter(const char *inPathp, char *outPathp, long outSize);
|
||||
long fs_ExtractDriveLetter(const char *inPathp, char *outPathp);
|
||||
BOOL IsSymlink(const char * true_name);
|
||||
BOOL IsMountPoint(const char * name);
|
||||
UINT MakeSymbolicLink(const char *,const char *);
|
||||
void ListSymbolicLinkPath(const char *strName,char *strPath,UINT nlenPath);
|
||||
#endif //__GUI2FS_H__
|
||||
|
@ -224,9 +224,16 @@ STDMETHODIMP CShellExt::XMenuExt::QueryContextMenu(HMENU hMenu,UINT indexMenu,
|
||||
// Mount Point submenu of the AFS submenu
|
||||
HMENU hMountPointMenu = CreatePopupMenu();
|
||||
int indexMountPointMenu = 0;
|
||||
::InsertMenu(hMountPointMenu, indexMountPointMenu++, MF_STRING | MF_BYPOSITION, idCmdFirst + IDM_MOUNTPOINT_SHOW, GetMessageString(IDS_MP_SHOW_ITEM));
|
||||
::InsertMenu(hMountPointMenu, indexMountPointMenu++, MF_STRING | MF_BYPOSITION, idCmdFirst + IDM_MOUNTPOINT_REMOVE, GetMessageString(IDS_MP_REMOVE_ITEM));
|
||||
::InsertMenu(hMountPointMenu, indexMountPointMenu++, MF_STRING | MF_BYPOSITION, idCmdFirst + IDM_MOUNTPOINT_MAKE, GetMessageString(IDS_MP_MAKE_ITEM));
|
||||
int nMountPointSelected = MF_GRAYED;
|
||||
for (int n = pThis->m_astrFileNames.GetSize() - 1 ; n >= 0; n--) {
|
||||
if ( IsMountPoint(pThis->m_astrFileNames[n]) ) {
|
||||
nMountPointSelected = MF_ENABLED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
::InsertMenu(hMountPointMenu, indexMountPointMenu++, MF_STRING | MF_BYPOSITION, idCmdFirst + IDM_MOUNTPOINT_SHOW, GetMessageString(IDS_MP_SHOW_ITEM));
|
||||
::InsertMenu(hMountPointMenu, indexMountPointMenu++, MF_STRING | MF_BYPOSITION | nMountPointSelected, idCmdFirst + IDM_MOUNTPOINT_REMOVE, GetMessageString(IDS_MP_REMOVE_ITEM));
|
||||
::InsertMenu(hMountPointMenu, indexMountPointMenu++, MF_STRING | MF_BYPOSITION, idCmdFirst + IDM_MOUNTPOINT_MAKE, GetMessageString(IDS_MP_MAKE_ITEM));
|
||||
::InsertMenu(hAfsMenu, indexAfsMenu++, MF_STRING | MF_BYPOSITION | MF_POPUP, (UINT)hMountPointMenu, GetMessageString(IDS_MOUNT_POINT_ITEM));
|
||||
|
||||
::InsertMenu(hAfsMenu, indexAfsMenu++, MF_STRING | MF_BYPOSITION, idCmdFirst + IDM_FLUSH, GetMessageString(IDS_FLUSH_FILE_DIR_ITEM));
|
||||
|
Loading…
Reference in New Issue
Block a user