equal
deleted
inserted
replaced
182 |
182 |
183 int kind = (fd->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) |
183 int kind = (fd->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) |
184 ? _S_IFDIR : _S_IFREG; |
184 ? _S_IFDIR : _S_IFREG; |
185 |
185 |
186 if (!wantstat) |
186 if (!wantstat) |
187 return Py_BuildValue("si", fd->cFileName, kind); |
187 return Py_BuildValue(PY23("si", "yi"), fd->cFileName, kind); |
188 |
188 |
189 py_st = PyObject_CallObject((PyObject *)&listdir_stat_type, NULL); |
189 py_st = PyObject_CallObject((PyObject *)&listdir_stat_type, NULL); |
190 if (!py_st) |
190 if (!py_st) |
191 return NULL; |
191 return NULL; |
192 |
192 |
200 stp->st_mtime = to_python_time(&fd->ftLastWriteTime); |
200 stp->st_mtime = to_python_time(&fd->ftLastWriteTime); |
201 stp->st_ctime = to_python_time(&fd->ftCreationTime); |
201 stp->st_ctime = to_python_time(&fd->ftCreationTime); |
202 if (kind == _S_IFREG) |
202 if (kind == _S_IFREG) |
203 stp->st_size = ((__int64)fd->nFileSizeHigh << 32) |
203 stp->st_size = ((__int64)fd->nFileSizeHigh << 32) |
204 + fd->nFileSizeLow; |
204 + fd->nFileSizeLow; |
205 return Py_BuildValue("siN", fd->cFileName, |
205 return Py_BuildValue(PY23("siN", "yiN"), fd->cFileName, |
206 kind, py_st); |
206 kind, py_st); |
207 } |
207 } |
208 |
208 |
209 static PyObject *_listdir(char *path, int plen, int wantstat, char *skip) |
209 static PyObject *_listdir(char *path, int plen, int wantstat, char *skip) |
210 { |
210 { |
388 |
388 |
389 if (keepstat) { |
389 if (keepstat) { |
390 stat = makestat(&st); |
390 stat = makestat(&st); |
391 if (!stat) |
391 if (!stat) |
392 goto error; |
392 goto error; |
393 elem = Py_BuildValue("siN", ent->d_name, kind, stat); |
393 elem = Py_BuildValue(PY23("siN", "yiN"), ent->d_name, |
|
394 kind, stat); |
394 } else |
395 } else |
395 elem = Py_BuildValue("si", ent->d_name, kind); |
396 elem = Py_BuildValue(PY23("si", "yi"), ent->d_name, |
|
397 kind); |
396 if (!elem) |
398 if (!elem) |
397 goto error; |
399 goto error; |
398 stat = NULL; |
400 stat = NULL; |
399 |
401 |
400 PyList_Append(list, elem); |
402 PyList_Append(list, elem); |
568 st.st_mtime = entry->mtime.tv_sec; |
570 st.st_mtime = entry->mtime.tv_sec; |
569 st.st_size = entry->size; |
571 st.st_size = entry->size; |
570 stat = makestat(&st); |
572 stat = makestat(&st); |
571 if (!stat) |
573 if (!stat) |
572 goto error; |
574 goto error; |
573 elem = Py_BuildValue("siN", filename, kind, stat); |
575 elem = Py_BuildValue(PY23("siN", "yiN"), |
|
576 filename, kind, stat); |
574 } else |
577 } else |
575 elem = Py_BuildValue("si", filename, kind); |
578 elem = Py_BuildValue(PY23("si", "yi"), |
|
579 filename, kind); |
576 if (!elem) |
580 if (!elem) |
577 goto error; |
581 goto error; |
578 stat = NULL; |
582 stat = NULL; |
579 |
583 |
580 PyList_Append(list, elem); |
584 PyList_Append(list, elem); |
1106 |
1110 |
1107 memset(&buf, 0, sizeof(buf)); |
1111 memset(&buf, 0, sizeof(buf)); |
1108 r = statfs(path, &buf); |
1112 r = statfs(path, &buf); |
1109 if (r != 0) |
1113 if (r != 0) |
1110 return PyErr_SetFromErrno(PyExc_OSError); |
1114 return PyErr_SetFromErrno(PyExc_OSError); |
1111 return Py_BuildValue("s", describefstype(&buf)); |
1115 return Py_BuildValue(PY23("s", "y"), describefstype(&buf)); |
1112 } |
1116 } |
1113 #endif /* defined(HAVE_LINUX_STATFS) || defined(HAVE_BSD_STATFS) */ |
1117 #endif /* defined(HAVE_LINUX_STATFS) || defined(HAVE_BSD_STATFS) */ |
1114 |
1118 |
1115 #if defined(HAVE_BSD_STATFS) |
1119 #if defined(HAVE_BSD_STATFS) |
1116 /* given a directory path, return filesystem mount point (best-effort) */ |
1120 /* given a directory path, return filesystem mount point (best-effort) */ |
1124 |
1128 |
1125 memset(&buf, 0, sizeof(buf)); |
1129 memset(&buf, 0, sizeof(buf)); |
1126 r = statfs(path, &buf); |
1130 r = statfs(path, &buf); |
1127 if (r != 0) |
1131 if (r != 0) |
1128 return PyErr_SetFromErrno(PyExc_OSError); |
1132 return PyErr_SetFromErrno(PyExc_OSError); |
1129 return Py_BuildValue("s", buf.f_mntonname); |
1133 return Py_BuildValue(PY23("s", "y"), buf.f_mntonname); |
1130 } |
1134 } |
1131 #endif /* defined(HAVE_BSD_STATFS) */ |
1135 #endif /* defined(HAVE_BSD_STATFS) */ |
1132 |
1136 |
1133 static PyObject *unblocksignal(PyObject *self, PyObject *args) |
1137 static PyObject *unblocksignal(PyObject *self, PyObject *args) |
1134 { |
1138 { |