Fossil

Check-in [a7822bcc]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment: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.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: a7822bcc001e9fce21a6f97803a02ae221f0cea8
User & Date: drh 2009-11-14 14:38:10
References
2011-01-06
21:34 Ticket [99caf06e] Error moving a file to a directory with ../.. status still Open with 2 other changes artifact: a9a4256f user: anonymous
Context
2009-11-23
13:21
Update the SQLite used internally to the first 3.6.21 release candidate. check-in: f3d4a2db user: drh tags: trunk
2009-11-14
14:38
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. check-in: a7822bcc user: drh tags: trunk
2009-11-11
16:21
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. check-in: d5695157 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/file.c.

136
137
138
139
140
141
142
143
144
145




146
147
148
149
150
151
152
153
...
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
/*
** Return 1 if zFilename is a directory.  Return 0 if zFilename
** does not exist.  Return 2 if zFilename exists but is something
** 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;
}

/*
** Create the directory named in the argument, if it does not already
** exist.  If forceFlag is 1, delete any prior non-directory object 
** with the same name.
**
................................................................................
    if( z[i]=='\\' ) z[i] = '/';
  }
#endif
  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]=='/' ){
        i += 1;
        continue;
      }
      if( z[i+1]=='.' && i+3<n && z[i+2]=='.' && z[i+3]=='/' ){
        while( j>0 && z[j-1]!='/' ){ j--; }
        if( j>0 ){ j--; }
        i += 2;
        continue;
      }
    }
    z[j++] = z[i];







|
|
|
>
>
>
>
|







 







|



|







136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
...
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
/*
** Return 1 if zFilename is a directory.  Return 0 if zFilename
** does not exist.  Return 2 if zFilename exists but is something
** other than a directory.
*/
int file_isdir(const char *zFilename){
  struct stat buf;
  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
** exist.  If forceFlag is 1, delete any prior non-directory object 
** with the same name.
**
................................................................................
    if( z[i]=='\\' ) z[i] = '/';
  }
#endif
  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]=='/') ){
        i += 1;
        continue;
      }
      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;
      }
    }
    z[j++] = z[i];