Functions | |
| int | sftp_async_read (SFTP_FILE *file, void *data, u32 len, u32 id) |
| Wait for an asynchronous read to complete and save the data. | |
| int | sftp_async_read_begin (SFTP_FILE *file, u32 len) |
| Start an asynchronous read from a file using an opened sftp file handle. | |
| void | sftp_attributes_free (SFTP_ATTRIBUTES *file) |
| Free a sftp attribute structure. | |
| char * | sftp_canonicalize_path (SFTP_SESSION *sftp, const char *path) |
| Canonicalize a sftp path. | |
| int | sftp_chmod (SFTP_SESSION *sftp, const char *file, mode_t mode) |
| Change permissions of a file. | |
| int | sftp_chown (SFTP_SESSION *sftp, const char *file, uid_t owner, gid_t group) |
| Change the file owner and group. | |
| int | sftp_close (SFTP_FILE *file) |
| Close an open file handle. | |
| int | sftp_closedir (SFTP_DIR *dir) |
| Close a directory handle opened by sftp_opendir(). | |
| int | sftp_dir_close (SFTP_DIR *dir) SFTP_DEPRECATED |
| int | sftp_dir_eof (SFTP_DIR *dir) |
| Tell if the directory has reached EOF (End Of File). | |
| int | sftp_file_close (SFTP_FILE *file) SFTP_DEPRECATED |
| void | sftp_free (SFTP_SESSION *sftp) |
| Close and deallocate a sftp session. | |
| SFTP_ATTRIBUTES * | sftp_fstat (SFTP_FILE *file) |
| Get information about a file or directory from a file handle. | |
| int | sftp_get_error (SFTP_SESSION *sftp) |
| Get the last sftp error. | |
| int | sftp_init (SFTP_SESSION *sftp) |
| Initialize the sftp session with the server. | |
| SFTP_ATTRIBUTES * | sftp_lstat (SFTP_SESSION *session, const char *path) |
| Get information about a file or directory. | |
| int | sftp_mkdir (SFTP_SESSION *sftp, const char *directory, mode_t mode) |
| Create a directory. | |
| SFTP_SESSION * | sftp_new (SSH_SESSION *session) |
| Start a new sftp session. | |
| SFTP_FILE * | sftp_open (SFTP_SESSION *session, const char *file, int flags, mode_t mode) |
| Open a file on the server. | |
| SFTP_DIR * | sftp_opendir (SFTP_SESSION *session, const char *path) |
| Open a directory used to obtain directory entries. | |
| ssize_t | sftp_read (SFTP_FILE *file, void *buf, size_t count) |
| Read from a file using an opened sftp file handle. | |
| SFTP_ATTRIBUTES * | sftp_readdir (SFTP_SESSION *session, SFTP_DIR *dir) |
| Get a single file attributes structure of a directory. | |
| char * | sftp_readlink (SFTP_SESSION *sftp, const char *path) |
| Read the value of a symbolic link. | |
| int | sftp_rename (SFTP_SESSION *sftp, const char *original, const char *newname) |
| Rename or move a file or directory. | |
| void | sftp_rewind (SFTP_FILE *file) |
| Rewinds the position of the file pointer to the beginning of the file. | |
| int | sftp_rm (SFTP_SESSION *sftp, const char *file) SFTP_DEPRECATED |
| int | sftp_rmdir (SFTP_SESSION *sftp, const char *directory) |
| Remove a directoy. | |
| int | sftp_seek (SFTP_FILE *file, u32 new_offset) |
| Seek to a specific location in a file. | |
| int | sftp_seek64 (SFTP_FILE *file, u64 new_offset) |
| Seek to a specific location in a file. | |
| int | sftp_server_version (SFTP_SESSION *sftp) |
| Get the version of the SFTP protocol supported by the server. | |
| int | sftp_setstat (SFTP_SESSION *sftp, const char *file, SFTP_ATTRIBUTES *attr) |
| Set file attributes on a file, directory or symbolic link. | |
| SFTP_ATTRIBUTES * | sftp_stat (SFTP_SESSION *session, const char *path) |
| Get information about a file or directory. | |
| int | sftp_symlink (SFTP_SESSION *sftp, const char *target, const char *dest) |
| Create a symbolic link. | |
| unsigned long | sftp_tell (SFTP_FILE *file) |
| Report current byte position in file. | |
| u64 | sftp_tell64 (SFTP_FILE *file) |
| Report current byte position in file. | |
| int | sftp_unlink (SFTP_SESSION *sftp, const char *file) |
| Unlink (delete) a file. | |
| int | sftp_utimes (SFTP_SESSION *sftp, const char *file, const struct timeval *times) |
| Change the last modification and access time of a file. | |
| ssize_t | sftp_write (SFTP_FILE *file, const void *buf, size_t count) |
| Write to a file using an opened sftp file handle. | |
| int sftp_async_read | ( | SFTP_FILE * | file, | |
| void * | data, | |||
| u32 | len, | |||
| u32 | id | |||
| ) |
Wait for an asynchronous read to complete and save the data.
| file | The opened sftp file handle to be read from. | |
| data | Pointer to buffer to recieve read data. | |
| len | Size of the buffer in bytes. It should be bigger or equal to the length parameter of the sftp_async_read_begin() call. | |
| id | The identifier returned by the sftp_async_read_begin() function. |
| int sftp_async_read_begin | ( | SFTP_FILE * | file, | |
| u32 | len | |||
| ) |
Start an asynchronous read from a file using an opened sftp file handle.
Its goal is to avoid the slowdowns related to the request/response pattern of a synchronous read. To do so, you must call 2 functions:
sftp_async_read_begin() and sftp_async_read().
The first step is to call sftp_async_read_begin(). This function returns a request identifier. The second step is to call sftp_async_read() using the returned identifier.
| file | The opened sftp file handle to be read from. | |
| len | Size to read in bytes. |
A call to sftp_async_read_begin() sends a request to the server. When the server answers, libssh allocates memory to store it until sftp_async_read() is called. Not calling sftp_async_read() will lead to memory leaks.
| void sftp_attributes_free | ( | SFTP_ATTRIBUTES * | file | ) |
Free a sftp attribute structure.
| file | The sftp attribute structure to free. |
| char* sftp_canonicalize_path | ( | SFTP_SESSION * | sftp, | |
| const char * | path | |||
| ) |
Canonicalize a sftp path.
| sftp | The sftp session handle. | |
| path | The path to be canonicalized. |
| int sftp_chmod | ( | SFTP_SESSION * | sftp, | |
| const char * | file, | |||
| mode_t | mode | |||
| ) |
Change permissions of a file.
| sftp | The sftp session handle. | |
| file | The file which owner and group should be changed. | |
| mode | Specifies the permissions to use. It is modified by the process's umask in the usual way: The permissions of the created file are (mode & ~umask) |
| int sftp_chown | ( | SFTP_SESSION * | sftp, | |
| const char * | file, | |||
| uid_t | owner, | |||
| gid_t | group | |||
| ) |
Change the file owner and group.
| sftp | The sftp session handle. | |
| file | The file which owner and group should be changed. | |
| owner | The new owner which should be set. | |
| group | The new group which should be set. |
| int sftp_close | ( | SFTP_FILE * | file | ) |
Close an open file handle.
| file | The open sftp file handle to close. |
| int sftp_closedir | ( | SFTP_DIR * | dir | ) |
Close a directory handle opened by sftp_opendir().
| dir | The sftp directory handle to close. |
| int sftp_dir_close | ( | SFTP_DIR * | dir | ) |
| int sftp_dir_eof | ( | SFTP_DIR * | dir | ) |
Tell if the directory has reached EOF (End Of File).
| dir | The sftp directory handle. |
| int sftp_file_close | ( | SFTP_FILE * | file | ) |
| void sftp_free | ( | SFTP_SESSION * | sftp | ) |
Close and deallocate a sftp session.
| sftp | The sftp session handle to free. |
| SFTP_ATTRIBUTES* sftp_fstat | ( | SFTP_FILE * | file | ) |
Get information about a file or directory from a file handle.
| file | The sftp file handle to get the stat information. |
| int sftp_get_error | ( | SFTP_SESSION * | sftp | ) |
Get the last sftp error.
Use this function to get the latest error set by a posix like sftp function.
| sftp | The sftp session where the error is saved. |
| int sftp_init | ( | SFTP_SESSION * | sftp | ) |
Initialize the sftp session with the server.
| sftp | The sftp session to initialize. |
| SFTP_ATTRIBUTES* sftp_lstat | ( | SFTP_SESSION * | session, | |
| const char * | path | |||
| ) |
Get information about a file or directory.
Identical to sftp_stat, but if the file or directory is a symbolic link, then the link itself is stated, not the file that it refers to.
| session | The sftp session handle. | |
| path | The path to the file or directory to obtain the information. |
| int sftp_mkdir | ( | SFTP_SESSION * | sftp, | |
| const char * | directory, | |||
| mode_t | mode | |||
| ) |
Create a directory.
| sftp | The sftp session handle. | |
| directory | The directory to create. | |
| mode | Specifies the permissions to use. It is modified by the process's umask in the usual way: The permissions of the created file are (mode & ~umask) |
| SFTP_SESSION* sftp_new | ( | SSH_SESSION * | session | ) |
Start a new sftp session.
| session | The ssh session to use. |
| SFTP_FILE* sftp_open | ( | SFTP_SESSION * | session, | |
| const char * | file, | |||
| int | flags, | |||
| mode_t | mode | |||
| ) |
Open a file on the server.
| session | The sftp session handle. | |
| file | The file to be opened. | |
| access | Is one of O_RDONLY, O_WRONLY or O_RDWR which request opening the file read-only,write-only or read/write. Acesss may also be bitwise-or'd with one or more of the following: O_CREAT - If the file does not exist it will be created. O_EXCL - When used with O_CREAT, if the file already exists it is an error and the open will fail. O_TRUNC - If the file already exists it will be truncated. | |
| mode | Mode specifies the permissions to use if a new file is created. It is modified by the process's umask in the usual way: The permissions of the created file are (mode & ~umask) |
| SFTP_DIR* sftp_opendir | ( | SFTP_SESSION * | session, | |
| const char * | path | |||
| ) |
Open a directory used to obtain directory entries.
| session | The sftp session handle to open the directory. | |
| path | The path of the directory to open. |
| ssize_t sftp_read | ( | SFTP_FILE * | file, | |
| void * | buf, | |||
| size_t | count | |||
| ) |
Read from a file using an opened sftp file handle.
| file | The opened sftp file handle to be read from. | |
| buf | Pointer to buffer to recieve read data. | |
| count | Size of the buffer in bytes. |
| SFTP_ATTRIBUTES* sftp_readdir | ( | SFTP_SESSION * | session, | |
| SFTP_DIR * | dir | |||
| ) |
Get a single file attributes structure of a directory.
| session | The sftp session handle to read the directory entry. | |
| dir | The opened sftp directory handle to read from. |
sftp_attribute_free()
| char* sftp_readlink | ( | SFTP_SESSION * | sftp, | |
| const char * | path | |||
| ) |
Read the value of a symbolic link.
| sftp | The sftp session handle. | |
| path | Specifies the path name of the symlink to be read. |
| int sftp_rename | ( | SFTP_SESSION * | sftp, | |
| const char * | original, | |||
| const char * | newname | |||
| ) |
Rename or move a file or directory.
| sftp | The sftp session handle. | |
| original | The original url (source url) of file or directory to be moved. | |
| newname | The new url (destination url) of the file or directory after the move. |
| void sftp_rewind | ( | SFTP_FILE * | file | ) |
Rewinds the position of the file pointer to the beginning of the file.
| file | Open sftp file handle. |
| int sftp_rm | ( | SFTP_SESSION * | sftp, | |
| const char * | file | |||
| ) |
| int sftp_rmdir | ( | SFTP_SESSION * | sftp, | |
| const char * | directory | |||
| ) |
Remove a directoy.
| sftp | The sftp session handle. | |
| directory | The directory to remove. |
| int sftp_seek | ( | SFTP_FILE * | file, | |
| u32 | new_offset | |||
| ) |
Seek to a specific location in a file.
| file | Open sftp file handle to seek in. | |
| new_offset | Offset in bytes to seek. |
| int sftp_seek64 | ( | SFTP_FILE * | file, | |
| u64 | new_offset | |||
| ) |
Seek to a specific location in a file.
This is the 64bit version.
| file | Open sftp file handle to seek in. | |
| new_offset | Offset in bytes to seek. |
| int sftp_server_version | ( | SFTP_SESSION * | sftp | ) |
Get the version of the SFTP protocol supported by the server.
| sftp | The sftp session handle. |
| int sftp_setstat | ( | SFTP_SESSION * | sftp, | |
| const char * | file, | |||
| SFTP_ATTRIBUTES * | attr | |||
| ) |
Set file attributes on a file, directory or symbolic link.
| sftp | The sftp session handle. | |
| file | The file which attributes should be changed. | |
| attr | The file attributes structure with the attributes set which should be changed. |
| SFTP_ATTRIBUTES* sftp_stat | ( | SFTP_SESSION * | session, | |
| const char * | path | |||
| ) |
Get information about a file or directory.
| session | The sftp session handle. | |
| path | The path to the file or directory to obtain the information. |
| int sftp_symlink | ( | SFTP_SESSION * | sftp, | |
| const char * | target, | |||
| const char * | dest | |||
| ) |
Create a symbolic link.
| sftp | The sftp session handle. | |
| target | Specifies the target of the symlink. | |
| dest | Specifies the path name of the symlink to be created. |
| unsigned long sftp_tell | ( | SFTP_FILE * | file | ) |
Report current byte position in file.
| file | Open sftp file handle. |
| u64 sftp_tell64 | ( | SFTP_FILE * | file | ) |
Report current byte position in file.
| file | Open sftp file handle. |
| int sftp_unlink | ( | SFTP_SESSION * | sftp, | |
| const char * | file | |||
| ) |
Unlink (delete) a file.
| sftp | The sftp session handle. | |
| file | The file to unlink/delete. |
| int sftp_utimes | ( | SFTP_SESSION * | sftp, | |
| const char * | file, | |||
| const struct timeval * | times | |||
| ) |
Change the last modification and access time of a file.
| sftp | The sftp session handle. | |
| file | The file which owner and group should be changed. | |
| times | A timeval structure which contains the desired access and modification time. |
| ssize_t sftp_write | ( | SFTP_FILE * | file, | |
| const void * | buf, | |||
| size_t | count | |||
| ) |
Write to a file using an opened sftp file handle.
| file | Open sftp file handle to write to. | |
| buf | Pointer to buffer to write data. | |
| count | Size of buffer in bytes. |