Bugzilla – Attachment 158 Details for
Bug 420
sftp client support of "ls [flags] [path [localfile]]"feature
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Diff file for sftp-int.c
sftp-int.c.diff (text/plain), 2.96 KB, created by
Calvin Cheng
on 2002-10-22 23:34:13 AEST
(
hide
)
Description:
Diff file for sftp-int.c
Filename:
MIME Type:
Creator:
Calvin Cheng
Created:
2002-10-22 23:34:13 AEST
Size:
2.96 KB
patch
obsolete
>--- sftp-int.c.orig 2002-09-11 20:34:15.000000000 -0400 >+++ sftp-int.c 2002-10-18 16:01:20.000000000 -0400 >@@ -555,13 +555,33 @@ > > /* sftp ls.1 replacement for directories */ > static int >-do_ls_dir(struct sftp_conn *conn, char *path, char *strip_path, int lflag) >+do_ls_dir(struct sftp_conn *conn, char *path, char *strip_path, int lflag, >+ char *localpath) > { > int n; > SFTP_DIRENT **d; >+ FILE *fp = NULL; >+ FILE *fp1 = NULL; >+ >+ if (localpath) { >+ fp = fopen(localpath, "w"); >+ if (!fp) >+ { >+ error("Can't write to file %s", localpath); >+ return -1; >+ } >+ } >+ >+ if (fp) >+ fp1 = fp; >+ else >+ fp1 = stdout; > > if ((n = do_readdir(conn, path, &d)) != 0) >+ { >+ if (fp) fclose(fp); > return (n); >+ } > > /* Count entries for sort */ > for (n = 0; d[n] != NULL; n++) >@@ -583,16 +603,17 @@ > memset(&sb, 0, sizeof(sb)); > attrib_to_stat(&d[n]->a, &sb); > lname = ls_file(fname, &sb, 1); >- printf("%s\n", lname); >+ fprintf(fp1, "%s\n", lname); > xfree(lname); > } else { > /* XXX - multicolumn display would be nice here */ >- printf("%s\n", fname); >+ fprintf(fp1, "%s\n", fname); > } > > xfree(fname); > } > >+ if (fp) fclose(fp); > free_sftp_dirents(d); > return (0); > } >@@ -600,12 +621,14 @@ > /* sftp ls.1 replacement which handles path globs */ > static int > do_globbed_ls(struct sftp_conn *conn, char *path, char *strip_path, >- int lflag) >+ int lflag, char* localpath) > { > glob_t g; > int i; > Attrib *a; > struct stat sb; >+ FILE *fp = NULL; >+ FILE *fp1 = NULL; > > memset(&g, 0, sizeof(g)); > >@@ -628,10 +651,25 @@ > if ((a->flags & SSH2_FILEXFER_ATTR_PERMISSIONS) && > S_ISDIR(a->perm)) { > globfree(&g); >- return (do_ls_dir(conn, path, strip_path, lflag)); >+ return (do_ls_dir(conn, path, strip_path, lflag, localpath)); > } > } > >+ if (localpath) >+ { >+ fp = fopen(localpath, "w"); >+ if (!fp) >+ { >+ error("Can't write to file %s", localpath); >+ return -1; >+ } >+ } >+ >+ if (fp) >+ fp1 = fp; >+ else >+ fp1 = stdout; >+ > for (i = 0; g.gl_pathv[i]; i++) { > char *fname, *lname; > >@@ -650,17 +688,19 @@ > if (a != NULL) > attrib_to_stat(a, &sb); > lname = ls_file(fname, &sb, 1); >- printf("%s\n", lname); >+ fprintf(fp1, "%s\n", lname); > xfree(lname); > } else { > /* XXX - multicolumn display would be nice here */ >- printf("%s\n", fname); >+ fprintf(fp1, "%s\n", fname); > } > xfree(fname); > } > > if (g.gl_pathc) > globfree(&g); >+ if (fp) >+ fclose(fp); > > return (0); > } >@@ -759,6 +799,8 @@ > /* Path is optional */ > if (get_pathname(&cp, path1)) > return(-1); >+ if (get_pathname(&cp, path2)) >+ return(-1); > break; > case I_LLS: > case I_SHELL: >@@ -897,7 +939,7 @@ > break; > case I_LS: > if (!path1) { >- do_globbed_ls(conn, *pwd, *pwd, lflag); >+ do_globbed_ls(conn, *pwd, *pwd, lflag, NULL); > break; > } > >@@ -908,7 +950,7 @@ > > path1 = make_absolute(path1, *pwd); > >- do_globbed_ls(conn, path1, tmp, lflag); >+ do_globbed_ls(conn, path1, tmp, lflag, path2); > break; > case I_LCHDIR: > if (chdir(path1) == -1) {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 420
: 158 |
159