Fossil SCM
Do not show hidden files on Windows with "fossil sys ls" unless the -a option is used. Do show "." and ".." if -a is used.
Commit
f39852d3713a459e6a5ea3917bd35f6e6ebd3c28fa569671117392ce8111295c
Parent
6ae9c9aa5b4e7ef…
2 files changed
+8
-5
+13
-1
+8
-5
| --- src/file.c | ||
| +++ src/file.c | ||
| @@ -2560,11 +2560,11 @@ | ||
| 2560 | 2560 | ** entries, even if the provided glob would match them. |
| 2561 | 2561 | */ |
| 2562 | 2562 | int file_directory_list( |
| 2563 | 2563 | const char *zDir, /* Directory to get a listing of */ |
| 2564 | 2564 | const char *zGlob, /* Only list objects matching this pattern */ |
| 2565 | - int omitDotFiles, /* Omit files that begin with "." if true */ | |
| 2565 | + int omitDotFiles, /* 0: skip "." and "..", 1: no .-files, 2: keep all */ | |
| 2566 | 2566 | int nLimit, /* Find at most this many files. 0 means "all" */ |
| 2567 | 2567 | char ***pazList /* OUT: Write the list here, if not NULL */ |
| 2568 | 2568 | ){ |
| 2569 | 2569 | void *zNative; |
| 2570 | 2570 | DIR *d; |
| @@ -2577,15 +2577,18 @@ | ||
| 2577 | 2577 | struct dirent *pEntry; |
| 2578 | 2578 | n = 0; |
| 2579 | 2579 | while( (pEntry=readdir(d))!=0 ){ |
| 2580 | 2580 | char *zUtf8 = 0; |
| 2581 | 2581 | if( pEntry->d_name[0]==0 ) continue; |
| 2582 | - if( pEntry->d_name[0]=='.' && | |
| 2583 | - (omitDotFiles | |
| 2584 | - /* Skip the special "." and ".." entries. */ | |
| 2582 | + if( pEntry->d_name[0]=='.' | |
| 2583 | + && omitDotFiles<2 | |
| 2584 | + && (omitDotFiles==1 | |
| 2585 | + /* Skip the special "." and ".." entries unless omitDotFiles>=2 */ | |
| 2585 | 2586 | || pEntry->d_name[1]==0 |
| 2586 | - || (pEntry->d_name[1]=='.' && pEntry->d_name[2]==0))){ | |
| 2587 | + || (pEntry->d_name[1]=='.' && pEntry->d_name[2]==0) | |
| 2588 | + ) | |
| 2589 | + ){ | |
| 2587 | 2590 | continue; |
| 2588 | 2591 | } |
| 2589 | 2592 | if( zGlob ){ |
| 2590 | 2593 | int rc; |
| 2591 | 2594 | zUtf8 = fossil_path_to_utf8(pEntry->d_name); |
| 2592 | 2595 |
| --- src/file.c | |
| +++ src/file.c | |
| @@ -2560,11 +2560,11 @@ | |
| 2560 | ** entries, even if the provided glob would match them. |
| 2561 | */ |
| 2562 | int file_directory_list( |
| 2563 | const char *zDir, /* Directory to get a listing of */ |
| 2564 | const char *zGlob, /* Only list objects matching this pattern */ |
| 2565 | int omitDotFiles, /* Omit files that begin with "." if true */ |
| 2566 | int nLimit, /* Find at most this many files. 0 means "all" */ |
| 2567 | char ***pazList /* OUT: Write the list here, if not NULL */ |
| 2568 | ){ |
| 2569 | void *zNative; |
| 2570 | DIR *d; |
| @@ -2577,15 +2577,18 @@ | |
| 2577 | struct dirent *pEntry; |
| 2578 | n = 0; |
| 2579 | while( (pEntry=readdir(d))!=0 ){ |
| 2580 | char *zUtf8 = 0; |
| 2581 | if( pEntry->d_name[0]==0 ) continue; |
| 2582 | if( pEntry->d_name[0]=='.' && |
| 2583 | (omitDotFiles |
| 2584 | /* Skip the special "." and ".." entries. */ |
| 2585 | || pEntry->d_name[1]==0 |
| 2586 | || (pEntry->d_name[1]=='.' && pEntry->d_name[2]==0))){ |
| 2587 | continue; |
| 2588 | } |
| 2589 | if( zGlob ){ |
| 2590 | int rc; |
| 2591 | zUtf8 = fossil_path_to_utf8(pEntry->d_name); |
| 2592 |
| --- src/file.c | |
| +++ src/file.c | |
| @@ -2560,11 +2560,11 @@ | |
| 2560 | ** entries, even if the provided glob would match them. |
| 2561 | */ |
| 2562 | int file_directory_list( |
| 2563 | const char *zDir, /* Directory to get a listing of */ |
| 2564 | const char *zGlob, /* Only list objects matching this pattern */ |
| 2565 | int omitDotFiles, /* 0: skip "." and "..", 1: no .-files, 2: keep all */ |
| 2566 | int nLimit, /* Find at most this many files. 0 means "all" */ |
| 2567 | char ***pazList /* OUT: Write the list here, if not NULL */ |
| 2568 | ){ |
| 2569 | void *zNative; |
| 2570 | DIR *d; |
| @@ -2577,15 +2577,18 @@ | |
| 2577 | struct dirent *pEntry; |
| 2578 | n = 0; |
| 2579 | while( (pEntry=readdir(d))!=0 ){ |
| 2580 | char *zUtf8 = 0; |
| 2581 | if( pEntry->d_name[0]==0 ) continue; |
| 2582 | if( pEntry->d_name[0]=='.' |
| 2583 | && omitDotFiles<2 |
| 2584 | && (omitDotFiles==1 |
| 2585 | /* Skip the special "." and ".." entries unless omitDotFiles>=2 */ |
| 2586 | || pEntry->d_name[1]==0 |
| 2587 | || (pEntry->d_name[1]=='.' && pEntry->d_name[2]==0) |
| 2588 | ) |
| 2589 | ){ |
| 2590 | continue; |
| 2591 | } |
| 2592 | if( zGlob ){ |
| 2593 | int rc; |
| 2594 | zUtf8 = fossil_path_to_utf8(pEntry->d_name); |
| 2595 |
+13
-1
| --- src/xsystem.c | ||
| +++ src/xsystem.c | ||
| @@ -117,12 +117,13 @@ | ||
| 117 | 117 | int i; |
| 118 | 118 | const char *zPrefix; |
| 119 | 119 | switch( file_isdir(zName, ExtFILE) ){ |
| 120 | 120 | case 1: { /* A directory */ |
| 121 | 121 | if( (mFlags & LS_DIRONLY)==0 ){ |
| 122 | + int omitDots = (mFlags & LS_ALL)!=0 ? 2 : 1; | |
| 122 | 123 | azList = 0; |
| 123 | - nList = file_directory_list(zName, 0, (mFlags & LS_ALL)==0, 0, &azList); | |
| 124 | + nList = file_directory_list(zName, 0, omitDots, 0, &azList); | |
| 124 | 125 | zPrefix = fossil_strcmp(zName,".") ? zName : 0; |
| 125 | 126 | break; |
| 126 | 127 | } |
| 127 | 128 | } |
| 128 | 129 | case 2: { /* A file */ |
| @@ -140,10 +141,21 @@ | ||
| 140 | 141 | for(i=0; i<nList; i++){ |
| 141 | 142 | char *zFile = zPrefix ? mprintf("%s/%s",zPrefix,azList[i]) : azList[i]; |
| 142 | 143 | int mode = file_mode(zFile, ExtFILE); |
| 143 | 144 | sqlite3_int64 sz = file_size(zFile, ExtFILE); |
| 144 | 145 | sqlite3_int64 mtime = file_mtime(zFile, ExtFILE); |
| 146 | +#ifdef _WIN32 | |
| 147 | + if( (mFlags & LS_ALL)==0 ){ | |
| 148 | + wchar_t *zMbcs = fossil_utf8_to_path(zFile, 1); | |
| 149 | + DWORD attr = GetFileAttributesW(zMbcs); | |
| 150 | + fossil_path_free(zMbcs); | |
| 151 | + if( attr & FILE_ATTRIBUTE_HIDDEN ){ | |
| 152 | + if( zPrefix ) fossil_free(zFile); | |
| 153 | + continue; | |
| 154 | + } | |
| 155 | + } | |
| 156 | +#endif | |
| 145 | 157 | sqlite3_bind_text(pStmt, 1, azList[i], -1, SQLITE_TRANSIENT); |
| 146 | 158 | sqlite3_bind_int64(pStmt, 2, mtime); |
| 147 | 159 | sqlite3_bind_int64(pStmt, 3, sz); |
| 148 | 160 | sqlite3_bind_int(pStmt, 4, mode); |
| 149 | 161 | sqlite3_bind_int64(pStmt, 5, strlen(zFile)); |
| 150 | 162 |
| --- src/xsystem.c | |
| +++ src/xsystem.c | |
| @@ -117,12 +117,13 @@ | |
| 117 | int i; |
| 118 | const char *zPrefix; |
| 119 | switch( file_isdir(zName, ExtFILE) ){ |
| 120 | case 1: { /* A directory */ |
| 121 | if( (mFlags & LS_DIRONLY)==0 ){ |
| 122 | azList = 0; |
| 123 | nList = file_directory_list(zName, 0, (mFlags & LS_ALL)==0, 0, &azList); |
| 124 | zPrefix = fossil_strcmp(zName,".") ? zName : 0; |
| 125 | break; |
| 126 | } |
| 127 | } |
| 128 | case 2: { /* A file */ |
| @@ -140,10 +141,21 @@ | |
| 140 | for(i=0; i<nList; i++){ |
| 141 | char *zFile = zPrefix ? mprintf("%s/%s",zPrefix,azList[i]) : azList[i]; |
| 142 | int mode = file_mode(zFile, ExtFILE); |
| 143 | sqlite3_int64 sz = file_size(zFile, ExtFILE); |
| 144 | sqlite3_int64 mtime = file_mtime(zFile, ExtFILE); |
| 145 | sqlite3_bind_text(pStmt, 1, azList[i], -1, SQLITE_TRANSIENT); |
| 146 | sqlite3_bind_int64(pStmt, 2, mtime); |
| 147 | sqlite3_bind_int64(pStmt, 3, sz); |
| 148 | sqlite3_bind_int(pStmt, 4, mode); |
| 149 | sqlite3_bind_int64(pStmt, 5, strlen(zFile)); |
| 150 |
| --- src/xsystem.c | |
| +++ src/xsystem.c | |
| @@ -117,12 +117,13 @@ | |
| 117 | int i; |
| 118 | const char *zPrefix; |
| 119 | switch( file_isdir(zName, ExtFILE) ){ |
| 120 | case 1: { /* A directory */ |
| 121 | if( (mFlags & LS_DIRONLY)==0 ){ |
| 122 | int omitDots = (mFlags & LS_ALL)!=0 ? 2 : 1; |
| 123 | azList = 0; |
| 124 | nList = file_directory_list(zName, 0, omitDots, 0, &azList); |
| 125 | zPrefix = fossil_strcmp(zName,".") ? zName : 0; |
| 126 | break; |
| 127 | } |
| 128 | } |
| 129 | case 2: { /* A file */ |
| @@ -140,10 +141,21 @@ | |
| 141 | for(i=0; i<nList; i++){ |
| 142 | char *zFile = zPrefix ? mprintf("%s/%s",zPrefix,azList[i]) : azList[i]; |
| 143 | int mode = file_mode(zFile, ExtFILE); |
| 144 | sqlite3_int64 sz = file_size(zFile, ExtFILE); |
| 145 | sqlite3_int64 mtime = file_mtime(zFile, ExtFILE); |
| 146 | #ifdef _WIN32 |
| 147 | if( (mFlags & LS_ALL)==0 ){ |
| 148 | wchar_t *zMbcs = fossil_utf8_to_path(zFile, 1); |
| 149 | DWORD attr = GetFileAttributesW(zMbcs); |
| 150 | fossil_path_free(zMbcs); |
| 151 | if( attr & FILE_ATTRIBUTE_HIDDEN ){ |
| 152 | if( zPrefix ) fossil_free(zFile); |
| 153 | continue; |
| 154 | } |
| 155 | } |
| 156 | #endif |
| 157 | sqlite3_bind_text(pStmt, 1, azList[i], -1, SQLITE_TRANSIENT); |
| 158 | sqlite3_bind_int64(pStmt, 2, mtime); |
| 159 | sqlite3_bind_int64(pStmt, 3, sz); |
| 160 | sqlite3_bind_int(pStmt, 4, mode); |
| 161 | sqlite3_bind_int64(pStmt, 5, strlen(zFile)); |
| 162 |