mirror of
https://github.com/PowerShell/Win32-OpenSSH.git
synced 2025-07-24 14:35:35 +02:00
SFTP issues.
This commit is contained in:
parent
9291dde274
commit
b7d80edae3
@ -559,13 +559,13 @@ fileio_fstat(struct w32_io* pio, struct _stat64 *buf) {
|
|||||||
|
|
||||||
int
|
int
|
||||||
fileio_stat(const char *path, struct _stat64 *buf) {
|
fileio_stat(const char *path, struct _stat64 *buf) {
|
||||||
wchar_t wpath[MAX_PATH];
|
wchar_t* wpath[MAX_PATH];
|
||||||
|
wchar_t* wtmp = NULL;
|
||||||
|
|
||||||
if (MultiByteToWideChar(CP_UTF8, 0, path, -1, wpath, MAX_PATH) == 0) {
|
if ((wtmp = utf8_to_utf16(path)) == NULL)
|
||||||
errno = EFAULT;
|
fatal("failed to covert input arguments");
|
||||||
debug("WideCharToMultiByte failed - ERROR:%d", GetLastError());
|
strcpy(wpath, wtmp);
|
||||||
return GetLastError();
|
free(wtmp);
|
||||||
}
|
|
||||||
|
|
||||||
return _wstat64(wpath, buf);
|
return _wstat64(wpath, buf);
|
||||||
}
|
}
|
||||||
|
@ -438,13 +438,10 @@ int w32_chdir(const char *dirname_utf8) {
|
|||||||
|
|
||||||
char *w32_getcwd(char *buffer, int maxlen) {
|
char *w32_getcwd(char *buffer, int maxlen) {
|
||||||
wchar_t wdirname[MAX_PATH];
|
wchar_t wdirname[MAX_PATH];
|
||||||
int needed;
|
|
||||||
|
|
||||||
wchar_t *wpwd = _wgetcwd(wdirname, MAX_PATH);
|
wchar_t *wpwd = _wgetcwd(wdirname, MAX_PATH);
|
||||||
|
|
||||||
if ((needed = WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, wdirname, -1, NULL, 0, NULL, NULL)) == 0 ||
|
if (buffer = utf16_to_utf8(wpwd))
|
||||||
(needed > MAX_PATH) ||
|
|
||||||
(WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, wdirname, -1, buffer, needed, NULL, NULL) != needed))
|
|
||||||
fatal("failed to convert input arguments");
|
fatal("failed to convert input arguments");
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
|
46
sftp.c
46
sftp.c
@ -76,6 +76,7 @@ typedef void EditLine;
|
|||||||
|
|
||||||
#ifdef WIN32_VS
|
#ifdef WIN32_VS
|
||||||
#include "win32_dirent.h"
|
#include "win32_dirent.h"
|
||||||
|
extern int ScreenX;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* File to read commands from */
|
/* File to read commands from */
|
||||||
@ -816,7 +817,8 @@ do_ls_dir(struct sftp_conn *conn, char *path, char *strip_path, int lflag)
|
|||||||
m += strlen(tmp);
|
m += strlen(tmp);
|
||||||
free(tmp);
|
free(tmp);
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
width = ConSetScreenX();
|
ConSetScreenX();
|
||||||
|
width = ScreenX ;
|
||||||
#else
|
#else
|
||||||
if (ioctl(fileno(stdin), TIOCGWINSZ, &ws) != -1)
|
if (ioctl(fileno(stdin), TIOCGWINSZ, &ws) != -1)
|
||||||
width = ws.ws_col;
|
width = ws.ws_col;
|
||||||
@ -853,12 +855,33 @@ do_ls_dir(struct sftp_conn *conn, char *path, char *strip_path, int lflag)
|
|||||||
attrib_to_stat(&d[n]->a, &sb);
|
attrib_to_stat(&d[n]->a, &sb);
|
||||||
lname = ls_file(fname, &sb, 1,
|
lname = ls_file(fname, &sb, 1,
|
||||||
(lflag & LS_SI_UNITS));
|
(lflag & LS_SI_UNITS));
|
||||||
printf("%s\n", lname);
|
#ifdef WINDOWS
|
||||||
|
wchar_t* wtmp = utf8_to_utf16(lname);
|
||||||
|
wprintf_s(L"%ls\n", wtmp);
|
||||||
|
free(tmp);
|
||||||
|
#else
|
||||||
|
printf("%s\n", lname);
|
||||||
|
#endif
|
||||||
free(lname);
|
free(lname);
|
||||||
} else
|
}
|
||||||
printf("%s\n", d[n]->longname);
|
else {
|
||||||
} else {
|
#ifdef WINDOWS
|
||||||
printf("%-*s", colspace, fname);
|
wchar_t* wtmp = utf8_to_utf16(d[n]->longname);
|
||||||
|
wprintf_s(L"%ls\n", wtmp);
|
||||||
|
free(wtmp);
|
||||||
|
#else
|
||||||
|
printf("%s\n", d[n]->longname);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
#ifdef WINDOWS
|
||||||
|
wchar_t* wtmp = utf8_to_utf16(fname);
|
||||||
|
wprintf_s(L"%-*ls", colspace, wtmp);
|
||||||
|
free(wtmp);
|
||||||
|
#else
|
||||||
|
printf("%-*s", colspace, fname);
|
||||||
|
#endif
|
||||||
if (c >= columns) {
|
if (c >= columns) {
|
||||||
printf("\n");
|
printf("\n");
|
||||||
c = 1;
|
c = 1;
|
||||||
@ -918,7 +941,8 @@ do_globbed_ls(struct sftp_conn *conn, char *path, char *strip_path,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
width = ConSetScreenX();
|
ConSetScreenX();
|
||||||
|
width = ScreenX;
|
||||||
#else
|
#else
|
||||||
if (ioctl(fileno(stdin), TIOCGWINSZ, &ws) != -1)
|
if (ioctl(fileno(stdin), TIOCGWINSZ, &ws) != -1)
|
||||||
width = ws.ws_col;
|
width = ws.ws_col;
|
||||||
@ -2128,11 +2152,11 @@ interactive_loop(struct sftp_conn *conn, char *file1, char *file2)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int needed;
|
char *pcmd = NULL;
|
||||||
if ((needed = WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, wcmd, -1, NULL, 0, NULL, NULL)) == 0 ||
|
if ((pcmd = utf16_to_utf8(wcmd)) == NULL)
|
||||||
(needed > MAX_COMMAND_LINE) ||
|
|
||||||
(WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, wcmd, -1, cmd, needed, NULL, NULL) != needed))
|
|
||||||
fatal("failed to convert input arguments");
|
fatal("failed to convert input arguments");
|
||||||
|
strcpy(cmd, pcmd);
|
||||||
|
free(pcmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -73,6 +73,7 @@ struct dirent *readdir(void *avp)
|
|||||||
struct dirent *pdirentry;
|
struct dirent *pdirentry;
|
||||||
struct _wfinddata_t c_file;
|
struct _wfinddata_t c_file;
|
||||||
DIR *dirp = (DIR *)avp;
|
DIR *dirp = (DIR *)avp;
|
||||||
|
char *tmp = NULL;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if ( _wfindnext( dirp->hFile, &c_file ) == 0 ) {
|
if ( _wfindnext( dirp->hFile, &c_file ) == 0 ) {
|
||||||
@ -82,10 +83,11 @@ struct dirent *readdir(void *avp)
|
|||||||
}
|
}
|
||||||
pdirentry = (struct dirent *) malloc( sizeof(struct dirent) );
|
pdirentry = (struct dirent *) malloc( sizeof(struct dirent) );
|
||||||
|
|
||||||
if ((needed = WideCharToMultiByte(CP_UTF8, 0, c_file.name, -1, NULL, 0, NULL, NULL)) == 0 ||
|
if ((tmp = utf16_to_utf8(pdirentry->d_name)) == NULL)
|
||||||
(pdirentry->d_name = malloc(needed)) == NULL ||
|
|
||||||
WideCharToMultiByte(CP_UTF8, 0, c_file.name, -1, pdirentry->d_name, needed, NULL, NULL) != needed)
|
|
||||||
fatal("failed to covert input arguments");
|
fatal("failed to covert input arguments");
|
||||||
|
strcpy(c_file.name[0], tmp);
|
||||||
|
free(tmp);
|
||||||
|
tmp = NULL;
|
||||||
|
|
||||||
pdirentry->d_ino = 1; // a fictious one like UNIX to say it is nonzero
|
pdirentry->d_ino = 1; // a fictious one like UNIX to say it is nonzero
|
||||||
return pdirentry ;
|
return pdirentry ;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user