Esempio n. 1
0
  def _Stat(
      self,
      entry: pyfsntfs.file_entry,
      data_stream: pyfsntfs.data_stream,
      pathspec: rdf_paths.PathSpec,
  ) -> rdf_client_fs.StatEntry:
    st = rdf_client_fs.StatEntry()
    st.pathspec = pathspec

    st.st_atime = rdfvalue.RDFDatetimeSeconds.FromDatetime(
        entry.get_access_time())
    st.st_mtime = rdfvalue.RDFDatetimeSeconds.FromDatetime(
        entry.get_modification_time())
    st.st_crtime = rdfvalue.RDFDatetimeSeconds.FromDatetime(
        entry.get_creation_time())
    st.st_ctime = rdfvalue.RDFDatetimeSeconds.FromDatetime(
        entry.get_entry_modification_time())
    if entry.has_directory_entries_index():
      st.st_mode = stat.S_IFDIR
    else:
      st.st_mode = stat.S_IFREG
      if data_stream is not None:
        st.st_size = data_stream.get_size()
    flags = entry.file_attribute_flags
    st.st_mode |= stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH
    if (flags & FILE_ATTRIBUTE_READONLY) == 0:
      st.st_mode |= stat.S_IWUSR | stat.S_IWGRP | stat.S_IWOTH
    if (flags & FILE_ATTRIBUTE_HIDDEN) == 0:
      st.st_mode |= stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH
    return st
Esempio n. 2
0
 def _Stat(
     self,
     entry: pyfsntfs.file_entry,
     data_stream: pyfsntfs.data_stream,
 ) -> filesystem_pb2.StatEntry:
     st = filesystem_pb2.StatEntry()
     if entry.name is not None:
         st.name = entry.name
     st.st_ino = entry.file_reference
     st.st_atime.FromDatetime(entry.get_access_time())
     st.st_mtime.FromDatetime(entry.get_modification_time())
     st.st_btime.FromDatetime(entry.get_creation_time())
     st.st_ctime.FromDatetime(entry.get_entry_modification_time())
     st.ntfs.is_directory = entry.has_directory_entries_index()
     if not entry.has_directory_entries_index() and data_stream is not None:
         st.st_size = data_stream.get_size()
     if entry != data_stream and data_stream is not None:
         st.stream_name = data_stream.name
     st.ntfs.flags = entry.file_attribute_flags
     return st