Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I know a SftpName of type SymbolicLink is linked to a directory or a file? #31

Closed
jonahzheng opened this issue Jun 1, 2022 · 2 comments

Comments

@jonahzheng
Copy link

jonahzheng commented Jun 1, 2022

final sftp = await client.sftp();
final items = await sftp.listdir('/');
for (final item in items) {
  if ((file.attr.isSymbolicLink)){
     print(item.longname);
  }
}
@xtyxtyx
Copy link
Member

xtyxtyx commented Jun 1, 2022

You can use sftp.stat with followLink set to true to check the attributes of the target of the link.

final sftp = await client.sftp();

final files = await sftp.listdir('/');

for (var file in files) {
  if (file.attr.isSymbolicLink) {
    final stat = await sftp.stat(file.filename, followLink: true);
    print('type: ${stat.mode?.type}');
  }
}

@jonahzheng
Copy link
Author

Thank you for your replay!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants