summaryrefslogtreecommitdiff
path: root/sftp.c
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@zip.com.au>2004-06-22 13:09:55 +1000
committerDarren Tucker <dtucker@zip.com.au>2004-06-22 13:09:55 +1000
commit9a526455669748a5ba87bc39ac9572f89dcfb29e (patch)
tree5ce9228f3547c4b1263ac3689cef25f9628a34ad /sftp.c
parent15ca6e88426b1b0919151e23268163d93c81e8a0 (diff)
- djm@cvs.openbsd.org 2004/06/22 01:16:39
[sftp.c] don't show .files by default in ls, add -a option to turn them back on; ok markus
Diffstat (limited to 'sftp.c')
-rw-r--r--sftp.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/sftp.c b/sftp.c
index 37adb0286..6639672ca 100644
--- a/sftp.c
+++ b/sftp.c
@@ -16,7 +16,7 @@
16 16
17#include "includes.h" 17#include "includes.h"
18 18
19RCSID("$OpenBSD: sftp.c,v 1.53 2004/06/21 22:30:45 djm Exp $"); 19RCSID("$OpenBSD: sftp.c,v 1.54 2004/06/22 01:16:39 djm Exp $");
20 20
21#include "buffer.h" 21#include "buffer.h"
22#include "xmalloc.h" 22#include "xmalloc.h"
@@ -72,6 +72,7 @@ char *__progname;
72#define LS_TIME_SORT 0x10 /* Sort by mtime */ 72#define LS_TIME_SORT 0x10 /* Sort by mtime */
73#define LS_SIZE_SORT 0x20 /* Sort by file size */ 73#define LS_SIZE_SORT 0x20 /* Sort by file size */
74#define LS_REVERSE_SORT 0x40 /* Reverse sort order */ 74#define LS_REVERSE_SORT 0x40 /* Reverse sort order */
75#define LS_SHOW_ALL 0x80 /* Don't skip filenames starting with '.' */
75 76
76#define VIEW_FLAGS (LS_LONG_VIEW|LS_SHORT_VIEW|LS_NUMERIC_VIEW) 77#define VIEW_FLAGS (LS_LONG_VIEW|LS_SHORT_VIEW|LS_NUMERIC_VIEW)
77#define SORT_FLAGS (LS_NAME_SORT|LS_TIME_SORT|LS_SIZE_SORT) 78#define SORT_FLAGS (LS_NAME_SORT|LS_TIME_SORT|LS_SIZE_SORT)
@@ -378,6 +379,9 @@ parse_ls_flags(const char **cpp, int *lflag)
378 case 'f': 379 case 'f':
379 *lflag &= ~SORT_FLAGS; 380 *lflag &= ~SORT_FLAGS;
380 break; 381 break;
382 case 'a':
383 *lflag |= LS_SHOW_ALL;
384 break;
381 default: 385 default:
382 error("Invalid flag -%c", *cp); 386 error("Invalid flag -%c", *cp);
383 return(-1); 387 return(-1);
@@ -666,8 +670,10 @@ do_ls_dir(struct sftp_conn *conn, char *path, char *strip_path, int lflag)
666 char *tmp; 670 char *tmp;
667 671
668 /* Count entries for sort and find longest filename */ 672 /* Count entries for sort and find longest filename */
669 for (n = 0; d[n] != NULL; n++) 673 for (n = 0; d[n] != NULL; n++) {
670 m = MAX(m, strlen(d[n]->filename)); 674 if (d[n]->filename[0] != '.' || (lflag & LS_SHOW_ALL))
675 m = MAX(m, strlen(d[n]->filename));
676 }
671 677
672 /* Add any subpath that also needs to be counted */ 678 /* Add any subpath that also needs to be counted */
673 tmp = path_strip(path, strip_path); 679 tmp = path_strip(path, strip_path);
@@ -691,6 +697,9 @@ do_ls_dir(struct sftp_conn *conn, char *path, char *strip_path, int lflag)
691 for (n = 0; d[n] != NULL && !interrupted; n++) { 697 for (n = 0; d[n] != NULL && !interrupted; n++) {
692 char *tmp, *fname; 698 char *tmp, *fname;
693 699
700 if (d[n]->filename[0] == '.' && !(lflag & LS_SHOW_ALL))
701 continue;
702
694 tmp = path_append(path, d[n]->filename); 703 tmp = path_append(path, d[n]->filename);
695 fname = path_strip(tmp, strip_path); 704 fname = path_strip(tmp, strip_path);
696 xfree(tmp); 705 xfree(tmp);