summaryrefslogtreecommitdiffstats
path: root/Python/import.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2010-10-07 21:45:39 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2010-10-07 21:45:39 (GMT)
commit4e31443c4d2c1fb211a6ea90fc6a8fbd9ff81c97 (patch)
tree5fb0a5fc704c00fcdd2b9885ac0896ab2f971309 /Python/import.c
parent7ae7c87b058137537bdc2b7f1d8e585aa0245c1c (diff)
downloadcpython-4e31443c4d2c1fb211a6ea90fc6a8fbd9ff81c97.zip
cpython-4e31443c4d2c1fb211a6ea90fc6a8fbd9ff81c97.tar.gz
cpython-4e31443c4d2c1fb211a6ea90fc6a8fbd9ff81c97.tar.bz2
Create fileutils.c/.h
* _Py_fopen() and _Py_stat() come from Python/import.c * (_Py)_wrealpath() comes from Python/sysmodule.c * _Py_char2wchar(), _Py_wchar2char() and _Py_wfopen() come from Modules/main.c * (_Py)_wstat(), (_Py)_wgetcwd(), _Py_wreadlink() come from Modules/getpath.c
Diffstat (limited to 'Python/import.c')
-rw-r--r--Python/import.c65
1 files changed, 0 insertions, 65 deletions
diff --git a/Python/import.c b/Python/import.c
index ab1615c..48fd205 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -1953,73 +1953,8 @@ case_ok(char *buf, Py_ssize_t len, Py_ssize_t namelen, char *name)
#endif
}
-/* Call _wfopen() on Windows, or fopen() otherwise. Return the new file
- object on success, or NULL if the file cannot be open or (if
- PyErr_Occurred()) on unicode error */
-
-FILE*
-_Py_fopen(PyObject *unicode, const char *mode)
-{
-#ifdef MS_WINDOWS
- wchar_t *path;
- wchar_t wmode[10];
- int usize;
- FILE *f;
-
- usize = MultiByteToWideChar(CP_ACP, 0, mode, -1, wmode, sizeof(wmode));
- if (usize == 0)
- return NULL;
-
- path = PyUnicode_AsWideCharString(unicode, NULL);
- if (path == NULL)
- return NULL;
- f = _wfopen(path, wmode);
- PyMem_Free(path);
- return f;
-#else
- FILE *f;
- PyObject *bytes = PyUnicode_EncodeFSDefault(unicode);
- if (bytes == NULL)
- return NULL;
- f = fopen(PyBytes_AS_STRING(bytes), mode);
- Py_DECREF(bytes);
- return f;
-#endif
-}
-
#ifdef HAVE_STAT
-/* Call _wstat() on Windows, or stat() otherwise. Only fill st_mode
- attribute on Windows. Return 0 on success, -1 on stat error or (if
- PyErr_Occurred()) unicode error. */
-
-int
-_Py_stat(PyObject *unicode, struct stat *statbuf)
-{
-#ifdef MS_WINDOWS
- wchar_t *path;
- int err;
- struct _stat wstatbuf;
-
- path = PyUnicode_AsWideCharString(unicode, NULL);
- if (path == NULL)
- return -1;
- err = _wstat(path, &wstatbuf);
- PyMem_Free(path);
- if (!err)
- statbuf->st_mode = wstatbuf.st_mode;
- return err;
-#else
- int ret;
- PyObject *bytes = PyUnicode_EncodeFSDefault(unicode);
- if (bytes == NULL)
- return -1;
- ret = stat(PyBytes_AS_STRING(bytes), statbuf);
- Py_DECREF(bytes);
- return ret;
-#endif
-}
-
/* Helper to look for __init__.py or __init__.py[co] in potential package */
static int
find_init_module(char *buf)