FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python/RISCOS/unixstuff.c at master · fruitegg/python · GitHub
fruitegg
/
python
Public
forked from
glix/python
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
python
/
RISCOS
/
unixstuff.c
Copy path
More file actions
More file actions
Latest commit
History
History
History
74 lines (61 loc) · 1.73 KB
Breadcrumbs
python
/
RISCOS
/
unixstuff.c
Copy path
File metadata and controls
74 lines (61 loc) · 1.73 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/* Fudge unix isatty and fileno for RISCOS */
#include
"unixstuff.h"
#include
<math.h>
#include
<time.h>
#include
"oslib/osfile.h"
int
fileno
(
FILE
*
f
)
{
return
(
int
)
f
;
}
int
isatty
(
int
fn
)
{
return
(
fn
==
fileno
(
stdin
));
}
bits
unixtime
(
bits
ld
,
bits
ex
)
{
ld
&=
0xFF
;
ld
-=
51
;
if
(
ex
<
1855547904U
)
ld
--
;
ex
-=
1855548004U
;
return
ex
/
100
+
42949673U
*
ld
-
ld
/
25
;
}
/* from RISC OS infozip, preserves filetype in ld */
int
acorntime
(
bits
*
ex
,
bits
*
ld
,
time_t
utime
)
{
unsigned
timlo
;
/* 3 lower bytes of acorn file-time plus carry byte */
unsigned
timhi
;
/* 2 high bytes of acorn file-time */
timlo
=
((
unsigned
)
utime
&
0x00ffffffU
)
*
100
+
0x00996a00U
;
timhi
=
((
unsigned
)
utime
>>
24
);
timhi
=
timhi
*
100
+
0x0000336eU
+
(
timlo
>>
24
);
if
(
timhi
&
0xffff0000U
)
return
1
;
/* calculation overflow, do not change time */
/* insert the five time bytes into loadaddr and execaddr variables */
*
ex
=
(
timlo
&
0x00ffffffU
) | ((
timhi
&
0x000000ffU
) <<
24
);
*
ld
=
(
*
ld
&
0xffffff00U
) | ((
timhi
>>
8
)
&
0x000000ffU
);
return
0
;
/* subject to future extension to signal overflow */
}
int
isdir
(
char
*
fn
)
{
int
ob
;
if
(
xosfile_read_stamped_no_path
(
fn
,
&
ob
,
0
,
0
,
0
,
0
,
0
))
return
0
;
switch
(
ob
)
{
case
osfile_IS_DIR
:
return
1
;
case
osfile_IS_IMAGE
:
return
1
;
}
return
0
;
}
int
isfile
(
char
*
fn
)
{
int
ob
;
if
(
xosfile_read_stamped_no_path
(
fn
,
&
ob
,
0
,
0
,
0
,
0
,
0
))
return
0
;
switch
(
ob
)
{
case
osfile_IS_FILE
:
return
1
;
case
osfile_IS_IMAGE
:
return
1
;
}
return
0
;
}
int
object_exists
(
char
*
fn
)
{
int
ob
;
if
(
xosfile_read_stamped_no_path
(
fn
,
&
ob
,
0
,
0
,
0
,
0
,
0
))
return
0
;
switch
(
ob
)
{
case
osfile_IS_FILE
:
return
1
;
case
osfile_IS_DIR
:
return
1
;
case
osfile_IS_IMAGE
:
return
1
;
}
return
0
;
}
Back
|
FazBrowse Home
|
New Git URL