Retrieve a directory listing of files/folders at *path* For simplicity, pysmb defines a "normal" file as a file entry that is not read-only, not hidden, not system, not archive and not a directory. It ignores other attributes like compression, indexed, sparse, temporary and
(self, service_name, path,
search = SMB_FILE_ATTRIBUTE_READONLY | SMB_FILE_ATTRIBUTE_HIDDEN | SMB_FILE_ATTRIBUTE_SYSTEM | SMB_FILE_ATTRIBUTE_DIRECTORY | SMB_FILE_ATTRIBUTE_ARCHIVE | SMB_FILE_ATTRIBUTE_INCL_NORMAL,
pattern = '*', timeout = 30)
| 170 | return results |
| 171 | |
| 172 | def listPath(self, service_name, path, |
| 173 | search = SMB_FILE_ATTRIBUTE_READONLY | SMB_FILE_ATTRIBUTE_HIDDEN | SMB_FILE_ATTRIBUTE_SYSTEM | SMB_FILE_ATTRIBUTE_DIRECTORY | SMB_FILE_ATTRIBUTE_ARCHIVE | SMB_FILE_ATTRIBUTE_INCL_NORMAL, |
| 174 | pattern = '*', timeout = 30): |
| 175 | """ |
| 176 | Retrieve a directory listing of files/folders at *path* |
| 177 | |
| 178 | For simplicity, pysmb defines a "normal" file as a file entry that is not read-only, not hidden, not system, not archive and not a directory. |
| 179 | It ignores other attributes like compression, indexed, sparse, temporary and encryption. |
| 180 | |
| 181 | Note that the default search parameter will query for all read-only (SMB_FILE_ATTRIBUTE_READONLY), hidden (SMB_FILE_ATTRIBUTE_HIDDEN), |
| 182 | system (SMB_FILE_ATTRIBUTE_SYSTEM), archive (SMB_FILE_ATTRIBUTE_ARCHIVE), normal (SMB_FILE_ATTRIBUTE_INCL_NORMAL) files |
| 183 | and directories (SMB_FILE_ATTRIBUTE_DIRECTORY). |
| 184 | If you do not need to include "normal" files in the result, define your own search parameter without the SMB_FILE_ATTRIBUTE_INCL_NORMAL constant. |
| 185 | SMB_FILE_ATTRIBUTE_NORMAL should be used by itself and not be used with other bit constants. |
| 186 | |
| 187 | :param string/unicode service_name: the name of the shared folder for the *path* |
| 188 | :param string/unicode path: path relative to the *service_name* where we are interested to learn about its files/sub-folders. |
| 189 | :param integer search: integer value made up from a bitwise-OR of *SMB_FILE_ATTRIBUTE_xxx* bits (see smb_constants.py). |
| 190 | :param string/unicode pattern: the filter to apply to the results before returning to the client. |
| 191 | :return: A list of :doc:`smb.base.SharedFile<smb_SharedFile>` instances. |
| 192 | """ |
| 193 | if not self.sock: |
| 194 | raise NotConnectedError('Not connected to server') |
| 195 | |
| 196 | results = [ ] |
| 197 | |
| 198 | def cb(entries): |
| 199 | self.is_busy = False |
| 200 | results.extend(entries) |
| 201 | |
| 202 | def eb(failure): |
| 203 | self.is_busy = False |
| 204 | raise failure |
| 205 | |
| 206 | self.is_busy = True |
| 207 | try: |
| 208 | self._listPath(service_name, path, cb, eb, search = search, pattern = pattern, timeout = timeout) |
| 209 | while self.is_busy: |
| 210 | self._pollForNetBIOSPacket(timeout) |
| 211 | finally: |
| 212 | self.is_busy = False |
| 213 | |
| 214 | return results |
| 215 | |
| 216 | def listSnapshots(self, service_name, path, timeout = 30): |
| 217 | """ |
no test coverage detected