mirror of https://github.com/python/cpython.git
Incorporated MSDOS changes (untested).
This commit is contained in:
parent
1ff6cb4f4f
commit
0ee42cdcf9
|
@ -29,20 +29,31 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
#define SYSV
|
#define SYSV
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef MSDOS
|
||||||
|
#define NO_LSTAT
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#ifdef SYSV
|
#ifdef SYSV
|
||||||
|
|
||||||
#define UTIME_STRUCT
|
#define UTIME_STRUCT
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#define direct dirent
|
#define direct dirent
|
||||||
#ifdef i386
|
#ifdef i386
|
||||||
#define mode_t int
|
#define mode_t int
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#else /* !SYSV */
|
#else /* !SYSV */
|
||||||
|
|
||||||
|
#ifndef MSDOS
|
||||||
#include <sys/dir.h>
|
#include <sys/dir.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* !SYSV */
|
#endif /* !SYSV */
|
||||||
|
|
||||||
#include "allobjects.h"
|
#include "allobjects.h"
|
||||||
|
@ -209,6 +220,7 @@ posix_getcwd(self, args)
|
||||||
return newstringobject(buf);
|
return newstringobject(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef MSDOS
|
||||||
static object *
|
static object *
|
||||||
posix_link(self, args)
|
posix_link(self, args)
|
||||||
object *self;
|
object *self;
|
||||||
|
@ -217,6 +229,7 @@ posix_link(self, args)
|
||||||
extern int link PROTO((const char *, const char *));
|
extern int link PROTO((const char *, const char *));
|
||||||
return posix_2str(args, link);
|
return posix_2str(args, link);
|
||||||
}
|
}
|
||||||
|
#endif /* !MSDOS */
|
||||||
|
|
||||||
static object *
|
static object *
|
||||||
posix_listdir(self, args)
|
posix_listdir(self, args)
|
||||||
|
@ -224,6 +237,33 @@ posix_listdir(self, args)
|
||||||
object *args;
|
object *args;
|
||||||
{
|
{
|
||||||
object *name, *d, *v;
|
object *name, *d, *v;
|
||||||
|
|
||||||
|
#ifdef MSDOS
|
||||||
|
struct ffblk ep;
|
||||||
|
int rv;
|
||||||
|
if (!getstrarg(args, &name))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (findfirst((char *) getstringvalue(name), &ep, 0) == -1)
|
||||||
|
return posix_error();
|
||||||
|
if ((d = newlistobject(0)) == NULL)
|
||||||
|
return NULL;
|
||||||
|
do {
|
||||||
|
v = newstringobject(ep.ff_name);
|
||||||
|
if (v == NULL) {
|
||||||
|
DECREF(d);
|
||||||
|
d = NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (addlistitem(d, v) != 0) {
|
||||||
|
DECREF(v);
|
||||||
|
DECREF(d);
|
||||||
|
d = NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
DECREF(v);
|
||||||
|
} while ((rv = findnext(&ep)) == 0);
|
||||||
|
#else /* !MSDOS */
|
||||||
DIR *dirp;
|
DIR *dirp;
|
||||||
struct direct *ep;
|
struct direct *ep;
|
||||||
if (!getstrarg(args, &name))
|
if (!getstrarg(args, &name))
|
||||||
|
@ -250,6 +290,8 @@ posix_listdir(self, args)
|
||||||
DECREF(v);
|
DECREF(v);
|
||||||
}
|
}
|
||||||
closedir(dirp);
|
closedir(dirp);
|
||||||
|
#endif /* !MSDOS */
|
||||||
|
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,7 +317,7 @@ rename(from, to)
|
||||||
return status;
|
return status;
|
||||||
return unlink(from);
|
return unlink(from);
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* i386 */
|
||||||
|
|
||||||
static object *
|
static object *
|
||||||
posix_rename(self, args)
|
posix_rename(self, args)
|
||||||
|
@ -317,6 +359,7 @@ posix_system(self, args)
|
||||||
return newintobject((long)sts);
|
return newintobject((long)sts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef MSDOS
|
||||||
static object *
|
static object *
|
||||||
posix_umask(self, args)
|
posix_umask(self, args)
|
||||||
object *self;
|
object *self;
|
||||||
|
@ -330,6 +373,7 @@ posix_umask(self, args)
|
||||||
return posix_error();
|
return posix_error();
|
||||||
return newintobject((long)i);
|
return newintobject((long)i);
|
||||||
}
|
}
|
||||||
|
#endif /* !MSDOS */
|
||||||
|
|
||||||
static object *
|
static object *
|
||||||
posix_unlink(self, args)
|
posix_unlink(self, args)
|
||||||
|
@ -380,7 +424,6 @@ posix_utime(self, args)
|
||||||
#undef MTIME
|
#undef MTIME
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifndef NO_LSTAT
|
#ifndef NO_LSTAT
|
||||||
|
|
||||||
static object *
|
static object *
|
||||||
|
@ -424,14 +467,18 @@ static struct methodlist posix_methods[] = {
|
||||||
{"chdir", posix_chdir},
|
{"chdir", posix_chdir},
|
||||||
{"chmod", posix_chmod},
|
{"chmod", posix_chmod},
|
||||||
{"getcwd", posix_getcwd},
|
{"getcwd", posix_getcwd},
|
||||||
|
#ifndef MSDOS
|
||||||
{"link", posix_link},
|
{"link", posix_link},
|
||||||
|
#endif
|
||||||
{"listdir", posix_listdir},
|
{"listdir", posix_listdir},
|
||||||
{"mkdir", posix_mkdir},
|
{"mkdir", posix_mkdir},
|
||||||
{"rename", posix_rename},
|
{"rename", posix_rename},
|
||||||
{"rmdir", posix_rmdir},
|
{"rmdir", posix_rmdir},
|
||||||
{"stat", posix_stat},
|
{"stat", posix_stat},
|
||||||
{"system", posix_system},
|
{"system", posix_system},
|
||||||
|
#ifndef MSDOS
|
||||||
{"umask", posix_umask},
|
{"umask", posix_umask},
|
||||||
|
#endif
|
||||||
{"unlink", posix_unlink},
|
{"unlink", posix_unlink},
|
||||||
{"utime", posix_utime},
|
{"utime", posix_utime},
|
||||||
{"utimes", posix_utime}, /* XXX for compatibility only */
|
{"utimes", posix_utime}, /* XXX for compatibility only */
|
||||||
|
@ -463,3 +510,47 @@ initposix()
|
||||||
if (PosixError == NULL || dictinsert(d, "error", PosixError) != 0)
|
if (PosixError == NULL || dictinsert(d, "error", PosixError) != 0)
|
||||||
fatal("can't define posix.error");
|
fatal("can't define posix.error");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef MSDOS
|
||||||
|
|
||||||
|
/* A small "compatibility library" for TurboC under MS-DOS */
|
||||||
|
|
||||||
|
#include <sir.h>
|
||||||
|
#include <io.h>
|
||||||
|
#include <dos.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
chmod(path, mode)
|
||||||
|
char *path;
|
||||||
|
int mode;
|
||||||
|
{
|
||||||
|
return _chmod(path, 1, mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
utime(path, times)
|
||||||
|
char *path;
|
||||||
|
time_t times[2];
|
||||||
|
{
|
||||||
|
struct date dt;
|
||||||
|
struct time tm;
|
||||||
|
struct ftime dft;
|
||||||
|
int fh;
|
||||||
|
unixtodos(tv[0].tv_sec,&dt,&tm);
|
||||||
|
dft.ft_tsec = tm.ti_sec; dft.ft_min = tm.ti_min;
|
||||||
|
dft.ft_hour = tm.ti_hour; dft.ft_day = dt.da_day;
|
||||||
|
dft.ft_month = dt.da_mon;
|
||||||
|
dft.ft_year = (dt.da_year - 1980); /* this is for TC library */
|
||||||
|
|
||||||
|
if ((fh = open(getstringvalue(path),O_RDWR)) < 0)
|
||||||
|
return posix_error(); /* can't open file to set time */
|
||||||
|
if (setftime(fh,&dft) < 0)
|
||||||
|
{
|
||||||
|
close(fh);
|
||||||
|
return posix_error();
|
||||||
|
}
|
||||||
|
close(fh); /* close the temp handle */
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* MSDOS */
|
||||||
|
|
Loading…
Reference in New Issue