miketeo / pysmb

pysmb is an experimental SMB/CIFS library written in Python. It implements the client-side SMB/CIFS protocol (SMB1 and SMB2) which allows your Python application to access and transfer files to/from SMB/CIFS shared folders like your Windows file sharing and Samba folders.
Other
341 stars 94 forks source link

Get file/directory attributes #2

Closed j0hnsmith closed 10 years ago

j0hnsmith commented 10 years ago

SMBConnection is cool but I don't see a way to get the metadata for a file, specifically I'd like to be able to get 'offline' attribute for a file. How can I get that attribute for a file using this library?

miketeo commented 10 years ago

You can try do a AND-bitmask the SharedFile.file_attributes with the value of 0x00001000.

See http://msdn.microsoft.com/en-us/library/cc246322.aspx The ATTR_OFFLINE constant is a new extension to the SMB specs (I have not added them to pysmb yet).

j0hnsmith commented 10 years ago

Thanks for your comments. Calling listPath and processing the results is inefficient for my use case as I want the details for a single file, not an entire directory. Is there a way I can make a QUERY_INFO request (2.2.37 http://msdn.microsoft.com/en-us/library/cc246557.aspx) for a specific file directly?

scfarley commented 10 years ago

I would concur. I wrote a method to grab the entire path listing then parse for the particular file (if requested): https://github.com/smartfile/fs-smb/blob/master/smbfs/__init__.py#L181

I tried other tricks to use a pattern or such, but I was unable to figure out a way that always worked using those tricks.

miketeo commented 10 years ago

@scfarley , @j0hnsmith : I guess it's about time to improve the current API to add in this functionality. I will do about it over this weekend. Will keep both of you posted via github.

j0hnsmith commented 10 years ago

@miketeo did you manage to add this functionality?

miketeo commented 10 years ago

@j0hnsmith : Yes, it was released in pysmb 1.1.10

j0hnsmith commented 10 years ago

Ahh yes, I missed https://github.com/miketeo/pysmb/commit/fdd3bdc248d862faee564d483c117e8f380b854c. Many thanks

scfarley commented 10 years ago

Thank you very much.