Hello
In an external I use the superb tmpnam(x) to generate a temp file path to use and delete. All is good then… for MacOS and Linux that is! In Windows, the code in C does create a file but when I try to pass it to TCL to open there, like in the amazing ELSE’s pic, I can’t - the inverted backslash are deleted. I tried also, like in else, using open_canvas to no avail.
Now I tried to use on windows the ELSE’s pic to troubleshoot and it seems I have 2 problems:
#1:
open C:/Users/pa/Documents/tmp.0.8eDtGO
But not this: open C:/Users/pa/appData/Local/tmp.0.8eDtGO
===
#2
C:\Users\pa\Documents\tmp.0.8eDtGO
Won’t work but
C:/Users/pa/Documents/tmp.0.8eDtGO’
will
===
So I wonder if there are pearls of wisdom on temp file generation for cross OS compile. At the moment, if I use the PIC hack of going through canvas_open I get a ‘void’ name, and if I don’t I get errors due to the backslash not being digested by TCL (it seems - the error is as above)
p
Ps Alexandre, without you and your code, this object would not exist, so 39402940923 thanks!
Generally, Pd only uses forward slashes as file path seperators. You can use sys_bashfilename() on the path generated by tempnam().
On 23.06.2022 15:36, Pierre Alexandre Tremblay wrote:
Hello
In an external I use the superb tmpnam(x) to generate a temp file path to use and delete. All is good then… for MacOS and Linux that is! In Windows, the code in C does create a file but when I try to pass it to TCL to open there, like in the amazing ELSE’s pic, I can’t - the inverted backslash are deleted. I tried also, like in else, using open_canvas to no avail.
Now I tried to use on windows the ELSE’s pic to troubleshoot and it seems I have 2 problems:
#1:
- PIC will accept the file I create when it is on the Documents folder, but not the exact same file in the temp folder created by tmpnam. So this will work:
open C:/Users/pa/Documents/tmp.0.8eDtGO
But not this: open C:/Users/pa/appData/Local/tmp.0.8eDtGO
===
#2
- PIC will only accept with straight slashes /
C:\Users\pa\Documents\tmp.0.8eDtGO
Won’t work but
C:/Users/pa/Documents/tmp.0.8eDtGO’
will
===
So I wonder if there are pearls of wisdom on temp file generation for cross OS compile. At the moment, if I use the PIC hack of going through canvas_open I get a ‘void’ name, and if I don’t I get errors due to the backslash not being digested by TCL (it seems - the error is as above)
p
Ps Alexandre, without you and your code, this object would not exist, so 39402940923 thanks!
Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list
Ok this is magic thanks! I’ll update the thread with the new findings.
On 23 Jun 2022, at 14:48, Christof Ressi info@christofressi.com wrote:
Generally, Pd only uses forward slashes as file path seperators. You can use sys_bashfilename() on the path generated by tempnam().
On 23.06.2022 15:36, Pierre Alexandre Tremblay wrote:
Hello
In an external I use the superb tmpnam(x) to generate a temp file path to use and delete. All is good then… for MacOS and Linux that is! In Windows, the code in C does create a file but when I try to pass it to TCL to open there, like in the amazing ELSE’s pic, I can’t - the inverted backslash are deleted. I tried also, like in else, using open_canvas to no avail.
Now I tried to use on windows the ELSE’s pic to troubleshoot and it seems I have 2 problems:
#1:
- PIC will accept the file I create when it is on the Documents folder, but not the exact same file in the temp folder created by tmpnam. So this will work:
open C:/Users/pa/Documents/tmp.0.8eDtGO
But not this: open C:/Users/pa/appData/Local/tmp.0.8eDtGO
===
#2
- PIC will only accept with straight slashes /
C:\Users\pa\Documents\tmp.0.8eDtGO
Won’t work but
C:/Users/pa/Documents/tmp.0.8eDtGO’
will
===
So I wonder if there are pearls of wisdom on temp file generation for cross OS compile. At the moment, if I use the PIC hack of going through canvas_open I get a ‘void’ name, and if I don’t I get errors due to the backslash not being digested by TCL (it seems - the error is as above)
p
Ps Alexandre, without you and your code, this object would not exist, so 39402940923 thanks!
Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list
Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list
Ok the problem is simple: tcl accepts only path separated with ‘/‘ in windows but sys_bashfilename doesn’t convert the (adequately) created windows separator. So I’ll do a character substitutor.
Objvously the code is free and online so people can have a look or I can post here if that helps
On 23 Jun 2022, at 14:48, Christof Ressi info@christofressi.com wrote:
Generally, Pd only uses forward slashes as file path seperators. You can use sys_bashfilename() on the path generated by tempnam().
On 23.06.2022 15:36, Pierre Alexandre Tremblay wrote:
Hello
In an external I use the superb tmpnam(x) to generate a temp file path to use and delete. All is good then… for MacOS and Linux that is! In Windows, the code in C does create a file but when I try to pass it to TCL to open there, like in the amazing ELSE’s pic, I can’t - the inverted backslash are deleted. I tried also, like in else, using open_canvas to no avail.
Now I tried to use on windows the ELSE’s pic to troubleshoot and it seems I have 2 problems:
#1:
- PIC will accept the file I create when it is on the Documents folder, but not the exact same file in the temp folder created by tmpnam. So this will work:
open C:/Users/pa/Documents/tmp.0.8eDtGO
But not this: open C:/Users/pa/appData/Local/tmp.0.8eDtGO
===
#2
- PIC will only accept with straight slashes /
C:\Users\pa\Documents\tmp.0.8eDtGO
Won’t work but
C:/Users/pa/Documents/tmp.0.8eDtGO’
will
===
So I wonder if there are pearls of wisdom on temp file generation for cross OS compile. At the moment, if I use the PIC hack of going through canvas_open I get a ‘void’ name, and if I don’t I get errors due to the backslash not being digested by TCL (it seems - the error is as above)
p
Ps Alexandre, without you and your code, this object would not exist, so 39402940923 thanks!
Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list
Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list
but sys_bashfilename doesn’t convert the (adequately) created windows separator.
D'oh. I'm sorry, it's the other way round :-D The function you need is sys_unbashfilename()
On 23.06.2022 16:54, Pierre Alexandre Tremblay wrote:
Ok the problem is simple: tcl accepts only path separated with ‘/‘ in windows but sys_bashfilename doesn’t convert the (adequately) created windows separator. So I’ll do a character substitutor.
Objvously the code is free and online so people can have a look or I can post here if that helps
On 23 Jun 2022, at 14:48, Christof Ressi info@christofressi.com wrote:
Generally, Pd only uses forward slashes as file path seperators. You can use sys_bashfilename() on the path generated by tempnam().
On 23.06.2022 15:36, Pierre Alexandre Tremblay wrote:
Hello
In an external I use the superb tmpnam(x) to generate a temp file path to use and delete. All is good then… for MacOS and Linux that is! In Windows, the code in C does create a file but when I try to pass it to TCL to open there, like in the amazing ELSE’s pic, I can’t - the inverted backslash are deleted. I tried also, like in else, using open_canvas to no avail.
Now I tried to use on windows the ELSE’s pic to troubleshoot and it seems I have 2 problems:
#1:
- PIC will accept the file I create when it is on the Documents folder, but not the exact same file in the temp folder created by tmpnam. So this will work:
open C:/Users/pa/Documents/tmp.0.8eDtGO
But not this: open C:/Users/pa/appData/Local/tmp.0.8eDtGO
===
#2
- PIC will only accept with straight slashes /
C:\Users\pa\Documents\tmp.0.8eDtGO
Won’t work but
C:/Users/pa/Documents/tmp.0.8eDtGO’
will
===
So I wonder if there are pearls of wisdom on temp file generation for cross OS compile. At the moment, if I use the PIC hack of going through canvas_open I get a ‘void’ name, and if I don’t I get errors due to the backslash not being digested by TCL (it seems - the error is as above)
p
Ps Alexandre, without you and your code, this object would not exist, so 39402940923 thanks!
Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list
Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list
Am 23. Juni 2022 16:54:30 MESZ schrieb Pierre Alexandre Tremblay tremblap@gmail.com:
Ok the problem is simple: tcl accepts only path separated with ‘/‘ in windows but
Just for the record: i'm pretty sure this is technically incorrect: tcl will always accept the system path separator. However, when sending the data from the core to the GUI, you must take extra care to escape any backslashes, as the backslash character is special and used as *the* escape character in virtually everything that involves string handling on code level.
sys_bashfilename doesn’t convert the (adequately) created windows separator. So I’ll do a character substitutor.
The m_pd.h file is notoriously undocumented. However, if you learn of a (to you) completely new function and it does not exactly what you want, you might want to check out the header for context and similar (sounding) functions.
Also note that often there is some documentation of a given function inhe corresponding C implementation of Pd.
mfg.sfg.jfd IOhannes
Just for the record: i'm pretty sure this is technically incorrect: tcl will always accept the system path separator.
I have tried to double escape them but maybe that was my error - I couldn’t make it work.
However, when sending the data from the core to the GUI, you must take extra care to escape any backslashes, as the backslash character is special and used as *the* escape character in virtually everything that involves string handling on code level.
Indeed that would be the case. I could try but now I use the native one, as I was pretty certain I wasn’t the only person trying to send paths to tcl :)
sys_bashfilename doesn’t convert the (adequately) created windows separator. So I’ll do a character substitutor.
The m_pd.h file is notoriously undocumented.
It is. I presume one with the knowledge (deffo not yours truly :)) could put a comment per method.
However, if you learn of a (to you) completely new function and it does not exactly what you want, you might want to check out the header for context and similar (sounding) functions.
Also note that often there is some documentation of a given function inhe corresponding C implementation of Pd.
Oh good call, I’ll go read the source more often. It just strangely feels heavy, but I should just learn it.
Thanks for your help all. Alexandre, I might put a PR in Else with that call to sanitize the path.
p
Am 24. Juni 2022 09:49:58 MESZ schrieb Pierre Alexandre Tremblay tremblap@gmail.com:
Also note that often there is some documentation of a given function inhe corresponding C implementation of Pd.
Oh good call, I’ll go read the source more often.
I was not suggesting to read (and understand) the actual C-code, but to check the implementation for documentation.
/* change the system's native file separator to '/' characters */ void sys_unbashfilename(const char *from, char *to)
mfg.sfg.jfd IOhannes