Fossil

Diff
Login

Differences From Artifact [467ee5d527]:

To Artifact [609b7e8d28]:


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{