windows-pioctl-20050902

support '/' as well as '\\' in pioctl calls
This commit is contained in:
Jeffrey Altman 2005-09-02 18:23:50 +00:00
parent 001f9b9732
commit d04a62e641

View File

@ -348,14 +348,16 @@ GetIoctlHandle(char *fileNamep, HANDLE * handlep)
tbuffer[1] = ':'; tbuffer[1] = ':';
strcpy(tbuffer + 2, SMB_IOCTL_FILENAME); strcpy(tbuffer + 2, SMB_IOCTL_FILENAME);
} else if (fileNamep[0] == fileNamep[1] && } else if (fileNamep[0] == fileNamep[1] &&
fileNamep[0] == '\\') (fileNamep[0] == '\\' || fileNamep[0] == '/'))
{ {
int count = 0, i = 0; int count = 0, i = 0;
while (count < 4 && fileNamep[i]) { while (count < 4 && fileNamep[i]) {
tbuffer[i] = fileNamep[i]; tbuffer[i] = fileNamep[i];
if ( tbuffer[i++] == '\\' ) if ( tbuffer[i] == '\\' ||
tbuffer[i] == '/')
count++; count++;
i++;
} }
if (fileNamep[i] == 0) if (fileNamep[i] == 0)
tbuffer[i++] = '\\'; tbuffer[i++] = '\\';
@ -370,14 +372,16 @@ GetIoctlHandle(char *fileNamep, HANDLE * handlep)
tbuffer[1] = ':'; tbuffer[1] = ':';
strcpy(tbuffer + 2, SMB_IOCTL_FILENAME); strcpy(tbuffer + 2, SMB_IOCTL_FILENAME);
} else if (curdir[0] == curdir[1] && } else if (curdir[0] == curdir[1] &&
curdir[0] == '\\') (curdir[0] == '\\' || curdir[0] == '/'))
{ {
int count = 0, i = 0; int count = 0, i = 0;
while (count < 4 && curdir[i]) { while (count < 4 && curdir[i]) {
tbuffer[i] = curdir[i]; tbuffer[i] = curdir[i];
if ( tbuffer[i++] == '\\' ) if ( tbuffer[i] == '\\' ||
count++; tbuffer[i] == '/')
count++;
i++;
} }
if (tbuffer[i] == 0) if (tbuffer[i] == 0)
tbuffer[i++] = '\\'; tbuffer[i++] = '\\';
@ -741,9 +745,10 @@ fs_GetFullPath(char *pathp, char *outPathp, long outSize)
int pathHasDrive; int pathHasDrive;
int doSwitch; int doSwitch;
char newPath[3]; char newPath[3];
HANDLE rootDir; HANDLE rootDir;
wchar_t *wpath; wchar_t *wpath;
unsigned long length; unsigned long length;
char * p;
#ifdef AFSIFS #ifdef AFSIFS
if (!pathp) if (!pathp)
@ -778,7 +783,8 @@ fs_GetFullPath(char *pathp, char *outPathp, long outSize)
pathHasDrive = 0; pathHasDrive = 0;
} }
if ( firstp[0] == '\\' && firstp[1] == '\\') { if ( firstp[0] == '\\' && firstp[1] == '\\' ||
firstp[0] == '/' && firstp[1] == '/') {
/* UNC path - strip off the server and sharename */ /* UNC path - strip off the server and sharename */
int i, count; int i, count;
for ( i=2,count=2; count < 4 && firstp[i]; i++ ) { for ( i=2,count=2; count < 4 && firstp[i]; i++ ) {
@ -791,10 +797,18 @@ fs_GetFullPath(char *pathp, char *outPathp, long outSize)
} else { } else {
strcpy(outPathp,&firstp[--i]); strcpy(outPathp,&firstp[--i]);
} }
for (p=outPathp ;*p; p++) {
if (*p == '/')
*p = '\\';
}
return 0; return 0;
} else if (firstp[0] == '\\' || firstp[0] == '/') { } else if (firstp[0] == '\\' || firstp[0] == '/') {
/* already an absolute pathname, just copy it back */ /* already an absolute pathname, just copy it back */
strcpy(outPathp, firstp); strcpy(outPathp, firstp);
for (p=outPathp ;*p; p++) {
if (*p == '/')
*p = '\\';
}
return 0; return 0;
} }
@ -824,7 +838,8 @@ fs_GetFullPath(char *pathp, char *outPathp, long outSize)
GetCurrentDirectory(sizeof(tpath), tpath); GetCurrentDirectory(sizeof(tpath), tpath);
if (tpath[1] == ':') if (tpath[1] == ':')
strcpy(outPathp, tpath + 2); /* skip drive letter */ strcpy(outPathp, tpath + 2); /* skip drive letter */
else if ( tpath[0] == '\\' && tpath[1] == '\\') { else if ( tpath[0] == '\\' && tpath[1] == '\\'||
tpath[0] == '/' && tpath[1] == '/') {
/* UNC path - strip off the server and sharename */ /* UNC path - strip off the server and sharename */
int i, count; int i, count;
for ( i=2,count=2; count < 4 && tpath[i]; i++ ) { for ( i=2,count=2; count < 4 && tpath[i]; i++ ) {
@ -855,6 +870,10 @@ fs_GetFullPath(char *pathp, char *outPathp, long outSize)
SetCurrentDirectory(origPath); SetCurrentDirectory(origPath);
} }
for (p=outPathp ;*p; p++) {
if (*p == '/')
*p = '\\';
}
return 0; return 0;
} }