mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-08-29 22:32:38 -06:00
SshBasics: SFtpFileSystemInfo example added.
git-svn-id: svn://ultimatepp.org/upp/trunk@12433 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
9bdb145d40
commit
2a1961c0c3
4 changed files with 35 additions and 0 deletions
31
reference/SshBasics/SFtpFileSystemInfo.cpp
Normal file
31
reference/SshBasics/SFtpFileSystemInfo.cpp
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
#include "SshBasics.h"
|
||||
|
||||
// SFtpTransparency:
|
||||
// Demonstrates access to sftp directory hierarcy in a file-system-agnostic (transparent) way.
|
||||
|
||||
void ReadDirEntries(FileSystemInfo& fsi, const String& path)
|
||||
{
|
||||
int maxentry = 5;
|
||||
for(FileSystemInfo::FileInfo entry : fsi.Find(path, maxentry)) {
|
||||
DUMP(entry.filename);
|
||||
DUMP(entry.is_folder);
|
||||
DUMP(entry.length);
|
||||
DUMP(entry.last_access_time);
|
||||
//...
|
||||
}
|
||||
}
|
||||
|
||||
void SFtpTransparency(SshSession& session)
|
||||
{
|
||||
LOG("Local file system objects----------------------------------------------------------");
|
||||
ReadDirEntries(StdFileSystemInfo(), GetCurrentDirectory());
|
||||
|
||||
SFtp sftp(session);
|
||||
SFtpFileSystemInfo sfsi(sftp);
|
||||
|
||||
LOG("Remote file system objects---------------------------------------------------------");
|
||||
ReadDirEntries(sfsi, "/pub/example/*.png");
|
||||
|
||||
if(sftp.IsError())
|
||||
LOG(sftp.GetErrorDesc());
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue