Commit 8e791e3b authored by Guido van Rossum's avatar Guido van Rossum

Updated version of RISCOS support. SF patch 411213 by Dietmar Schwertberger

parent 49fbc9f3
......@@ -203,21 +203,30 @@ def exists(p):
"""
Test whether a path exists.
"""
return swi.swi('OS_File', '5s;i', p)!=0
try:
return swi.swi('OS_File', '5s;i', p)!=0
except swi.error:
return 0
def isdir(p):
"""
Is a path a directory? Includes image files.
"""
return swi.swi('OS_File', '5s;i', p) in [2, 3]
try:
return swi.swi('OS_File', '5s;i', p) in [2, 3]
except swi.error:
return 0
def isfile(p):
"""
Test whether a path is a file, including image files.
"""
return swi.swi('OS_File', '5s;i', p) in [1, 3]
try:
return swi.swi('OS_File', '5s;i', p) in [1, 3]
except swi.error:
return 0
def islink(p):
......
......@@ -26,10 +26,18 @@
static char **orig_argv;
static int orig_argc;
/* For my_readline when running under RISCOS */
#ifdef RISCOS
/* command line options */
#define BASE_OPTS "c:diOStuUvxXhVW:"
#ifndef RISCOS
#define PROGRAM_OPTS BASE_OPTS
#else /*RISCOS*/
/* extra option saying that we are running under a special task window
frontend; especially my_readline will behave different */
#define PROGRAM_OPTS BASE_OPTS "w"
/* corresponding flag */
extern int Py_RISCOSWimpFlag;
#endif
#endif /*RISCOS*/
/* Short usage message (with %s for argv0) */
static char *usage_line =
......@@ -115,11 +123,7 @@ Py_Main(int argc, char **argv)
PySys_ResetWarnOptions();
#ifdef RISCOS
while ((c = getopt(argc, argv, "c:diOStuUvwxXhV")) != EOF) {
#else
while ((c = _PyOS_GetOpt(argc, argv, "c:diOStuUvxXhVW:")) != EOF) {
#endif
while ((c = _PyOS_GetOpt(argc, argv, PROGRAM_OPTS)) != EOF) {
if (c == 'c') {
/* -c is the last option; following arguments
that look like options are left for the
......
......@@ -756,9 +756,7 @@ floatsleep(double secs)
#if defined(__WATCOMC__) && !defined(__QNX__)
/* XXX Can't interrupt this sleep */
Py_BEGIN_ALLOW_THREADS
#ifndef RISCOS
delay((int)(secs * 1000 + 0.5)); /* delay() uses milliseconds */
#endif
Py_END_ALLOW_THREADS
#else /* !__WATCOMC__ || __QNX__ */
#ifdef MSDOS
......@@ -831,10 +829,20 @@ floatsleep(double secs)
Py_END_ALLOW_THREADS
}
#else /* !__BEOS__ */
#ifdef RISCOS
if (secs <= 0.0)
return 0;
Py_BEGIN_ALLOW_THREADS
/* This sleep *CAN BE* interrupted. */
if ( sleep(secs) )
return -1;
Py_END_ALLOW_THREADS
#else /* !RISCOS */
/* XXX Can't interrupt this sleep */
Py_BEGIN_ALLOW_THREADS
sleep((int)secs);
Py_END_ALLOW_THREADS
#endif /* !RISCOS */
#endif /* !__BEOS__ */
#endif /* !PYOS_OS2 */
#endif /* !MS_WIN32 */
......
......@@ -808,7 +808,11 @@ PySys_SetArgv(int argc, char **argv)
if (argc > 0 && argv0 != NULL)
p = strrchr(argv0, SEP);
if (p != NULL) {
#ifndef RISCOS
n = p + 1 - argv0;
#else /* don't include trailing separator */
n = p - argv0;
#endif /* RISCOS */
#if SEP == '/' /* Special case for Unix filename syntax */
if (n > 1)
n--; /* Drop trailing separator */
......
This diff is collapsed.
#include "osmodule.h"
#include <stdio.h>
#include "kernel.h"
#include <limits.h>
#include <errno.h>
#include "taskwindow.h"
#include "Python.h"
int sleep(double delay)
{
os_t starttime, endtime, time; /* monotonic times (centiseconds) */
int *pollword, ret;
bool claimed;
/* calculate end time */
starttime = os_read_monotonic_time();
if (starttime + 100.0*delay >INT_MAX)
endtime = INT_MAX;
else
endtime = (os_t)(starttime + 100.0*delay);
/* allocate (in RMA) and set pollword for xupcall_sleep */
pollword = osmodule_alloc(4);
*pollword = 1;
time = starttime;
ret = 0;
while ( time<endtime && time>=starttime ) {
xupcall_sleep (pollword, &claimed);
if (PyErr_CheckSignals()) {
ret = 1;
break;
}
time = os_read_monotonic_time();
}
/* deallocate pollword */
osmodule_free(pollword);
return ret;
}
set Python$Dir <Obey$Dir>
set PythonApp$Path <Obey$Dir>.
IconSprites <Obey$Dir>.!Sprites
<Obey$Dir>.AddToPath Python$Path PythonApp:Lib
<Obey$Dir>.AddToPath Python$Path PythonApp:Lib.plat-riscos
<Obey$Dir>.AddToPath Python$Path PythonApp:Lib.site-packages
set Alias$@RunType_ae5 TaskWindow |"python %%*0|" -name |"Python|" -quit
| -display
set File$Type_ae5 Python
set Alias$Python Run <Python$Dir>.python21 %*0
\ No newline at end of file
<Obey$Dir>.!Boot
TaskWindow "python" -name "Python" -quit -display
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment