Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Fix the file_relative_name() function so that it works on windows. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | ben-testing |
| Files: | files | file ages | folders |
| SHA1: |
47b5bf7d166505182d64aa8469be9c4c |
| User & Date: | drh 2011-08-14 23:12:03.828 |
Context
|
2011-08-14
| ||
| 23:14 | Merge the ben-testing branch into trunk. check-in: 9a0c995826 user: drh tags: trunk | |
| 23:12 | Fix the file_relative_name() function so that it works on windows. Closed-Leaf check-in: 47b5bf7d16 user: drh tags: ben-testing | |
| 17:54 | Remove the seperate versionable version of db_get(), which now uses ctrlSettings to determine whether a setting is versionable or not. check-in: 3113f7b18f user: ben tags: ben-testing | |
Changes
Changes to src/file.c.
| ︙ | ︙ | |||
497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 |
if( z[i+2]=='/' || z[i+2]==0 ) return 0;
if( z[i+2]=='.' && (z[i+3]=='/' || z[i+3]==0) ) return 0;
}
}
}
return 1;
}
/*
** Compute a pathname for a file or directory that is relative
** to the current directory.
*/
void file_relative_name(const char *zOrigName, Blob *pOut){
char *zPath;
blob_set(pOut, zOrigName);
blob_resize(pOut, file_simplify_name(blob_buffer(pOut), blob_size(pOut)));
| > > > > > > > > > > > | | > > | > > > > > | > | 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 |
if( z[i+2]=='/' || z[i+2]==0 ) return 0;
if( z[i+2]=='.' && (z[i+3]=='/' || z[i+3]==0) ) return 0;
}
}
}
return 1;
}
/*
** Return a pointer to the first character in a pathname past the
** drive letter. This routine is a no-op on unix.
*/
char *file_without_drive_letter(char *zIn){
#ifdef _WIN32
if( fossil_isalpha(zIn[0]) && zIn[1]==':' ) zIn += 2;
#endif
return zIn;
}
/*
** Compute a pathname for a file or directory that is relative
** to the current directory.
*/
void file_relative_name(const char *zOrigName, Blob *pOut){
char *zPath;
blob_set(pOut, zOrigName);
blob_resize(pOut, file_simplify_name(blob_buffer(pOut), blob_size(pOut)));
zPath = file_without_drive_letter(blob_buffer(pOut));
if( zPath[0]=='/' ){
int i, j;
Blob tmp;
char *zPwd;
char zBuf[2000];
zPwd = zBuf;
file_getcwd(zBuf, sizeof(zBuf)-20);
zPwd = file_without_drive_letter(zBuf);
i = 1;
#ifdef _WIN32
while( zPath[i] && fossil_tolower(zPwd[i])==fossil_tolower(zPath[i]) ) i++;
#else
while( zPath[i] && zPwd[i]==zPath[i] ) i++;
#endif
if( zPath[i]==0 ){
blob_reset(pOut);
if( zPwd[i]==0 ){
blob_append(pOut, ".", 1);
}else{
blob_append(pOut, "..", 2);
for(j=i+1; zPwd[j]; j++){
|
| ︙ | ︙ |