diff options
author | Ryo Nakamura <upa@haeena.net> | 2023-08-03 17:07:39 +0900 |
---|---|---|
committer | Ryo Nakamura <upa@haeena.net> | 2023-08-03 17:07:39 +0900 |
commit | 9f7c135b1515ae297b839f54ea08c1fd16c9521e (patch) | |
tree | 74dc98867f35b76e458939f7846f9fa0c7625eff /src/fileops.h | |
parent | 8ab06c95319d4da360e3ca1c98876902736243b8 (diff) |
cleanup wrappers for file operations
Previously wrapper functions for open(), opendir(), and stat(), etc,
are implemneted in path.h, and now they are in fileops.h and fileops.c.
This commit is a reparation for remote glob.
Diffstat (limited to 'src/fileops.h')
-rw-r--r-- | src/fileops.h | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/fileops.h b/src/fileops.h new file mode 100644 index 0000000..79eb453 --- /dev/null +++ b/src/fileops.h @@ -0,0 +1,47 @@ + +#include <dirent.h> +#include <sys/stat.h> + +#include <ssh.h> + +void set_tls_sftp_session(sftp_session sftp); +/* sftp_session set by set_tls_sftp_session is sued in + mscp_open_wrapped(), mscp_stat_wrapped(), and + mscp_lstat_wrapped(). This _wrapped() functions exist for + sftp_glob() */ + +struct mdir_struct { + DIR *local; + sftp_dir remote; +}; +typedef struct mdir_struct MDIR; + +/* directory operations */ +MDIR *mscp_opendir(const char *path, sftp_session sftp); + +MDIR *mscp_opendir_wrapped(const char *path); +int mscp_closedir(MDIR *md); +struct dirent *mscp_readdir(MDIR *md); + +int mscp_mkdir(const char *path, mode_t mode, sftp_session sftp); + +/* stat operations */ +int mscp_stat(const char *path, struct stat *st, sftp_session sftp); +int mscp_stat_wrapped(const char *path, struct stat *st); + +int mscp_lstat(const char *path, struct stat *st, sftp_session sftp); +int mscp_lstat_wrapped(const char *path, struct stat *st); + + +/* file operations */ + +struct mf_struct { + sftp_file remote; + int local; +}; +typedef struct mf_struct mf; + +mf *mscp_open(const char *path, int flags, mode_t mode, sftp_session sftp); +void mscp_close(mf *f); +int mscp_lseek(mf *f, size_t off); +int mscp_chmod(const char *path, mode_t mode, sftp_session sftp); |