Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Add a wrapper around all calls to access() that translates UTF8 to MBCS. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | windows-i18n |
| Files: | files | file ages | folders |
| SHA1: |
850d3df44e03f4c5f1257a6a6bc4d553 |
| User & Date: | drh 2011-05-04 11:13:03.436 |
Context
|
2011-05-04
| ||
| 11:16 | Merge the latest changes from trunk. check-in: 503a0ef555 user: drh tags: windows-i18n | |
| 11:13 | Add a wrapper around all calls to access() that translates UTF8 to MBCS. check-in: 850d3df44e user: drh tags: windows-i18n | |
|
2011-05-03
| ||
| 20:25 | Convert the results of getenv() from MBCS into UTF8. check-in: b7df0b9ce6 user: drh tags: windows-i18n | |
Changes
Changes to src/add.c.
| ︙ | ︙ | |||
213 214 215 216 217 218 219 |
file_canonical_name(g.argv[i], &fullName);
zName = blob_str(&fullName);
isDir = file_isdir(zName);
if( isDir==1 ){
vfile_scan(&fullName, nRoot-1, includeDotFiles, pIgnore);
}else if( isDir==0 ){
fossil_fatal("not found: %s", zName);
| | | 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 |
file_canonical_name(g.argv[i], &fullName);
zName = blob_str(&fullName);
isDir = file_isdir(zName);
if( isDir==1 ){
vfile_scan(&fullName, nRoot-1, includeDotFiles, pIgnore);
}else if( isDir==0 ){
fossil_fatal("not found: %s", zName);
}else if( file_access(zName, R_OK) ){
fossil_fatal("cannot open %s", zName);
}else{
char *zTreeName = &zName[nRoot];
db_multi_exec(
"INSERT OR IGNORE INTO sfile(x)"
" SELECT %Q WHERE NOT EXISTS(SELECT 1 FROM vfile WHERE pathname=%Q)",
zTreeName, zTreeName
|
| ︙ | ︙ |
Changes to src/allrepo.c.
| ︙ | ︙ | |||
127 128 129 130 131 132 133 |
db_prepare(&q,
"SELECT DISTINCT substr(name, 6) COLLATE nocase"
" FROM global_config"
" WHERE substr(name, 1, 5)=='repo:' ORDER BY 1"
);
while( db_step(&q)==SQLITE_ROW ){
const char *zFilename = db_column_text(&q, 0);
| | | 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
db_prepare(&q,
"SELECT DISTINCT substr(name, 6) COLLATE nocase"
" FROM global_config"
" WHERE substr(name, 1, 5)=='repo:' ORDER BY 1"
);
while( db_step(&q)==SQLITE_ROW ){
const char *zFilename = db_column_text(&q, 0);
if( file_access(zFilename, 0) ){
nMissing++;
continue;
}
if( !file_is_canonical(zFilename) ) nMissing++;
if( zCmd[0]=='l' ){
fossil_print("%s\n", zFilename);
continue;
|
| ︙ | ︙ | |||
157 158 159 160 161 162 163 |
** be found, remove those names from the ~/.fossil file.
*/
if( nMissing ){
db_begin_transaction();
db_reset(&q);
while( db_step(&q)==SQLITE_ROW ){
const char *zFilename = db_column_text(&q, 0);
| | | 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
** be found, remove those names from the ~/.fossil file.
*/
if( nMissing ){
db_begin_transaction();
db_reset(&q);
while( db_step(&q)==SQLITE_ROW ){
const char *zFilename = db_column_text(&q, 0);
if( file_access(zFilename, 0) ){
char *zRepo = mprintf("repo:%s", zFilename);
db_unset(zRepo, 1);
free(zRepo);
}else if( !file_is_canonical(zFilename) ){
Blob cname;
char *zRepo = mprintf("repo:%s", zFilename);
db_unset(zRepo, 1);
|
| ︙ | ︙ |
Changes to src/checkin.c.
| ︙ | ︙ | |||
52 53 54 55 56 57 58 |
int isNew = db_column_int(&q,3)==0;
int isRenamed = db_column_int(&q,4);
char *zFullName = mprintf("%s%s", g.zLocalRoot, zPathname);
blob_append(report, zPrefix, nPrefix);
if( isDeleted ){
blob_appendf(report, "DELETED %s\n", zPathname);
}else if( !file_isfile(zFullName) ){
| | | 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
int isNew = db_column_int(&q,3)==0;
int isRenamed = db_column_int(&q,4);
char *zFullName = mprintf("%s%s", g.zLocalRoot, zPathname);
blob_append(report, zPrefix, nPrefix);
if( isDeleted ){
blob_appendf(report, "DELETED %s\n", zPathname);
}else if( !file_isfile(zFullName) ){
if( file_access(zFullName, 0)==0 ){
blob_appendf(report, "NOT_A_FILE %s\n", zPathname);
if( missingIsFatal ){
fossil_warning("not a file: %s", zPathname);
nErr++;
}
}else{
blob_appendf(report, "MISSING %s\n", zPathname);
|
| ︙ | ︙ | |||
180 181 182 183 184 185 186 |
if( isBrief ){
fossil_print("%s\n", zPathname);
}else if( isNew ){
fossil_print("ADDED %s\n", zPathname);
}else if( isDeleted ){
fossil_print("DELETED %s\n", zPathname);
}else if( !file_isfile(zFullName) ){
| | | 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 |
if( isBrief ){
fossil_print("%s\n", zPathname);
}else if( isNew ){
fossil_print("ADDED %s\n", zPathname);
}else if( isDeleted ){
fossil_print("DELETED %s\n", zPathname);
}else if( !file_isfile(zFullName) ){
if( file_access(zFullName, 0)==0 ){
fossil_print("NOT_A_FILE %s\n", zPathname);
}else{
fossil_print("MISSING %s\n", zPathname);
}
}else if( chnged ){
fossil_print("EDITED %s\n", zPathname);
}else if( renamed ){
|
| ︙ | ︙ |
Changes to src/db.c.
| ︙ | ︙ | |||
726 727 728 729 730 731 732 |
** true. If it is not a valid local database file, return 0.
*/
static int isValidLocalDb(const char *zDbName){
i64 lsize;
int rc;
sqlite3_stmt *pStmt;
| | | 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 |
** true. If it is not a valid local database file, return 0.
*/
static int isValidLocalDb(const char *zDbName){
i64 lsize;
int rc;
sqlite3_stmt *pStmt;
if( file_access(zDbName, F_OK) ) return 0;
lsize = file_size(zDbName);
if( lsize%1024!=0 || lsize<4096 ) return 0;
db_open_or_attach(zDbName, "localdb");
g.localOpen = 1;
db_open_config(0);
db_open_repository(0);
|
| ︙ | ︙ | |||
801 802 803 804 805 806 807 |
db_err("pwd too big: max %d", sizeof(zPwd)-20);
}
n = strlen(zPwd);
zPwdConv = mprintf("%/", zPwd);
strncpy(zPwd, zPwdConv, 2000-20);
free(zPwdConv);
while( n>0 ){
| | | 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 |
db_err("pwd too big: max %d", sizeof(zPwd)-20);
}
n = strlen(zPwd);
zPwdConv = mprintf("%/", zPwd);
strncpy(zPwd, zPwdConv, 2000-20);
free(zPwdConv);
while( n>0 ){
if( file_access(zPwd, W_OK) ) break;
for(i=0; i<sizeof(aDbName)/sizeof(aDbName[0]); i++){
sqlite3_snprintf(sizeof(zPwd)-n, &zPwd[n], "%s", aDbName[i]);
if( isValidLocalDb(zPwd) ){
/* Found a valid checkout database file */
zPwd[n] = 0;
while( n>1 && zPwd[n-1]=='/' ){
n--;
|
| ︙ | ︙ | |||
839 840 841 842 843 844 845 |
if( g.localOpen ){
zDbName = db_lget("repository", 0);
}
if( zDbName==0 ){
db_err("unable to find the name of a repository database");
}
}
| | | | | 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 |
if( g.localOpen ){
zDbName = db_lget("repository", 0);
}
if( zDbName==0 ){
db_err("unable to find the name of a repository database");
}
}
if( file_access(zDbName, R_OK) || file_size(zDbName)<1024 ){
if( file_access(zDbName, 0) ){
fossil_panic("repository does not exist or"
" is in an unreadable directory: %s", zDbName);
}else if( file_access(zDbName, R_OK) ){
fossil_panic("read permission denied for repository %s", zDbName);
}else{
fossil_panic("not a valid repository: %s", zDbName);
}
}
db_open_or_attach(zDbName, "repository");
g.repositoryOpen = 1;
|
| ︙ | ︙ | |||
950 951 952 953 954 955 956 |
}
if( db_open_local()==0 ){
fossil_fatal("not in a local checkout");
return;
}
file_canonical_name(g.argv[2], &repo);
zRepo = blob_str(&repo);
| | | 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 |
}
if( db_open_local()==0 ){
fossil_fatal("not in a local checkout");
return;
}
file_canonical_name(g.argv[2], &repo);
zRepo = blob_str(&repo);
if( file_access(zRepo, 0) ){
fossil_fatal("no such file: %s", zRepo);
}
db_open_or_attach(zRepo, "test_repo");
db_lset("repository", blob_str(&repo));
db_close(1);
}
|
| ︙ | ︙ |
Changes to src/diffcmd.c.
| ︙ | ︙ | |||
98 99 100 101 102 103 104 |
/* Construct a temporary file to hold pFile1 based on the name of
** zFile2 */
blob_zero(&nameFile1);
do{
blob_reset(&nameFile1);
blob_appendf(&nameFile1, "%s~%d", zFile2, cnt++);
| | | 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
/* Construct a temporary file to hold pFile1 based on the name of
** zFile2 */
blob_zero(&nameFile1);
do{
blob_reset(&nameFile1);
blob_appendf(&nameFile1, "%s~%d", zFile2, cnt++);
}while( file_access(blob_str(&nameFile1),0)==0 );
blob_write_to_file(pFile1, blob_str(&nameFile1));
/* Construct the external diff command */
blob_zero(&cmd);
blob_appendf(&cmd, "%s ", zDiffCmd);
shell_escape(&cmd, blob_str(&nameFile1));
blob_append(&cmd, " ", 1);
|
| ︙ | ︙ | |||
261 262 263 264 265 266 267 |
int srcid = db_column_int(&q, 4);
char *zFullName = mprintf("%s%s", g.zLocalRoot, zPathname);
char *zToFree = zFullName;
int showDiff = 1;
if( isDeleted ){
diff_printf("DELETED %s\n", zPathname);
if( !asNewFile ){ showDiff = 0; zFullName = "/dev/null"; }
| | | 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 |
int srcid = db_column_int(&q, 4);
char *zFullName = mprintf("%s%s", g.zLocalRoot, zPathname);
char *zToFree = zFullName;
int showDiff = 1;
if( isDeleted ){
diff_printf("DELETED %s\n", zPathname);
if( !asNewFile ){ showDiff = 0; zFullName = "/dev/null"; }
}else if( file_access(zFullName, 0) ){
diff_printf("MISSING %s\n", zPathname);
if( !asNewFile ){ showDiff = 0; }
}else if( isNew ){
diff_printf("ADDED %s\n", zPathname);
srcid = 0;
if( !asNewFile ){ showDiff = 0; }
}else if( isChnged==3 ){
|
| ︙ | ︙ |
Changes to src/file.c.
| ︙ | ︙ | |||
120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
rc = getStat(zFN);
free(zFN);
}else{
rc = getStat(0);
}
return rc ? 0 : (S_ISDIR(fileStat.st_mode) ? 1 : 2);
}
/*
** Find an unused filename similar to zBase with zSuffix appended.
**
** Make the name relative to the working directory if relFlag is true.
**
** Space to hold the new filename is obtained form mprintf() and should
| > > > > > > > > > > | 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
rc = getStat(zFN);
free(zFN);
}else{
rc = getStat(0);
}
return rc ? 0 : (S_ISDIR(fileStat.st_mode) ? 1 : 2);
}
/*
** Wrapper around the access() system call.
*/
int file_access(const char *zFilename, int flags){
char *zMbcs = fossil_utf8_to_mbcs(zFilename);
int rc = access(zMbcs, flags);
fossil_mbcs_free(zMbcs);
return rc;
}
/*
** Find an unused filename similar to zBase with zSuffix appended.
**
** Make the name relative to the working directory if relFlag is true.
**
** Space to hold the new filename is obtained form mprintf() and should
|
| ︙ | ︙ |
Changes to src/main.c.
| ︙ | ︙ | |||
1330 1331 1332 1333 1334 1335 1336 |
char *zFull;
int i;
int bExists;
while( zPath && zPath[0] ){
while( zPath[0]==':' ) zPath++;
for(i=0; zPath[i] && zPath[i]!=':'; i++){}
zFull = mprintf("%.*s/%s", i, zPath, zBinary);
| | | 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 |
char *zFull;
int i;
int bExists;
while( zPath && zPath[0] ){
while( zPath[0]==':' ) zPath++;
for(i=0; zPath[i] && zPath[i]!=':'; i++){}
zFull = mprintf("%.*s/%s", i, zPath, zBinary);
bExists = file_access(zFull, X_OK);
free(zFull);
if( bExists==0 ) return 1;
zPath += i;
}
return 0;
}
#endif
|
| ︙ | ︙ |
Changes to src/rebuild.c.
| ︙ | ︙ | |||
909 910 911 912 913 914 915 |
if( zPrefixOpt[0]>='0' && zPrefixOpt[0]<='9' && !zPrefixOpt[1] ){
prefixLength = (int)(*zPrefixOpt-'0');
}else{
fossil_fatal("N(%s) is not a a valid prefix length!",zPrefixOpt);
}
}
#ifndef _WIN32
| | | 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 |
if( zPrefixOpt[0]>='0' && zPrefixOpt[0]<='9' && !zPrefixOpt[1] ){
prefixLength = (int)(*zPrefixOpt-'0');
}else{
fossil_fatal("N(%s) is not a a valid prefix length!",zPrefixOpt);
}
}
#ifndef _WIN32
if( file_access(zDestDir, W_OK) ){
fossil_fatal("DESTINATION(%s) is not writeable!",zDestDir);
}
#else
/* write access on windows is not checked, errors will be
** dected on blob_write_to_file
*/
#endif
|
| ︙ | ︙ |