#include <ne7ssh.h>
Classes | |
struct | fileAttrs |
Public Types | |
enum | writeMode { READ, OVERWRITE, APPEND } |
Public Member Functions | |
Ne7SftpSubsystem () | |
Ne7SftpSubsystem (class Ne7sshSftp *_sftp) | |
~Ne7SftpSubsystem () | |
bool | setTimeout (uint32 _timeout) |
uint32 | openFile (const char *filename, uint8 mode) |
uint32 | openDir (const char *dirname) |
bool | readFile (uint32 fileID, uint64 offset=0) |
bool | writeFile (uint32 fileID, const uint8 *data, uint32 len, uint64 offset=0) |
bool | closeFile (uint32 fileID) |
bool | getFileAttrs (fileAttrs &attrs, const char *filename, bool followSymLinks=true) |
bool | get (const char *remoteFile, FILE *localFile) |
bool | put (FILE *localFile, const char *remoteFile) |
bool | rm (const char *remoteFile) |
bool | mv (const char *oldFile, const char *newFile) |
bool | mkdir (const char *remoteDir) |
bool | rmdir (const char *remoteDir) |
const char * | ls (const char *remoteDir, bool longNames=false) |
bool | cd (const char *remoteDir) |
bool | chmod (const char *remoteFile, const char *mode) |
bool | chown (const char *remoteFile, uint32_t uid, uint32_t gid=0) |
bool | isFile (const char *remoteFile) |
bool | isDir (const char *remoteFile) |
Private Member Functions | |
bool | errorNotInited () |
Private Attributes | |
bool | inited |
Ne7sshSftp * | sftp |
Modes used when opening a remote file.
Ne7SftpSubsystem::Ne7SftpSubsystem | ( | ) |
Default constructor.
Ne7SftpSubsystem::Ne7SftpSubsystem | ( | class Ne7sshSftp * | _sftp | ) |
Constructor used to initialize the subsystem with a new Ne7sshSftp class instance.
_sftp | Ne7sshSftp class instance. |
Ne7SftpSubsystem::~Ne7SftpSubsystem | ( | ) |
Default destructor.
bool Ne7SftpSubsystem::cd | ( | const char * | remoteDir | ) |
This method is used to change the current working directory.
remoteDir | Full or relative path to the new working directory on the remote server. |
References Ne7sshSftp::cd(), and errorNotInited().
bool Ne7SftpSubsystem::chmod | ( | const char * | remoteFile, | |
const char * | mode | |||
) |
This method is used for changing the permissions associated with a remote file.
remoteFile | Full or relative path to the remote file. | |
mode | Mode string. It can be either a numerical mode expression such as "755" or an expression showing the modifications to be made, such as "ug+w". Mode string is the same as used by *nix chmod command. |
References Ne7sshSftp::chmod(), and errorNotInited().
bool Ne7SftpSubsystem::chown | ( | const char * | remoteFile, | |
uint32_t | uid, | |||
uint32_t | gid = 0 | |||
) |
This method is used to change the owner of a remote file.
remoteFile | Full or relative path to the remote file. | |
uid | Numerical new owner user ID. | |
gid | Numerical new owner group ID. |
References Ne7sshSftp::chown(), and errorNotInited().
bool Ne7SftpSubsystem::closeFile | ( | uint32 | fileID | ) |
Low level method used to close a file opened by using openFile() method.
fileID | File ID returned by openFile() method. |
References Ne7sshSftp::closeFile(), and errorNotInited().
bool Ne7SftpSubsystem::errorNotInited | ( | ) | [private] |
Pushes and error to the error buffer, if this subsystem has not been initialized before usage.
References ne7ssh::errors(), and Ne7sshError::push().
Referenced by cd(), chmod(), chown(), closeFile(), get(), getFileAttrs(), isDir(), isFile(), ls(), mkdir(), mv(), openDir(), openFile(), put(), readFile(), rm(), rmdir(), setTimeout(), and writeFile().
bool Ne7SftpSubsystem::get | ( | const char * | remoteFile, | |
FILE * | localFile | |||
) |
This method is used to retrieve a remote file and dump it into local file.
remoteFile | Full or relative path to the file on the remote side. | |
localFile | Pointer to the FILE structure. If the file being retrieved is binary, use "w+" attributes in fopen function. |
References errorNotInited(), and Ne7sshSftp::get().
bool Ne7SftpSubsystem::getFileAttrs | ( | fileAttrs & | attrs, | |
const char * | filename, | |||
bool | followSymLinks = true | |||
) |
This method is used to retrieve remote file attributes and place them into fileAttrs structure.
attrs | Reference to fileAttrs structure where retrieved attributes should be placed. | |
filename | Name of the remote file. | |
followSymLinks | If this variable is set to true, symbolic links will be followed. That is the default befavour. If this behavour is undesired, pass "false". |
References errorNotInited(), and Ne7sshSftp::getFileAttrs().
bool Ne7SftpSubsystem::isDir | ( | const char * | remoteFile | ) |
This method is used to determine if a remote inode is a directory.
remoteFile | Full or relative path to the remote file. |
References errorNotInited(), and Ne7sshSftp::isDir().
bool Ne7SftpSubsystem::isFile | ( | const char * | remoteFile | ) |
This method is used to determine if a remote inode is a regular file.
remoteFile | Full or relative path to the remote inode. |
References errorNotInited(), and Ne7sshSftp::isFile().
const char * Ne7SftpSubsystem::ls | ( | const char * | remoteDir, | |
bool | longNames = false | |||
) |
This methods is used retrieve a listing of a remote directory.
remoteDir | Full or relative path to a directory. | |
longNames | If set to "true" the returned string in addition to file strings will contain attributes for each file. |
References errorNotInited(), and Ne7sshSftp::ls().
bool Ne7SftpSubsystem::mkdir | ( | const char * | remoteDir | ) |
This method is used to create a new directory.
remoteDir | Full or relative path to a new directory on the remote server. |
References errorNotInited(), and Ne7sshSftp::mkdir().
bool Ne7SftpSubsystem::mv | ( | const char * | oldFile, | |
const char * | newFile | |||
) |
This method is used to rename/move files.
oldFile | Full or relative path to an old file on the remote server. | |
newFile | Full or relative path to a new file on the remote side. |
References errorNotInited(), and Ne7sshSftp::mv().
uint32 Ne7SftpSubsystem::openDir | ( | const char * | dirname | ) |
Low level method used to open an inode containing file entries a.k.a directory.
dirname | Relative or full path to the inode. |
References errorNotInited(), and Ne7sshSftp::openDir().
uint32 Ne7SftpSubsystem::openFile | ( | const char * | filename, | |
uint8 | mode | |||
) |
Low level method used to open a remote file.
filename | Relative or full path to the file. | |
mode | Mode to be used when opening the file. Can be one of the modes defined by writeMode class variable. |
References errorNotInited(), and Ne7sshSftp::openFile().
bool Ne7SftpSubsystem::put | ( | FILE * | localFile, | |
const char * | remoteFile | |||
) |
This method is used to upload a file to a remote server.
localFile | Pointer to the FILE structure. If the file being retrieved is binary, use "r+" attributes in fopen function. | |
remoteFile | Full or relative path to the file on the remote side. |
References errorNotInited(), and Ne7sshSftp::put().
bool Ne7SftpSubsystem::readFile | ( | uint32 | fileID, | |
uint64 | offset = 0 | |||
) |
Low level method used to read datablock up to the size of SFTP_MAX_MSG_SIZE from a file.
fileID | File ID retruned by openFile() method. | |
offset | Offset. |
References errorNotInited(), and Ne7sshSftp::readFile().
bool Ne7SftpSubsystem::rm | ( | const char * | remoteFile | ) |
This method is used to remove a file on a remote server.
remoteFile | Full or relative path to the file on the remote side. |
References errorNotInited(), and Ne7sshSftp::rm().
bool Ne7SftpSubsystem::rmdir | ( | const char * | remoteDir | ) |
This method is used to remove a remote directory.
remoteDir | Full or relative path to a directory to be removed. |
References errorNotInited(), and Ne7sshSftp::rmdir().
bool Ne7SftpSubsystem::setTimeout | ( | uint32 | _timeout | ) |
This method is used to set a timeout for all SFTP subsystem communications.
_timeout | Timeout in seconds. |
References errorNotInited(), and Ne7sshSftp::setTimeout().
bool Ne7SftpSubsystem::writeFile | ( | uint32 | fileID, | |
const uint8 * | data, | |||
uint32 | len, | |||
uint64 | offset = 0 | |||
) |
Low level method used to write data-block up to the size of SFTP_MAX_MSG_SIZE to a remote file.
fileID | File ID returned by openFile() method. | |
data | Pointer to a buffer containing the data. | |
len | Length of the block. | |
offset | Offset in the remote file. If offset is passed EOF the space between EOF and offset will be filled by 0x0. |
References errorNotInited(), and Ne7sshSftp::writeFile().