summaryrefslogtreecommitdiffstats
path: root/Modules/posixmodule.c
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2006-02-18 22:29:33 (GMT)
committerGeorg Brandl <georg@python.org>2006-02-18 22:29:33 (GMT)
commitf4f4415a18cebdc6e0498c8b178e12978414f5d0 (patch)
treecc1492865323485f5c7e9ec6b8ce365ed54c8c74 /Modules/posixmodule.c
parent47fab92542133b9a3936f8771560bd6167db9d4d (diff)
downloadcpython-f4f4415a18cebdc6e0498c8b178e12978414f5d0.zip
cpython-f4f4415a18cebdc6e0498c8b178e12978414f5d0.tar.gz
cpython-f4f4415a18cebdc6e0498c8b178e12978414f5d0.tar.bz2
Patch #1393157: os.startfile() now has an optional argument to specify
a "command verb" to invoke on the file.
Diffstat (limited to 'Modules/posixmodule.c')
-rw-r--r--Modules/posixmodule.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index f35c090..bd5c32a 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -7385,11 +7385,15 @@ posix_abort(PyObject *self, PyObject *noargs)
#ifdef MS_WINDOWS
PyDoc_STRVAR(win32_startfile__doc__,
-"startfile(filepath) - Start a file with its associated application.\n\
+"startfile(filepath [, operation]) - Start a file with its associated\n\
+application.\n\
\n\
-This acts like double-clicking the file in Explorer, or giving the file\n\
-name as an argument to the DOS \"start\" command: the file is opened\n\
-with whatever application (if any) its extension is associated.\n\
+When \"operation\" is not specified or \"open\", this acts like\n\
+double-clicking the file in Explorer, or giving the file name as an\n\
+argument to the DOS \"start\" command: the file is opened with whatever\n\
+application (if any) its extension is associated.\n\
+When another \"operation\" is given, it specifies what should be done with\n\
+the file. A typical operation is \"print\".\n\
\n\
startfile returns as soon as the associated application is launched.\n\
There is no option to wait for the application to close, and no way\n\
@@ -7403,12 +7407,15 @@ static PyObject *
win32_startfile(PyObject *self, PyObject *args)
{
char *filepath;
+ char *operation = NULL;
HINSTANCE rc;
- if (!PyArg_ParseTuple(args, "et:startfile",
- Py_FileSystemDefaultEncoding, &filepath))
+ if (!PyArg_ParseTuple(args, "et|s:startfile",
+ Py_FileSystemDefaultEncoding, &filepath,
+ &operation))
return NULL;
Py_BEGIN_ALLOW_THREADS
- rc = ShellExecute((HWND)0, NULL, filepath, NULL, NULL, SW_SHOWNORMAL);
+ rc = ShellExecute((HWND)0, operation, filepath,
+ NULL, NULL, SW_SHOWNORMAL);
Py_END_ALLOW_THREADS
if (rc <= (HINSTANCE)32) {
PyObject *errval = win32_error("startfile", filepath);