|
From: Patrick M. <ume...@us...> - 2008-07-17 18:16:00
|
Update of /cvsroot/radmind/radmind In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv12512 Modified Files: fsdiff.c Log Message: If path doesn't contain a directory, canonicalize it by prepending "./". This allows paths to be dynamically converted between relative and absolute paths without breaking sort order. Index: fsdiff.c =================================================================== RCS file: /cvsroot/radmind/radmind/fsdiff.c,v retrieving revision 1.79 retrieving revision 1.80 diff -C2 -d -r1.79 -r1.80 *** fsdiff.c 3 Nov 2007 15:25:45 -0000 1.79 --- fsdiff.c 17 Jul 2008 18:15:55 -0000 1.80 *************** *** 259,263 **** int finish = 0; struct stat st; ! char type; struct applefileinfo afinfo; --- 259,263 ---- int finish = 0; struct stat st; ! char type, buf[ MAXPATHLEN ]; struct applefileinfo afinfo; *************** *** 360,363 **** --- 360,385 ---- } + /* If path_prefix doesn't contain a directory, canonicalize it by + * prepending a "./". This allow paths to be dynamically converted between + * relative and absolute paths without breaking sort order. + */ + switch( path_prefix[ 0 ] ) { + case '/': + break; + + case '.': + if ( path_prefix[ 1 ] == '/' ) { + break; + } + default: + if ( snprintf( buf, sizeof( buf ), "./%s", + path_prefix ) >= MAXPATHLEN ) { + fprintf( stderr, "path too long\n" ); + exit( 2 ); + } + path_prefix = buf; + break; + } + if ( radstat( path_prefix, &st, &type, &afinfo ) != 0 ) { perror( path_prefix ); |