File tree Expand file tree Collapse file tree 1 file changed +13
-10
lines changed Expand file tree Collapse file tree 1 file changed +13
-10
lines changed Original file line number Diff line number Diff line change @@ -159,20 +159,23 @@ def set_raw_data(self, data):
159159 def get_class (self ) -> Union [Type [T ], None ]:
160160 return ClassIDTypeToClassMap .get (self .type )
161161
162- def peek_name (self ) -> Union [str , None ]:
162+ def peek_name (self , max_name_length : int = 256 ) -> Union [str , None ]:
163163 """Peeks the name of the object without reading/parsing the whole object."""
164164 # TODO: EditorExtension might be enough
165+ if self .platform == BuildTarget .NoTarget :
166+ # 2x PPtr
167+ raise NotImplementedError (
168+ "Directly fetching the name for 'NoTarget' platform is not supported"
169+ )
165170 clz = self .get_class ()
166- if clz and issubclass (clz , NamedObject ):
167- self .reset ()
168- if self .platform == BuildTarget .NoTarget :
169- # 2x PPtr
170- raise NotImplementedError (
171- "Directly fetching the name for 'NoTarget' platform is not supported"
172- )
173- return self .reader .read_aligned_string ()
174- else :
171+ if "m_Name" not in clz .__annotations__ :
172+ return None
173+ self .reset ()
174+ len = self .reader .read_int ()
175+ if len < 0 or len > max_name_length or len + 4 > self .byte_size :
175176 return None
177+ string_data = bytes (self .reader .read_bytes (len ))
178+ return string_data .decode ("utf8" , "surrogateescape" )
176179
177180 @property
178181 def container (self ):
You can’t perform that action at this time.
0 commit comments