win32_file_watcher.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:Deploy_XXNET_Server 作者: jzp820927 项目源码 文件源码
def _parse_file_notification_information(buff, offset):
  """Parse FileNotificationInformation from a c_char buffer.

  Args:
    buff: a ctypes string buffer that contains
         a FileNotificationInformation structure.
    offset: the offset you want to parse the struct from.

  Returns:
    a class matching the structure.
  """
  notify_information_short = ctypes.cast(
      ctypes.addressof(buff) + offset,
      ctypes.POINTER(FileNotifyInformationShort)).contents
  # This is a variable length structure so we need to do a 2 steps parse to
  # create a perfectly matching result.
  chr_len = notify_information_short.FileNameLength / _WCHAR_BYTESIZE

  class FileNotifyInformation(ctypes.Structure):
    _fields_ = (
        _COMMON_FILE_NOTIFY_FIELDS +
        [('FileName', ctypes.c_wchar * chr_len)])
  return ctypes.cast(ctypes.addressof(buff) + offset,
                     ctypes.POINTER(FileNotifyInformation)).contents


# we want to be sure that at least one notification fits even if it is a big
# one.
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号