mirror of https://github.com/MidnightCommander/mc
* xdirentry.h (vfs_s_fh.u.ftp): Add append field.
(vfs_s_data.file_store): Change second argument to (vfs_s_fh *fh). * direntry.c (vfs_s_close): Adjust. * fish.c (file_store): Likewise. * ftpfs.c (file_store): Likewise. Use "APPE" if fh->u.ftp.append is true. (linear_start): Care about fh->u.ftp.append. (ftpfs_fh_open): Likewise.
This commit is contained in:
parent
4035b37feb
commit
a60f38583a
|
@ -5,6 +5,16 @@
|
|||
|
||||
2002-05-22 Andrew V. Samoilov <kai@cmail.ru>
|
||||
|
||||
* xdirentry.h (vfs_s_fh.u.ftp): Add append field.
|
||||
(vfs_s_data.file_store): Change second argument
|
||||
to (vfs_s_fh *fh).
|
||||
* direntry.c (vfs_s_close): Adjust.
|
||||
* fish.c (file_store): Likewise.
|
||||
* ftpfs.c (file_store): Likewise. Use "APPE" if
|
||||
fh->u.ftp.append is true.
|
||||
(linear_start): Care about fh->u.ftp.append.
|
||||
(ftpfs_fh_open): Likewise.
|
||||
|
||||
* fish.c (fish_fh_open): Generate fh->ino->localname
|
||||
if this one is NULL and file is opened for writting only.
|
||||
* ftpfs.c (ftpfs_fh_open): Likewise if control_connection_buzy
|
||||
|
|
|
@ -915,7 +915,7 @@ vfs_s_close (void *fh)
|
|||
if (!s)
|
||||
res = -1;
|
||||
else {
|
||||
res = MEDATA->file_store (me, FH_SUPER, s, FH->ino->localname);
|
||||
res = MEDATA->file_store (me, fh, s, FH->ino->localname);
|
||||
g_free (s);
|
||||
}
|
||||
vfs_s_invalidate (me, FH_SUPER);
|
||||
|
|
|
@ -467,8 +467,9 @@ error:
|
|||
}
|
||||
|
||||
static int
|
||||
file_store(vfs *me, vfs_s_super *super, char *name, char *localname)
|
||||
file_store(vfs *me, vfs_s_fh *fh, char *name, char *localname)
|
||||
{
|
||||
vfs_s_super *super = FH_SUPER;
|
||||
int n, total;
|
||||
char buffer[8192];
|
||||
struct stat s;
|
||||
|
|
10
vfs/ftpfs.c
10
vfs/ftpfs.c
|
@ -1360,7 +1360,7 @@ fallback:
|
|||
}
|
||||
|
||||
static int
|
||||
file_store(vfs *me, vfs_s_super *super, char *name, char *localname)
|
||||
file_store(vfs *me, vfs_s_fh *fh, char *name, char *localname)
|
||||
{
|
||||
int h, sock, n;
|
||||
off_t total;
|
||||
|
@ -1371,12 +1371,13 @@ file_store(vfs *me, vfs_s_super *super, char *name, char *localname)
|
|||
#endif
|
||||
char buffer[8192];
|
||||
struct stat s;
|
||||
vfs_s_super *super = FH_SUPER;
|
||||
|
||||
h = open(localname, O_RDONLY);
|
||||
if (h == -1)
|
||||
ERRNOR (EIO, -1);
|
||||
fstat(h, &s);
|
||||
sock = open_data_connection(me, super, "STOR", name, TYPE_BINARY, 0);
|
||||
sock = open_data_connection(me, super, fh->u.ftp.append ? "APPE" : "STOR", name, TYPE_BINARY, 0);
|
||||
if (sock < 0) {
|
||||
close(h);
|
||||
return -1;
|
||||
|
@ -1436,7 +1437,7 @@ error_return:
|
|||
return -1;
|
||||
}
|
||||
|
||||
#define FH_SOCK fh->u.ftp.sock
|
||||
//#define FH_SOCK fh->u.ftp.sock
|
||||
|
||||
static int
|
||||
linear_start(vfs *me, vfs_s_fh *fh, int offset)
|
||||
|
@ -1451,6 +1452,7 @@ linear_start(vfs *me, vfs_s_fh *fh, int offset)
|
|||
ERRNOR (EACCES, 0);
|
||||
fh->linear = LS_LINEAR_OPEN;
|
||||
FH_SUPER->u.ftp.control_connection_buzy = 1;
|
||||
fh->u.ftp.append = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -1688,6 +1690,7 @@ static void my_forget (char *file)
|
|||
|
||||
static int ftpfs_fh_open (vfs *me, vfs_s_fh *fh, int flags, int mode)
|
||||
{
|
||||
fh->u.ftp.append = 0;
|
||||
/* File will be written only, so no need to retrieve it from ftp server */
|
||||
if (((flags & O_WRONLY) == O_WRONLY) && !(flags & (O_RDONLY|O_RDWR))){
|
||||
#ifdef HAVE_STRUCT_LINGER
|
||||
|
@ -1707,6 +1710,7 @@ static int ftpfs_fh_open (vfs *me, vfs_s_fh *fh, int flags, int mode)
|
|||
if (handle == -1)
|
||||
return -1;
|
||||
close (handle);
|
||||
fh->u.ftp.append = flags & O_APPEND;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -141,7 +141,7 @@ typedef struct vfs_s_fh {
|
|||
int got, total;
|
||||
} fish;
|
||||
struct {
|
||||
int sock;
|
||||
int sock, append;
|
||||
} ftp;
|
||||
} u;
|
||||
int magic;
|
||||
|
@ -169,7 +169,7 @@ struct vfs_s_data {
|
|||
vfs_s_entry* (*find_entry) (vfs *me, vfs_s_inode *root, char *path, int follow, int flags);
|
||||
int (*dir_load) (vfs *me, vfs_s_inode *ino, char *path);
|
||||
int (*dir_uptodate) (vfs *me, vfs_s_inode *ino);
|
||||
int (*file_store) (vfs *me, vfs_s_super *super, char *path, char *localname);
|
||||
int (*file_store) (vfs *me, vfs_s_fh *fh, char *path, char *localname);
|
||||
|
||||
int (*linear_start) (vfs *me, vfs_s_fh *fh, int from);
|
||||
int (*linear_read) (vfs *me, vfs_s_fh *fh, void *buf, int len);
|
||||
|
|
Loading…
Reference in New Issue