Diff
Not logged in

Differences From:

File src/file.c part of check-in [d5695157d0] - Deal with windows filename aliasing in the "all" command. Ticket 974618fe5a8. Also display the home directory for windows users with the "info" command since the home directory is non-obvious in windows. by drh on 2009-11-11 16:21:19. [view]

To:

File src/file.c part of check-in [a7822bcc00] - In the file_isdir() routine, make sure the filename is simplified (has no "/../" or "/./" components and does not end with "/") in order to work around bugs in mingw. by drh on 2009-11-14 14:38:10. [view]

@@ -139,12 +139,16 @@
 ** other than a directory.
 */
 int file_isdir(const char *zFilename){
   struct stat buf;
-  if( stat(zFilename, &buf)!=0 ){
-    return 0;
-  }
-  return S_ISDIR(buf.st_mode) ? 1 : 2;
+  int rc;
+  char *zFN;
+
+  zFN = mprintf("%s", zFilename);
+  file_simplify_name(zFN, strlen(zFN));
+  rc = stat(zFN, &buf);
+  free(zFN);
+  return rc!=0 ? 0 : (S_ISDIR(buf.st_mode) ? 1 : 2);
 }
 
 /*
 ** Create the directory named in the argument, if it does not already
@@ -223,13 +227,13 @@
   while( n>1 && z[n-1]=='/' ){ n--; }
   for(i=j=0; i<n; i++){
     if( z[i]=='/' ){
       if( z[i+1]=='/' ) continue;
-      if( z[i+1]=='.' && i+2<n && z[i+2]=='/' ){
+      if( z[i+1]=='.' && (i+2==n || z[i+2]=='/') ){
         i += 1;
         continue;
       }
-      if( z[i+1]=='.' && i+3<n && z[i+2]=='.' && z[i+3]=='/' ){
+      if( z[i+1]=='.' && i+2<n && z[i+2]=='.' && (i+3==n || z[i+3]=='/') ){
         while( j>0 && z[j-1]!='/' ){ j--; }
         if( j>0 ){ j--; }
         i += 2;
         continue;