question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Expose additional directory entry fields

See original GitHub issue

The smbclient.scandir function returns an iterator to SMBDirEntry objects – and since the directory is queried for FILE_ID_FULL_DIRECTORY_INFORMATION, the internal _dir_info structure holds additional useful information such as allocation_size and last_write_time.

These should be exposed the same way that inode() is exposing the file_id field.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
jborean93commented, Jul 28, 2021

Just as an FYI this is somewhat possible today through public interfaces

import smbclient

from smbprotocol.file_info import FileInformationClass

path = r'\\server\share\dir'

with smbclient.open_file(path, mode='rb', buffering=0, file_type='dir', share_access='r') as dir:
    for dir_entry in dir.query_directory("*", FileInformationClass.FILE_NAMES_INFORMATION):
        print(dir_entry['file_name'].get_value().decode('utf-16-le'))

This is essentially what scandir does except now you are just dealing with the raw information.

Unfortunately it does expose the raw structure value back which isn’t the easiest to deal with.

1reaction
malthecommented, Jul 27, 2021

Perhaps a new function querydir which can then return a richer object that more closely models the file information class?

That is – we keep SMBDirEntry for the result of scandir but introduce a new class for the result of querydir that explicitly exposes FileInformationClass.FILE_ID_FULL_DIRECTORY_INFORMATION (or whatever information class is requested).

This might then also be an opportunity to dial down the information class for scandir – presumably it costs a little extra on the server side to retrieve all that metadata.

Read more comments on GitHub >

github_iconTop Results From Across the Web

os: new Readdirentries method to read directory entries and ...
Could we please have a new File-level API to list a directory's entries, which exposes the d_type field ( syscall.Dirent.
Read more >
Chapter 5. Directory Entry Schema Reference
This chapter provides an overview of some of the basic concepts of the directory schema and lists the files in which the schema...
Read more >
Provide optional claims to Azure AD apps - Microsoft Entra
How to add custom or additional claims to the SAML 2.0 and JSON Web ... in extension attributes and directory extensions to add...
Read more >
Dockerfile reference - Docker Documentation
Environment variables are supported by the following list of instructions in the Dockerfile : ADD; COPY; ENV; EXPOSE; FROM; LABEL; STOPSIGNAL ...
Read more >
os — Miscellaneous operating system interfaces — Python ...
For creating temporary files and directories see the tempfile module, ... scandir() to expose the file path and other file attributes of a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found