Codebase list pysmb / c73c350
Merge #172 into dev-1.2.x Michael Teo 3 years ago
2 changed file(s) with 14 addition(s) and 13 deletion(s). Raw diff Collapse all Expand all
428428 finally:
429429 self.is_busy = False
430430
431 def resetFileAttributes(self, service_name, path_file_pattern, timeout = 30):
431 def resetFileAttributes(self, service_name, path_file_pattern, file_attributes = ATTR_NORMAL, timeout = 30):
432432 """
433433 Reset file attributes of one or more regular files or folders.
434434 It supports the use of wildcards in file names, allowing for unlocking of multiple files/folders in a single request.
435435 This function is very helpful when deleting files/folders that are read-only.
436 Note: this function is currently only implemented for SMB2! Technically, it sets the FILE_ATTRIBUTE_NORMAL flag, therefore clearing all other flags. (See https://msdn.microsoft.com/en-us/library/cc232110.aspx for further information)
436 By default, it sets the ATTR_NORMAL flag, therefore clearing all other flags.
437 (See https://msdn.microsoft.com/en-us/library/cc232110.aspx for further information)
438
439 Note: this function is currently only implemented for SMB2!
437440
438441 :param string/unicode service_name: Contains the name of the shared folder.
439442 :param string/unicode path_file_pattern: The pathname of the file(s) to be deleted, relative to the service_name.
440443 Wildcards may be used in the filename component of the path.
441444 If your path/filename contains non-English characters, you must pass in an unicode string.
445 :param int file_attributes: The desired file attributes to set. Defaults to `ATTR_NORMAL`.
442446 :return: None
443447 """
444448 if not self.sock:
453457
454458 self.is_busy = True
455459 try:
456 self._resetFileAttributes(service_name, path_file_pattern, cb, eb, timeout = timeout)
457 while self.is_busy:
458 self._pollForNetBIOSPacket(timeout)
459 finally:
460 self.is_busy = False
461
460 self._resetFileAttributes(service_name, path_file_pattern, cb, eb, file_attributes, timeout)
461 while self.is_busy:
462 self._pollForNetBIOSPacket(timeout)
463 finally:
464 self.is_busy = False
462465
463466 def createDirectory(self, service_name, path, timeout = 30):
464467 """
12871287
12881288 sendCreate(tid)
12891289
1290 def _resetFileAttributes_SMB2(self, service_name, path_file_pattern, callback, errback, timeout = 30):
1290 def _resetFileAttributes_SMB2(self, service_name, path_file_pattern, callback, errback, file_attributes = ATTR_NORMAL, timeout = 30):
12911291 if not self.has_authenticated:
12921292 raise NotReadyError('SMB connection not authenticated')
12931293
13351335 additional_info = 0,
13361336 info_type = SMB2_INFO_FILE,
13371337 file_info_class = 4, # FileBasicInformation
1338 data = struct.pack('qqqqii',0,0,0,0,0x80,0))) # FILE_ATTRIBUTE_NORMAL
1338 data = struct.pack('qqqqii', 0, 0, 0, 0, file_attributes, 0)))
13391339 # [MS-SMB2]: 2.2.39, [MS-FSCC]: 2.4, [MS-FSCC]: 2.4.7, [MS-FSCC]: 2.6
13401340 m.tid = tid
13411341 self._sendSMBMessage(m)
13771377 messages_history.append(m)
13781378 else:
13791379 sendCreate(self.connected_trees[service_name])
1380
1381
13821380
13831381 def _createDirectory_SMB2(self, service_name, path, callback, errback, timeout = 30):
13841382 if not self.has_authenticated:
26952693
26962694 sendDelete(tid)
26972695
2698 def _resetFileAttributes_SMB1(self, service_name, path_file_pattern, callback, errback, timeout = 30):
2696 def _resetFileAttributes_SMB1(self, service_name, path_file_pattern, callback, errback, file_attributes=ATTR_NORMAL, timeout = 30):
26992697 raise NotReadyError('resetFileAttributes is not yet implemented for SMB1')
27002698
27012699 def _createDirectory_SMB1(self, service_name, path, callback, errback, timeout = 30):