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):
159
159
def get_class (self ) -> Union [Type [T ], None ]:
160
160
return ClassIDTypeToClassMap .get (self .type )
161
161
162
- def peek_name (self ) -> Union [str , None ]:
162
+ def peek_name (self , max_name_length : int = 256 ) -> Union [str , None ]:
163
163
"""Peeks the name of the object without reading/parsing the whole object."""
164
164
# 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
+ )
165
170
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 :
175
176
return None
177
+ string_data = bytes (self .reader .read_bytes (len ))
178
+ return string_data .decode ("utf8" , "surrogateescape" )
176
179
177
180
@property
178
181
def container (self ):
You can’t perform that action at this time.
0 commit comments