Fossil

Check-in [40376ef892]
Login

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

Overview
Comment:Enhance the file_canonical_name() function so that it always includes the drive letter prefix on Windows.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 40376ef892bbee029f554a413112eaa7fe86c7c15469f5aad6a2f140ed6ce6f0
User & Date: drh 2024-11-21 13:06:33.273
Context
2024-11-21
13:34
Strengthen the file_is_canonical() routine so that it returns false on Windows if the pathname does not begin with a drive letter. check-in: f6ff25e1b7 user: drh tags: trunk
13:06
Enhance the file_canonical_name() function so that it always includes the drive letter prefix on Windows. check-in: 40376ef892 user: drh tags: trunk
2024-11-19
14:28
Fix the /timeline page such that when the rl= query parameter is used, subsequent hyperlinks are correct. check-in: 761c24e7b0 user: drh tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/file.c.
1300
1301
1302
1303
1304
1305
1306

1307
1308
1309
1310


1311
1312
1313
1314
1315
1316

1317
1318








1319

1320
1321
1322
1323
1324
1325
1326
1327
1328
  }else{
    return 0;
  }
}

/*
** Compute a canonical pathname for a file or directory.

** Make the name absolute if it is relative.
** Remove redundant / characters
** Remove all /./ path elements.
** Convert /A/../ to just /


** If the slash parameter is non-zero, the trailing slash, if any,
** is retained.
**
** See also: file_canonical_name_dup()
*/
void file_canonical_name(const char *zOrigName, Blob *pOut, int slash){

  blob_zero(pOut);
  if( file_is_absolute_path(zOrigName) ){








    blob_appendf(pOut, "%/", zOrigName);

  }else{
    char zPwd[2000];
    file_getcwd(zPwd, sizeof(zPwd)-strlen(zOrigName));
    if( zPwd[0]=='/' && strlen(zPwd)==1 ){
      /* when on '/', don't add an extra '/' */
      if( zOrigName[0]=='.' && strlen(zOrigName)==1 ){
        /* '.' when on '/' mean '/' */
        blob_appendf(pOut, "%/", zPwd);
      }else{







>
|
|
|
|
>
>






>


>
>
>
>
>
>
>
>
|
>

<







1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333

1334
1335
1336
1337
1338
1339
1340
  }else{
    return 0;
  }
}

/*
** Compute a canonical pathname for a file or directory.
**
**  *  Make the name absolute if it is relative.
**  *  Remove redundant / characters
**  *  Remove all /./ path elements.
**  *  Convert /A/../ to just /
**  *  On windows, add the drive letter prefix.
**
** If the slash parameter is non-zero, the trailing slash, if any,
** is retained.
**
** See also: file_canonical_name_dup()
*/
void file_canonical_name(const char *zOrigName, Blob *pOut, int slash){
  char zPwd[2000];
  blob_zero(pOut);
  if( file_is_absolute_path(zOrigName) ){
#if defined(_WIN32)
    if( fossil_isdirsep(zOrigName[0]) ){
      /* Add the drive letter to the full pathname */
      file_getcwd(zPwd, sizeof(zPwd)-strlen(zOrigName));
      blob_appendf(pOut, "%.2s%/", zPwd, zOrigName);
    }else
#endif
    {
      blob_appendf(pOut, "%/", zOrigName);
    }
  }else{

    file_getcwd(zPwd, sizeof(zPwd)-strlen(zOrigName));
    if( zPwd[0]=='/' && strlen(zPwd)==1 ){
      /* when on '/', don't add an extra '/' */
      if( zOrigName[0]=='.' && strlen(zOrigName)==1 ){
        /* '.' when on '/' mean '/' */
        blob_appendf(pOut, "%/", zPwd);
      }else{