To be on the safe side I would change these too in data.c (haven't yet tested it):
char book_path[255] = { BOOKDIR };
char log_path[255] = { LOGDIR };
char tb_path[255] = { TBDIR };
char rc_path[255] = { RCDIR };
I think that defining a LONGEST_PATH_LENGTH=255 constant and checking against it in various parts of the code would make it a lot more robust against Java programmers.
Although I'm a very unskilled C programmer and don't have any knowledge of computer chess programming I found navigating through Crafty's code easy. It's not only a competitive chess engine, but its code base is a great learning tool to the business of computer chess.
Problem integrating Crafty with Windows GUI
Moderators: hgm, Rebel, chrisw
Re: Problem integrating Crafty with Windows GUI
What about using MAX_PATH / PATH_MAX (can't remember off the top of my head which one is Windows and which is Unix).
Andy.
Andy.
-
- Posts: 20943
- Joined: Mon Feb 27, 2006 7:30 pm
- Location: Birmingham, AL
Re: Problem integrating Crafty with Windows GUI
There is no "MAX_PATH" concept in unix. I have had directories hundreds of levels deep...plattyaj wrote:What about using MAX_PATH / PATH_MAX (can't remember off the top of my head which one is Windows and which is Unix).
Andy.
-
- Posts: 12566
- Joined: Wed Mar 08, 2006 8:57 pm
- Location: Redmond, WA USA
Re: Problem integrating Crafty with Windows GUI
Every C compiler must include a macro called FILENAME_MAX in stdio.h and this symbol must be the maximum length of a legal file name for that operating system.bob wrote:There is no "MAX_PATH" concept in unix. I have had directories hundreds of levels deep...plattyaj wrote:What about using MAX_PATH / PATH_MAX (can't remember off the top of my head which one is Windows and which is Unix).
Andy.
ISO/IEC 9899:TC3 Committee Draft — Septermber 7, 2007 WG14/N1256
7.19 Input/output <stdio.h>
FILENAME_MAX
which expands to an integer constant expression that is the size needed for an array of char large enough to hold the longest file name string that the implementation guarantees can be opened; (see footnote 231)
footnote 231) If the implementation imposes no practical limit on the length of file name strings, the value of FILENAME_MAX should instead be the recommended size of an array intended to hold a file name string. Of course, file name string contents are subject to other system-specific constraints; therefore all possible strings of length FILENAME_MAX cannot be expected to be opened successfully.
Re: Problem integrating Crafty with Windows GUI
True to a point. The O/S will let you build a directory structure that deep but it won't let you open it (at least not in one go):bob wrote:There is no "MAX_PATH" concept in unix. I have had directories hundreds of levels deep...plattyaj wrote:What about using MAX_PATH / PATH_MAX (can't remember off the top of my head which one is Windows and which is Unix).
Andy.
Try this little snippet - it will stop at some point:
Code: Select all
#!/usr/bin/ksh
let COUNT=0
THE_PATH=.
while [ $COUNT -lt 1100 ]; do
THE_PATH=$THE_PATH/testp
mkdir $THE_PATH
if [ $? -eq 1 ]; then
echo "Stopped at $COUNT"
exit 0
fi
let COUNT=${COUNT}+1
done
Andy.
-
- Posts: 20943
- Joined: Mon Feb 27, 2006 7:30 pm
- Location: Birmingham, AL
Re: Problem integrating Crafty with Windows GUI
The question is, is that a korn shell limit, since it is building the path/filename internally? There must be a limit, but I have not run across one in actual practice... But then no sane person has directories 20 levels deep in the first place, that is simply a good way to lose files by forgetting where they are.plattyaj wrote:True to a point. The O/S will let you build a directory structure that deep but it won't let you open it (at least not in one go):bob wrote:There is no "MAX_PATH" concept in unix. I have had directories hundreds of levels deep...plattyaj wrote:What about using MAX_PATH / PATH_MAX (can't remember off the top of my head which one is Windows and which is Unix).
Andy.
Try this little snippet - it will stop at some point:
On the Linux system I tested that on, MAX_PATH was 4096 and this stopped where COUNT was 682 right where you would expect. But I could cd into that directory and run it again, etc.Code: Select all
#!/usr/bin/ksh let COUNT=0 THE_PATH=. while [ $COUNT -lt 1100 ]; do THE_PATH=$THE_PATH/testp mkdir $THE_PATH if [ $? -eq 1 ]; then echo "Stopped at $COUNT" exit 0 fi let COUNT=${COUNT}+1 done
Andy.