[PD] A quick question for C dev - temp file on windows

Christof Ressi info at christofressi.com
Thu Jun 23 15:48:46 CEST 2022


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 at lists.iem.at mailing list
> UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list





More information about the Pd-list mailing list