Page 1 of 1
Can’t save WS while file mapped
Posted: Sat Sep 23, 2017 3:05 pm
by jmosk
I am using the ⌷MAP function to read a binary file. When I try to save the workspace, I get an error message saying the function can’t be executed while a file is mapped. I copied the data into a matrix then copied a vector form of the data to a different variable. I erased the variable to which the data was read thinking that perhaps this is keeping the file mapped, but still got the error. How do I break the connection to the mapped file so I can save the WS?
Re: Can’t save WS while file mapped
Posted: Mon Sep 25, 2017 11:11 am
by Geoff|Dyalog
⎕MAP produces an array that has reference semantics. Namespaces also have reference semantics.
You break these by using indexing. So
a←80 1 2 3 ⎕map '/dev/zero'
maps /dev/zero which, on Unix/Linux/MacOs, is a "file" that reads as an infinite length - all zeros.
So I now have a 3 dimensional array of shape 1 2 3 that is all null character.
)save ./junk.dws
Cannot perform operation with mapped files present.
b←a[;;]
⎕ex'a'
)save ./junk.dws
./junk.dws saved Mon Sep 25 11:38:54 2017
The data is saved in the workspace as "b". You could equally have reused "a".
The mapping is also broken if all of the names that still reference it are reassigned.
a←80 1 2 3 ⎕map '/dev/zero'
)save ./junk.dws
Cannot perform operation with mapped files present.
a←1
)save ./junk.dws
./junk.dws saved Mon Sep 25 12:01:14 2017
In this case the data is not saved in the workspace. No name still references it.