mirror of
https://git.openafs.org/openafs.git
synced 2025-01-31 21:47:45 +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:
|
* Delete AFS mount points. Variables are used as follows:
|
||||||
* tbuffer: Set to point to the null-terminated directory name of the mount point
|
* tbuffer: Set to point to the null-terminated directory name of the mount point
|
||||||
@ -1247,28 +1280,7 @@ BOOL RemoveMount(CStringArray& files)
|
|||||||
HOURGLASS hourglass;
|
HOURGLASS hourglass;
|
||||||
|
|
||||||
for (int i = 0; i < files.GetSize(); i++) {
|
for (int i = 0; i < files.GetSize(); i++) {
|
||||||
char szCurItem[1024];
|
if (!IsMountPoint(files[i])) {
|
||||||
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) {
|
|
||||||
error = TRUE;
|
error = TRUE;
|
||||||
if (errno == EINVAL)
|
if (errno == EINVAL)
|
||||||
results.Add(GetMessageString(IDS_NOT_MOUNT_POINT_ERROR, StripPath(files[i])));
|
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_StripDriveLetter(const char *inPathp, char *outPathp, long outSize);
|
||||||
long fs_ExtractDriveLetter(const char *inPathp, char *outPathp);
|
long fs_ExtractDriveLetter(const char *inPathp, char *outPathp);
|
||||||
BOOL IsSymlink(const char * true_name);
|
BOOL IsSymlink(const char * true_name);
|
||||||
|
BOOL IsMountPoint(const char * name);
|
||||||
UINT MakeSymbolicLink(const char *,const char *);
|
UINT MakeSymbolicLink(const char *,const char *);
|
||||||
void ListSymbolicLinkPath(const char *strName,char *strPath,UINT nlenPath);
|
void ListSymbolicLinkPath(const char *strName,char *strPath,UINT nlenPath);
|
||||||
#endif //__GUI2FS_H__
|
#endif //__GUI2FS_H__
|
||||||
|
@ -224,9 +224,16 @@ STDMETHODIMP CShellExt::XMenuExt::QueryContextMenu(HMENU hMenu,UINT indexMenu,
|
|||||||
// Mount Point submenu of the AFS submenu
|
// Mount Point submenu of the AFS submenu
|
||||||
HMENU hMountPointMenu = CreatePopupMenu();
|
HMENU hMountPointMenu = CreatePopupMenu();
|
||||||
int indexMountPointMenu = 0;
|
int indexMountPointMenu = 0;
|
||||||
::InsertMenu(hMountPointMenu, indexMountPointMenu++, MF_STRING | MF_BYPOSITION, idCmdFirst + IDM_MOUNTPOINT_SHOW, GetMessageString(IDS_MP_SHOW_ITEM));
|
int nMountPointSelected = MF_GRAYED;
|
||||||
::InsertMenu(hMountPointMenu, indexMountPointMenu++, MF_STRING | MF_BYPOSITION, idCmdFirst + IDM_MOUNTPOINT_REMOVE, GetMessageString(IDS_MP_REMOVE_ITEM));
|
for (int n = pThis->m_astrFileNames.GetSize() - 1 ; n >= 0; n--) {
|
||||||
::InsertMenu(hMountPointMenu, indexMountPointMenu++, MF_STRING | MF_BYPOSITION, idCmdFirst + IDM_MOUNTPOINT_MAKE, GetMessageString(IDS_MP_MAKE_ITEM));
|
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 | 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));
|
::InsertMenu(hAfsMenu, indexAfsMenu++, MF_STRING | MF_BYPOSITION, idCmdFirst + IDM_FLUSH, GetMessageString(IDS_FLUSH_FILE_DIR_ITEM));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user