Hi,
Not sure this is the right place to ask but i will try, maybe one of you can help.
I'm trying to use "fopen" for a file located in my working directory however it is not working and i'm not sure for the correct path so i thought of trying something like "getcwd".Is there any recommendation for opening a file from a relative path?
Thanks,Ronen
Hi Ronen,
I did a quick test. If running the example on the FVP, you need to disable (debugger) semihosting, as the FVP handles the semihosting itself.
Use the command:
set semihosting enabled 0
either up on connect, and "Debug from Entry Point", or in a "target initialization script" as set in the Debugger pane or the Debug Configuration view.
As for where it finds the file... it seems to create and write the file in the Scripts directory [\sw\debugger\configdb\Scripts] of the DS install. I assume this is because of how the debugger and the FVP are integrated. I could not find any way to change this... it does not relate to the Current Working Directory (use the debugger command print $cwd to see this). Unfortunately I've not found a good workaround other than to use a full path in your code:myfile= fopen("C:\\work\\fopen\\hello.txt", "w+");
Running the FVP directly from the command line (FVP -a <image.axf>) uses that current folder as expected.
Regards, Ronan
Thanks Ronan.calling print $cwd from the debugger reveals the current working dir.