mirror of
https://github.com/python/cpython.git
synced 2025-11-10 22:36:18 +00:00
Added popen().
Added getmtime() function for use by ".pyc" processing.
This commit is contained in:
parent
c405b7b2fa
commit
3b06619e1c
1 changed files with 37 additions and 1 deletions
|
|
@ -427,7 +427,7 @@ posix_utime(self, args)
|
||||||
|
|
||||||
#ifndef MSDOS
|
#ifndef MSDOS
|
||||||
|
|
||||||
/* Process Primitives */
|
/* Process operations */
|
||||||
|
|
||||||
static object *
|
static object *
|
||||||
posix__exit(self, args)
|
posix__exit(self, args)
|
||||||
|
|
@ -544,6 +544,26 @@ posix_kill(self, args)
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static object *
|
||||||
|
posix_popen(self, args)
|
||||||
|
object *self;
|
||||||
|
object *args;
|
||||||
|
{
|
||||||
|
extern int pclose PROTO((FILE *));
|
||||||
|
object *name, *mode;
|
||||||
|
FILE *fp;
|
||||||
|
if (args == NULL || !is_tupleobject(args) || gettuplesize(args) != 2 ||
|
||||||
|
!is_stringobject(name = gettupleitem(args, 0)) ||
|
||||||
|
!is_stringobject(mode = gettupleitem(args, 1))) {
|
||||||
|
err_setstr(TypeError, "open() requires 2 string arguments");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
fp = popen(getstringvalue(name), getstringvalue(mode));
|
||||||
|
if (fp == NULL)
|
||||||
|
return posix_error();
|
||||||
|
return newopenfileobject(fp, name, mode, pclose);
|
||||||
|
}
|
||||||
|
|
||||||
static object *
|
static object *
|
||||||
posix_wait(self, args) /* Also waitpid() */
|
posix_wait(self, args) /* Also waitpid() */
|
||||||
object *self;
|
object *self;
|
||||||
|
|
@ -644,6 +664,7 @@ static struct methodlist posix_methods[] = {
|
||||||
{"getpid", posix_getpid},
|
{"getpid", posix_getpid},
|
||||||
{"getppid", posix_getppid},
|
{"getppid", posix_getppid},
|
||||||
{"kill", posix_kill},
|
{"kill", posix_kill},
|
||||||
|
{"popen", posix_popen},
|
||||||
{"wait", posix_wait},
|
{"wait", posix_wait},
|
||||||
#endif
|
#endif
|
||||||
#ifndef NO_LSTAT
|
#ifndef NO_LSTAT
|
||||||
|
|
@ -675,6 +696,21 @@ initposix()
|
||||||
fatal("can't define posix.error");
|
fatal("can't define posix.error");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Function used elsewhere to get a file's modification time */
|
||||||
|
|
||||||
|
long
|
||||||
|
getmtime(path)
|
||||||
|
char *path;
|
||||||
|
{
|
||||||
|
struct stat st;
|
||||||
|
if (stat(path, &st) != 0)
|
||||||
|
return -1;
|
||||||
|
else
|
||||||
|
return st.st_mtime;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef MSDOS
|
#ifdef MSDOS
|
||||||
|
|
||||||
/* A small "compatibility library" for TurboC under MS-DOS */
|
/* A small "compatibility library" for TurboC under MS-DOS */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue