Wed Jun 26 00:48:45 2024 by Matthew |
Hi, I'm using the offline version and when I go to output the map into a folder i get this error "Could not open output file C:\Users\Matthew.bmp, error code = 13" I'm fairly certain that it's because there is a space between my first name and last name in the file path. I've tried putting the path in quotes, using a backtick ` to exclude the character and putting an ampersand & in front of the quoted path. I'm on windows. any idea what's going on or how to fix it? |
Wed Jun 26 00:52:49 2024 by Matthew |
wait, different problem now. while it was in quotes I got rid of the space between -o and the file path. it seems to have done something, I didn't get an error, but my map isn't in the folder. full command (without last name): .\planet.exe -s 0.1 -w 200 -h 100 -E -pq -o"C:\Users\Matthew **\Desktop\plantmaps" |
Wed Jun 26 01:17:39 2024 by Matthew |
Ok, I finally understand what's going on. is there any way of having your files appears in a different file? |
Wed Jun 26 01:18:05 2024 by Matthew |
folder* |
Wed Jun 26 09:29:55 2024 by Torben |
I regularly put files in different directories/folders than the one from which I start the command, using both relative and absolute file paths. I use Linux, so this might make a difference. In your second example, you use * in the file name. I assume this represents an unspecified part of the file name. This does not work, nor do spaces in file names (even in quoted file names or with escape characters), as I use the fopen() function to open files. As for the space, a space is required between -o and the file name. My best suggestion is to use an output file without spaces and then rename/move the file afterwards. |
Sun Jul 7 04:19:03 2024 by Mizuki |
The problem seems to be not with fopen() which can handle spaces fine, but with sscanf(av[++i],"%s",filename); , since %s will only read input until the first space. Maybe fgets() would be a better function to use? |
Sun Jul 7 04:31:09 2024 by Mizuki |
According to this: https://stackoverflow.com/questions/43970463/file-name-contains-spaces-cant-open-with-fopen, the answer is simply substituting %s with a specifier that allow spaces like [\n] - which will read until the line terminator. A simple patch would be to replace case 'o' : sscanf(av[++i],"%s",filename); with case 'o' : sscanf(av[++i],"%255[\n]",filename); and case 'C' : sscanf(av[++i],"%s",colorsname); with case 'C' : sscanf(av[++i],"%255[\n]",colorsname); which will also allow spaces in colors file names. (The 255 is just to check against buffer overflow since we defined filename and colorsname to be [256] Test: plstest.exe -o " b aa" -s 0.3113 -w 1000 -h 500 will create " b aa.bmp" (how do you actually escape carets in this forum?) |
Sun Jul 7 04:49:44 2024 by Mizuki |
According to this: https://stackoverflow.com/questions/43970463/file-name-contains-spaces-cant-open-with-fopen, the answer is simply substituting %s with a specifier that allow spaces like [\n] - which will read until the line terminator. A simple patch would be to replace case 'o' : sscanf(av[++i],"%s",filename); with case 'o' : sscanf(av[++i],"%255[\n]",filename); and case 'C' : sscanf(av[++i],"%s",colorsname); with case 'C' : sscanf(av[++i],"%255[\n]",colorsname); which will also allow spaces in colors file names. (The 255 is just to check against buffer overflow since we defined filename and colorsname to be [256] Test: plstest.exe -o " b aa" -s 0.3113 -w 1000 -h 500 will create " b aa.bmp" (how do you actually escape carets in this forum?) |
Sun Jul 7 09:07:03 2024 by Mizuki |
Also, I do have a precompiled version here if you wish to get the fix without getting mingw or visual studio: https://github.com/MagicalDrizzle/planet-generator |
Mon Jul 8 12:56:40 2024 by Torben |
Thanks. It fixes reading file names with spaces, but fopen() will still not open the file. Maybe it works differently on Windows? |
Tue Jul 9 05:33:32 2024 by Mizuki |
I don't have access to a Linux machine right now, but it works just fine on Termux on Android for me. https://ibb.co/X7Vny6V |
Tue Jul 9 13:26:44 2024 by Torben |
It does, indeed, seem to work now. I don't know what went wrong yesterday. |
Tue Jul 9 14:16:06 2024 by Mizuki |
Well computers love being finicky haha Anyhow I hope you will consider merging this into the next update ^ |