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.

drh 2025-11-25 19:16 trunk
Commit f39852d3713a459e6a5ea3917bd35f6e6ebd3c28fa569671117392ce8111295c
2 files changed +8 -5 +13 -1
+8 -5
--- src/file.c
+++ src/file.c
@@ -2560,11 +2560,11 @@
25602560
** entries, even if the provided glob would match them.
25612561
*/
25622562
int file_directory_list(
25632563
const char *zDir, /* Directory to get a listing of */
25642564
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 */
25662566
int nLimit, /* Find at most this many files. 0 means "all" */
25672567
char ***pazList /* OUT: Write the list here, if not NULL */
25682568
){
25692569
void *zNative;
25702570
DIR *d;
@@ -2577,15 +2577,18 @@
25772577
struct dirent *pEntry;
25782578
n = 0;
25792579
while( (pEntry=readdir(d))!=0 ){
25802580
char *zUtf8 = 0;
25812581
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 */
25852586
|| 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
+ ){
25872590
continue;
25882591
}
25892592
if( zGlob ){
25902593
int rc;
25912594
zUtf8 = fossil_path_to_utf8(pEntry->d_name);
25922595
--- 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 @@
117117
int i;
118118
const char *zPrefix;
119119
switch( file_isdir(zName, ExtFILE) ){
120120
case 1: { /* A directory */
121121
if( (mFlags & LS_DIRONLY)==0 ){
122
+ int omitDots = (mFlags & LS_ALL)!=0 ? 2 : 1;
122123
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);
124125
zPrefix = fossil_strcmp(zName,".") ? zName : 0;
125126
break;
126127
}
127128
}
128129
case 2: { /* A file */
@@ -140,10 +141,21 @@
140141
for(i=0; i<nList; i++){
141142
char *zFile = zPrefix ? mprintf("%s/%s",zPrefix,azList[i]) : azList[i];
142143
int mode = file_mode(zFile, ExtFILE);
143144
sqlite3_int64 sz = file_size(zFile, ExtFILE);
144145
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
145157
sqlite3_bind_text(pStmt, 1, azList[i], -1, SQLITE_TRANSIENT);
146158
sqlite3_bind_int64(pStmt, 2, mtime);
147159
sqlite3_bind_int64(pStmt, 3, sz);
148160
sqlite3_bind_int(pStmt, 4, mode);
149161
sqlite3_bind_int64(pStmt, 5, strlen(zFile));
150162
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button