Kaydet (Commit) 0bb44a4a authored tarafından Tim Peters's avatar Tim Peters

Closes SF bug 113894: on Windows, things like os.listdir("k:") and

glob.glob("k:*py") (i.e., a raw drive letter + colon at the start) were
using the root of the drive rather than the expected Windows behavior
of using the drive's "current directory".
üst a2ebb87b
...@@ -796,6 +796,7 @@ posix_listdir(PyObject *self, PyObject *args) ...@@ -796,6 +796,7 @@ posix_listdir(PyObject *self, PyObject *args)
HANDLE hFindFile; HANDLE hFindFile;
WIN32_FIND_DATA FileData; WIN32_FIND_DATA FileData;
char namebuf[MAX_PATH+5]; char namebuf[MAX_PATH+5];
char ch;
if (!PyArg_ParseTuple(args, "t#:listdir", &name, &len)) if (!PyArg_ParseTuple(args, "t#:listdir", &name, &len))
return NULL; return NULL;
...@@ -804,7 +805,8 @@ posix_listdir(PyObject *self, PyObject *args) ...@@ -804,7 +805,8 @@ posix_listdir(PyObject *self, PyObject *args)
return NULL; return NULL;
} }
strcpy(namebuf, name); strcpy(namebuf, name);
if (namebuf[len-1] != '/' && namebuf[len-1] != '\\') ch = namebuf[len-1];
if (ch != '/' && ch != '\\' && ch != ':')
namebuf[len++] = '/'; namebuf[len++] = '/';
strcpy(namebuf + len, "*.*"); strcpy(namebuf + len, "*.*");
...@@ -844,8 +846,7 @@ posix_listdir(PyObject *self, PyObject *args) ...@@ -844,8 +846,7 @@ posix_listdir(PyObject *self, PyObject *args)
return d; return d;
#else /* !MS_WIN32 */ #elif defined(_MSC_VER) /* 16-bit Windows */
#ifdef _MSC_VER /* 16-bit Windows */
#ifndef MAX_PATH #ifndef MAX_PATH
#define MAX_PATH 250 #define MAX_PATH 250
...@@ -906,8 +907,7 @@ posix_listdir(PyObject *self, PyObject *args) ...@@ -906,8 +907,7 @@ posix_listdir(PyObject *self, PyObject *args)
return d; return d;
#else #elif defined(PYOS_OS2)
#if defined(PYOS_OS2)
#ifndef MAX_PATH #ifndef MAX_PATH
#define MAX_PATH CCHMAXPATH #define MAX_PATH CCHMAXPATH
...@@ -1016,10 +1016,8 @@ posix_listdir(PyObject *self, PyObject *args) ...@@ -1016,10 +1016,8 @@ posix_listdir(PyObject *self, PyObject *args)
return d; return d;
#endif /* !PYOS_OS2 */ #endif /* which OS */
#endif /* !_MSC_VER */ } /* end of posix_listdir */
#endif /* !MS_WIN32 */
}
static char posix_mkdir__doc__[] = static char posix_mkdir__doc__[] =
"mkdir(path [, mode=0777]) -> None\n\ "mkdir(path [, mode=0777]) -> None\n\
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment