Problem example:
fopen() succesfully opens:
C:\Render\Floors\1234567890.bmp
But fails to open:
C:\Render\Floors\1234567890a.bmp
what could be the problem?
Thank you
C:\Render\Floors\1234567890a.bmp
should be
C:\\Render\\Floors\\1234567890a.bmp
John
I work in win32 env
anyway I tried,
1. C:\\Render\\Floors\\1234567890.bmp => FAILED
2. C:\Render\Floors\1234567890.bmp => SUCCESS
...
How big is the buffer you are storing your file name in?
Unless the filename is "hard coded', I typically allow 256 characters (MAX_PATH in windows) but I'm guessing you have it set to 32... which is far too small.
Bingo,
here is your guess(and my mistake):
#define MAXFLDSIZE 32
Thank you
Quote from: raviv on March 02, 2011, 12:21:43 PM
Bingo,
here is your guess(and my mistake):
#define MAXFLDSIZE 32
Thank you
;D Every once in a while I get real lucky...
If you are using #include <windows.h> you can use their MAX_PATH as I mentioned. It's used throughout windows so you can be pretty sure you won't get a filename longer than that.
The ANSI Windows API functions use MAX_PATH as the maximum path length.
The UNICODE functions use 32kB as the maximum path length.
You just need to decide, which route to go.
Quote from: Stefan Pendl on March 02, 2011, 11:07:39 PM
The ANSI Windows API functions use MAX_PATH as the maximum path length.
The UNICODE functions use 32kB as the maximum path length.
You just need to decide, which route to go.
I may be horridly mistaken here but I don't think that's universal... MAX_PATH is used internally by most windows functions... It's still 260 characters but of course in Unicode a character is 16 bits, not 8.
From the CreateFile Function (http://msdn.microsoft.com/en-us/library/aa363858%28VS.85%29.aspx) description at MSDN:
QuoteIn the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path.
And this is not the only location, where you can find it.
Quote from: Stefan Pendl on March 02, 2011, 11:54:57 PM
From the CreateFile Function (http://msdn.microsoft.com/en-us/library/aa363858%28VS.85%29.aspx) description at MSDN:
QuoteIn the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path.
And this is not the only location, where you can find it.
Yes, but only with the special code... without that: MAX_PATH, either way. This much I already knew.