Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
V
vmspython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OpenVMS
Python
Modules
vmspython
Commits
a3e428f4938b
Commit
a3e428f4938b
authored
1 year ago
by
jfp
Browse files
Options
Downloads
Patches
Plain Diff
rms.search return file fid, use it. Add FILEQIO.create class method
parent
f04f54a524c6
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
python/local/ovms_module/ovms/fileqio.py
+97
-3
97 additions, 3 deletions
python/local/ovms_module/ovms/fileqio.py
with
97 additions
and
3 deletions
python/local/ovms_module/ovms/fileqio.py
+
97
−
3
View file @
a3e428f4
import
ctypes
import
ctypes
from
ovms
import
ast
from
ovms
import
crtl
from
ovms
import
descrip
from
ovms
import
iodef
from
ovms
import
iodef
from
ovms
import
efndef
from
ovms
import
efndef
from
ovms
import
iosbdef
from
ovms
import
iosbdef
...
@@ -8,7 +11,6 @@
...
@@ -8,7 +11,6 @@
from
ovms
import
atrdef
from
ovms
import
atrdef
from
ovms
import
starlet
from
ovms
import
starlet
from
ovms
import
stsdef
from
ovms
import
stsdef
from
ovms
import
ast
from
typing
import
Tuple
from
typing
import
Tuple
...
@@ -27,5 +29,7 @@
...
@@ -27,5 +29,7 @@
self
.
fibdesc
=
None
self
.
fibdesc
=
None
def
_open_p1
(
self
)
->
Tuple
[
int
,
fibdef
.
FIBDEF
]:
def
_open_p1
(
self
)
->
Tuple
[
int
,
fibdef
.
FIBDEF
]:
dev
=
rms
.
search
(
self
.
filename
)[
1
]
rs
=
rms
.
search
(
self
.
filename
,
fid
=
True
)
dev
=
rs
[
1
]
ifid
=
rs
[
-
1
]
...
@@ -31,5 +35,4 @@
...
@@ -31,5 +35,4 @@
ifid
=
rms
.
getrmsattr
(
self
.
filename
,
rms
.
RMSATTR_K_FID
)
fid
=
fibdef
.
FIDDEF
()
fid
=
fibdef
.
FIDDEF
()
fid
.
fid_w_num
=
ifid
[
0
]
&
0x0000FFFF
fid
.
fid_w_num
=
ifid
[
0
]
&
0x0000FFFF
fid
.
fid_w_seq
=
ifid
[
1
]
&
0x0000FFFF
fid
.
fid_w_seq
=
ifid
[
1
]
&
0x0000FFFF
...
@@ -333,3 +336,94 @@
...
@@ -333,3 +336,94 @@
await
ast
.
wait_completion
(
astctxt
)
await
ast
.
wait_completion
(
astctxt
)
if
not
stsdef
.
vms_status_success
(
iosb
.
iosb_w_status
):
if
not
stsdef
.
vms_status_success
(
iosb
.
iosb_w_status
):
raise
IOError
(
iosb
.
iosb_w_status
,
"
IOSB awriteblk error
"
)
raise
IOError
(
iosb
.
iosb_w_status
,
"
IOSB awriteblk error
"
)
@classmethod
def
_create
(
cls
,
filename
:
str
,
exsz
:
int
,
fat
:
fatdef
.
FAT
,
astctxt
:
ast
.
AstContext
|
None
=
None
,
)
->
iosbdef
.
IOSB_r_io_64
:
qio_call
=
starlet
.
vms_qiow
if
astctxt
is
None
else
starlet
.
vms_qio
r
=
rms
.
parse
(
filename
)
chan
=
starlet
.
assign
(
r
[
1
])[
1
]
r
=
b
""
.
join
(
r
[
1
:
3
])
r
=
crtl
.
from_vms
(
r
)
r
=
crtl
.
to_vms
(
r
,
0
,
1
)
+
"
.DIR
"
# type: ignore
r
=
rms
.
getrmsattr
(
r
,
rms
.
RMSATTR_K_FID
)
fib
=
fibdef
.
FIBDEF
()
fib
.
fib_w_nmctl
=
fibdef
.
FIB_M_NEWVER
fib
.
fib_r_did_fields
.
fid_w_num
=
r
[
0
]
&
0x0000FFFF
fib
.
fib_r_did_fields
.
fid_w_seq
=
r
[
1
]
&
0x0000FFFF
fib
.
fib_r_did_fields
.
fid_b_rvn
=
(
r
[
0
]
&
0x00FF0000
)
>>
16
fib
.
fib_r_did_fields
.
fid_b_nmx
=
r
[
2
]
&
0xFF
fib
.
fib_w_exctl
=
fibdef
.
FIB_M_EXTEND
# | fibdef.FIB_M_ALDEF
fib
.
fib_l_exsz
=
exsz
fib
.
fib_l_acctl
=
fibdef
.
FIB_M_NOWRITE
|
fibdef
.
FIB_M_WRITE
fibdesc
=
fibdef
.
FIBDESC
()
fibdesc
.
length
=
ctypes
.
sizeof
(
fib
)
fibdesc
.
a_fibdef
=
ctypes
.
pointer
(
fib
)
efn
=
ctypes
.
c_uint32
(
efndef
.
EFN_C_ENF
)
ichan
=
ctypes
.
c_uint16
(
chan
)
zero64
=
ctypes
.
c_uint64
(
0
)
func
=
ctypes
.
c_uint32
(
iodef
.
IO__CREATE
|
iodef
.
IO_M_CREATE
)
iosb
=
iosbdef
.
IOSB_r_io_64
()
if
astctxt
is
None
:
c_ast_completion
=
None
c_ast_param
=
zero64
else
:
c_ast_completion
=
ctypes
.
c_uint64
(
ast
.
vms_ast_completion
)
c_ast_param
=
ctypes
.
c_uint64
(
id
(
astctxt
))
atr1
=
atrdef
.
ATR
()
atrdef
.
set_atr_item
(
atr1
,
atrdef
.
ATR_S_RECATTR
,
atrdef
.
ATR_C_RECATTR
,
ctypes
.
pointer
(
fat
),
)
atr2
=
atrdef
.
ATR
()
# default fill with zeros
atrs
=
(
atrdef
.
ATR
*
2
)(
atr1
,
atr2
)
status
=
qio_call
(
efn
,
ichan
,
func
,
ctypes
.
byref
(
iosb
),
c_ast_completion
,
c_ast_param
,
ctypes
.
byref
(
fibdesc
),
descrip
.
bydesc
(
filename
.
encode
()),
zero64
,
zero64
,
ctypes
.
byref
(
atrs
),
zero64
,
)
if
not
stsdef
.
vms_status_success
(
status
):
starlet
.
dassgn
(
chan
)
raise
IOError
(
status
,
"
qio _create CREATE error
"
)
return
iosb
@classmethod
def
create
(
cls
,
filename
:
str
,
exsz
:
int
,
fifat
:
fatdef
.
FAT
|
None
=
None
):
fat
=
fatdef
.
FAT
()
if
fifat
is
not
None
:
ctypes
.
memmove
(
ctypes
.
byref
(
fat
),
ctypes
.
byref
(
fifat
),
ctypes
.
sizeof
(
fat
))
# set eof
fat
.
fat_w_efblkh
=
0
fat
.
fat_l_efblkl
=
1
fat
.
fat_w_ffbyte
=
0
iosb
=
FILEQIO
.
_create
(
filename
,
exsz
,
fat
,
None
)
if
not
stsdef
.
vms_status_success
(
iosb
.
iosb_w_status
):
raise
IOError
(
iosb
.
iosb_w_status
,
"
IOSB create error
"
)
return
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment