2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								/**************************************************************************/  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/*  file_access_pack.cpp                                                  */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/**************************************************************************/  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/*                         This file is part of:                          */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/*                             GODOT ENGINE                               */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/*                        https://godotengine.org                         */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/**************************************************************************/  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur.                  */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/*                                                                        */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* Permission is hereby granted, free of charge, to any person obtaining  */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* a copy of this software and associated documentation files (the        */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* "Software"), to deal in the Software without restriction, including    */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* without limitation the rights to use, copy, modify, merge, publish,    */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* distribute, sublicense, and/or sell copies of the Software, and to     */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* permit persons to whom the Software is furnished to do so, subject to  */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* the following conditions:                                              */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/*                                                                        */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* The above copyright notice and this permission notice shall be         */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* included in all copies or substantial portions of the Software.        */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/*                                                                        */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,        */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF     */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY   */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,   */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE      */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                 */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/**************************************************************************/  
						 
					
						
							
								
									
										
										
										
											2018-01-05 00:50:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								# include  "file_access_pack.h" 
  
						 
					
						
							
								
									
										
										
										
											2018-09-11 18:13:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-04-28 20:51:29 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  "core/io/file_access_encrypted.h" 
  
						 
					
						
							
								
									
										
										
										
											2020-11-07 19:33:38 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  "core/object/script_language.h" 
  
						 
					
						
							
								
									
										
										
										
											2021-12-20 11:28:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  "core/os/os.h" 
  
						 
					
						
							
								
									
										
										
										
											2018-09-11 18:13:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  "core/version.h" 
  
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-03-26 18:51:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Error  PackedData : : add_pack ( const  String  & p_path ,  bool  p_replace_files ,  uint64_t  p_offset )  {  
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									for  ( int  i  =  0 ;  i  <  sources . size ( ) ;  i + + )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-13 11:22:06 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( sources [ i ] - > try_open_pack ( p_path ,  p_replace_files ,  p_offset ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
											return  OK ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-19 15:46:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  ERR_FILE_UNRECOGNIZED ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-19 15:46:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-02-20 11:08:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  PackedData : : add_path ( const  String  & p_pkg_path ,  const  String  & p_path ,  uint64_t  p_ofs ,  uint64_t  p_size ,  const  uint8_t  * p_md5 ,  PackSource  * p_src ,  bool  p_replace_files ,  bool  p_encrypted ,  bool  p_bundle )  {  
						 
					
						
							
								
									
										
										
										
											2024-09-23 12:39:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									String  simplified_path  =  p_path . simplify_path ( ) . trim_prefix ( " res:// " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-22 15:03:05 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									PathMD5  pmd5 ( simplified_path . md5_buffer ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-08-01 22:10:38 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									bool  exists  =  files . has ( pmd5 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									PackedFile  pf ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-04-28 20:51:29 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									pf . encrypted  =  p_encrypted ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-02-20 11:08:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									pf . bundle  =  p_bundle ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-03-26 18:51:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									pf . pack  =  p_pkg_path ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									pf . offset  =  p_ofs ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									pf . size  =  p_size ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									for  ( int  i  =  0 ;  i  <  16 ;  i + + )  { 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-13 18:03:28 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										pf . md5 [ i ]  =  p_md5 [ i ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									pf . src  =  p_src ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( ! exists  | |  p_replace_files )  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-09-23 22:41:25 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										files [ pmd5 ]  =  pf ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( ! exists )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-23 12:39:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// Search for directory.
 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										PackedDir  * cd  =  root ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-12-05 17:56:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( simplified_path . contains_char ( ' / ' ) )  {  // In a subdirectory.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-23 12:39:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											Vector < String >  ds  =  simplified_path . get_base_dir ( ) . split ( " / " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											for  ( int  j  =  0 ;  j  <  ds . size ( ) ;  j + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												if  ( ! cd - > subdirs . has ( ds [ j ] ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													PackedDir  * pd  =  memnew ( PackedDir ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													pd - > name  =  ds [ j ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													pd - > parent  =  cd ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													cd - > subdirs [ pd - > name ]  =  pd ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													cd  =  pd ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													cd  =  cd - > subdirs [ ds [ j ] ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-22 15:03:05 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										String  filename  =  simplified_path . get_file ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-23 12:39:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// Don't add as a file if the path points to a directory.
 
							 
						 
					
						
							
								
									
										
										
										
											2020-12-15 12:04:21 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( ! filename . is_empty ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-03-18 14:04:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											cd - > files . insert ( filename ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-23 12:39:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  PackedData : : remove_path ( const  String  & p_path )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									String  simplified_path  =  p_path . simplify_path ( ) . trim_prefix ( " res:// " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									PathMD5  pmd5 ( simplified_path . md5_buffer ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( ! files . has ( pmd5 ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Search for directory.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									PackedDir  * cd  =  root ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-12-05 17:56:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( simplified_path . contains_char ( ' / ' ) )  {  // In a subdirectory.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-23 12:39:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										Vector < String >  ds  =  simplified_path . get_base_dir ( ) . split ( " / " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										for  ( int  j  =  0 ;  j  <  ds . size ( ) ;  j + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if  ( ! cd - > subdirs . has ( ds [ j ] ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												return ;  // Subdirectory does not exist, do not bother creating.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												cd  =  cd - > subdirs [ ds [ j ] ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									cd - > files . erase ( simplified_path . get_file ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									files . erase ( pmd5 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								void  PackedData : : add_pack_source ( PackSource  * p_source )  {  
						 
					
						
							
								
									
										
										
										
											2020-04-02 01:20:12 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( p_source  ! =  nullptr )  { 
							 
						 
					
						
							
								
									
										
										
										
											2015-05-06 20:37:25 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										sources . push_back ( p_source ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-19 15:46:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-17 12:48:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								uint8_t  * PackedData : : get_file_hash ( const  String  & p_path )  {  
						 
					
						
							
								
									
										
										
										
											2024-09-23 12:39:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									String  simplified_path  =  p_path . simplify_path ( ) . trim_prefix ( " res:// " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									PathMD5  pmd5 ( simplified_path . md5_buffer ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-17 12:48:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									HashMap < PathMD5 ,  PackedFile ,  PathMD5 > : : Iterator  E  =  files . find ( pmd5 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-23 12:39:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( ! E )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-17 12:48:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  E - > value . md5 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-23 12:39:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								HashSet < String >  PackedData : : get_file_paths ( )  const  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									HashSet < String >  file_paths ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									_get_file_paths ( root ,  root - > name ,  file_paths ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  file_paths ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  PackedData : : _get_file_paths ( PackedDir  * p_dir ,  const  String  & p_parent_dir ,  HashSet < String >  & r_paths )  const  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									for  ( const  String  & E  :  p_dir - > files )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										r_paths . insert ( p_parent_dir . path_join ( E ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									for  ( const  KeyValue < String ,  PackedDir  * >  & E  :  p_dir - > subdirs )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										_get_file_paths ( E . value ,  p_parent_dir . path_join ( E . key ) ,  r_paths ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-17 12:48:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  PackedData : : clear ( )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									files . clear ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									_free_packed_dirs ( root ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									root  =  memnew ( PackedDir ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								PackedData : : PackedData ( )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									singleton  =  this ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									root  =  memnew ( PackedDir ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									add_pack_source ( memnew ( PackedSourcePCK ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-04-20 19:38:02 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  PackedData : : _free_packed_dirs ( PackedDir  * p_dir )  {  
						 
					
						
							
								
									
										
										
										
											2021-08-09 14:13:42 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									for  ( const  KeyValue < String ,  PackedDir  * >  & E  :  p_dir - > subdirs )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										_free_packed_dirs ( E . value ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2015-04-20 19:38:02 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									memdelete ( p_dir ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								PackedData : : ~ PackedData ( )  {  
						 
					
						
							
								
									
										
										
										
											2024-08-09 03:33:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( singleton  = =  this )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										singleton  =  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-04-20 19:38:02 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									for  ( int  i  =  0 ;  i  <  sources . size ( ) ;  i + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										memdelete ( sources [ i ] ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									_free_packed_dirs ( root ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								//////////////////////////////////////////////////////////////////
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-03-26 18:51:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								bool  PackedSourcePCK : : try_open_pack ( const  String  & p_path ,  bool  p_replace_files ,  uint64_t  p_offset )  {  
						 
					
						
							
								
									
										
										
										
											2022-03-23 11:08:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									Ref < FileAccess >  f  =  FileAccess : : open ( p_path ,  FileAccess : : READ ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( f . is_null ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										return  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-20 11:28:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									bool  pck_header_found  =  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-13 11:22:06 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-20 11:28:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// Search for the header at the start offset - standalone PCK file.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									f - > seek ( p_offset ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									uint32_t  magic  =  f - > get_32 ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-20 11:28:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( magic  = =  PACK_HEADER_MAGIC )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										pck_header_found  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-20 11:28:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// Search for the header in the executable "pck" section - self contained executable.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( ! pck_header_found )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Loading with offset feature not supported for self contained exe files.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( p_offset  ! =  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											ERR_FAIL_V_MSG ( false ,  " Loading self-contained executable with offset not supported. " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-13 11:22:06 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-20 11:28:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										int64_t  pck_off  =  OS : : get_singleton ( ) - > get_embedded_pck_offset ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( pck_off  ! =  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											// Search for the header, in case PCK start and section have different alignment.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											for  ( int  i  =  0 ;  i  <  8 ;  i + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												f - > seek ( pck_off ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												magic  =  f - > get_32 ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												if  ( magic  = =  PACK_HEADER_MAGIC )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# ifdef DEBUG_ENABLED 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													print_verbose ( " PCK header found in executable pck section, loading from offset 0x "  +  String : : num_int64 ( pck_off  -  4 ,  16 ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# endif 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													pck_header_found  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												pck_off + + ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-20 11:28:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-20 11:28:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// Search for the header at the end of file - self contained executable.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( ! pck_header_found )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Loading with offset feature not supported for self contained exe files.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( p_offset  ! =  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											ERR_FAIL_V_MSG ( false ,  " Loading self-contained executable with offset not supported. " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-20 11:28:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										f - > seek_end ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										f - > seek ( f - > get_position ( )  -  4 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										magic  =  f - > get_32 ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-20 11:28:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( magic  = =  PACK_HEADER_MAGIC )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											f - > seek ( f - > get_position ( )  -  12 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											uint64_t  ds  =  f - > get_64 ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											f - > seek ( f - > get_position ( )  -  ds  -  8 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											magic  =  f - > get_32 ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if  ( magic  = =  PACK_HEADER_MAGIC )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# ifdef DEBUG_ENABLED 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												print_verbose ( " PCK header found at the end of executable, loading from offset 0x "  +  String : : num_int64 ( f - > get_position ( )  -  4 ,  16 ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# endif 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												pck_header_found  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-20 11:28:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( ! pck_header_found )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-02-10 21:58:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									int64_t  pck_start_pos  =  f - > get_position ( )  -  4 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-25 19:11:06 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// Read header.
 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-15 02:01:39 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									uint32_t  version  =  f - > get_32 ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									uint32_t  ver_major  =  f - > get_32 ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									uint32_t  ver_minor  =  f - > get_32 ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-25 19:11:06 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									uint32_t  ver_patch  =  f - > get_32 ( ) ;  // Not used for validation.
 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-25 19:11:06 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ERR_FAIL_COND_V_MSG ( version  ! =  PACK_FORMAT_VERSION_V3  & &  version  ! =  PACK_FORMAT_VERSION_V2 ,  false ,  vformat ( " Pack version unsupported: %d. " ,  version ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ERR_FAIL_COND_V_MSG ( ver_major  >  GODOT_VERSION_MAJOR  | |  ( ver_major  = =  GODOT_VERSION_MAJOR  & &  ver_minor  >  GODOT_VERSION_MINOR ) ,  false ,  vformat ( " Pack created with a newer version of the engine: %d.%d.%d. " ,  ver_major ,  ver_minor ,  ver_patch ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-04-28 20:51:29 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									uint32_t  pack_flags  =  f - > get_32 ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									bool  enc_directory  =  ( pack_flags  &  PACK_DIR_ENCRYPTED ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-25 19:11:06 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									bool  rel_filebase  =  ( pack_flags  &  PACK_REL_FILEBASE ) ;  // Note: Always enabled for V3.
 
							 
						 
					
						
							
								
									
										
										
										
											2025-02-20 11:08:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									bool  sparse_bundle  =  ( pack_flags  &  PACK_SPARSE_BUNDLE ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-04-28 20:51:29 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-25 19:11:06 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									uint64_t  file_base  =  f - > get_64 ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( ( version  = =  PACK_FORMAT_VERSION_V3 )  | |  ( version  = =  PACK_FORMAT_VERSION_V2  & &  rel_filebase ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										file_base  + =  pck_start_pos ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-25 19:11:06 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( version  = =  PACK_FORMAT_VERSION_V3 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// V3: Read directory offset and skip reserved part of the header.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										uint64_t  dir_offset  =  f - > get_64 ( )  +  pck_start_pos ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										f - > seek ( dir_offset ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}  else  if  ( version  = =  PACK_FORMAT_VERSION_V2 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// V2: Directory directly after the header.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										for  ( int  i  =  0 ;  i  <  16 ;  i + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											f - > get_32 ( ) ;  // Reserved.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2024-02-10 21:58:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-25 19:11:06 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// Read directory.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									int  file_count  =  f - > get_32 ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-04-28 20:51:29 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( enc_directory )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-23 11:08:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										Ref < FileAccessEncrypted >  fae ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										fae . instantiate ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										ERR_FAIL_COND_V_MSG ( fae . is_null ( ) ,  false ,  " Can't open encrypted pack directory. " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-04-28 20:51:29 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										Vector < uint8_t >  key ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										key . resize ( 32 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										for  ( int  i  =  0 ;  i  <  key . size ( ) ;  i + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											key . write [ i ]  =  script_encryption_key [ i ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										Error  err  =  fae - > open_and_parse ( f ,  key ,  FileAccessEncrypted : : MODE_READ ,  false ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-23 11:08:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										ERR_FAIL_COND_V_MSG ( err ,  false ,  " Can't open encrypted pack directory. " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-04-28 20:51:29 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										f  =  fae ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									for  ( int  i  =  0 ;  i  <  file_count ;  i + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										uint32_t  sl  =  f - > get_32 ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										CharString  cs ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-05-28 20:33:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										cs . resize_uninitialized ( sl  +  1 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										f - > get_buffer ( ( uint8_t  * ) cs . ptr ( ) ,  sl ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										cs [ sl ]  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-03-30 19:56:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										String  path  =  String : : utf8 ( cs . ptr ( ) ,  sl ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-23 12:39:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										uint64_t  ofs  =  f - > get_64 ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										uint64_t  size  =  f - > get_64 ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-13 18:03:28 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										uint8_t  md5 [ 16 ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										f - > get_buffer ( md5 ,  16 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-04-28 20:51:29 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										uint32_t  flags  =  f - > get_32 ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-09-23 12:39:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( flags  &  PACK_FILE_REMOVAL )  {  // The file was removed.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											PackedData : : get_singleton ( ) - > remove_path ( path ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2025-02-20 11:08:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											PackedData : : get_singleton ( ) - > add_path ( p_path ,  path ,  file_base  +  ofs ,  size ,  md5 ,  this ,  p_replace_files ,  ( flags  &  PACK_FILE_ENCRYPTED ) ,  sparse_bundle ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-23 12:39:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-19 15:46:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-19 15:46:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-23 11:08:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Ref < FileAccess >  PackedSourcePCK : : get_file ( const  String  & p_path ,  PackedData : : PackedFile  * p_file )  {  
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									return  memnew ( FileAccessPack ( p_path ,  * p_file ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-19 15:46:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//////////////////////////////////////////////////////////////////
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-04-09 10:31:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								bool  PackedSourceDirectory : : try_open_pack ( const  String  & p_path ,  bool  p_replace_files ,  uint64_t  p_offset )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Load with offset feature only supported for PCK files.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ERR_FAIL_COND_V_MSG ( p_offset  ! =  0 ,  false ,  " Invalid PCK data. Note that loading files with a non-zero offset isn't supported with directories. " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( p_path  ! =  " res:// " )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									add_directory ( p_path ,  p_replace_files ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Ref < FileAccess >  PackedSourceDirectory : : get_file ( const  String  & p_path ,  PackedData : : PackedFile  * p_file )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Ref < FileAccess >  ret  =  FileAccess : : create_for_path ( p_path ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ret - > reopen ( p_path ,  FileAccess : : READ ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  ret ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  PackedSourceDirectory : : add_directory ( const  String  & p_path ,  bool  p_replace_files )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Ref < DirAccess >  da  =  DirAccess : : open ( p_path ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( da . is_null ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									da - > set_include_hidden ( true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									for  ( const  String  & file_name  :  da - > get_files ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										String  file_path  =  p_path . path_join ( file_name ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										uint8_t  md5 [ 16 ]  =  {  0 ,  0 ,  0 ,  0 ,  0 ,  0 ,  0 ,  0 ,  0 ,  0 ,  0 ,  0 ,  0 ,  0 ,  0 ,  0  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2025-02-20 11:08:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										PackedData : : get_singleton ( ) - > add_path ( p_path ,  file_path ,  0 ,  0 ,  md5 ,  this ,  p_replace_files ,  false ,  false ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-09 10:31:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									for  ( const  String  & sub_dir_name  :  da - > get_directories ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										String  sub_dir_path  =  p_path . path_join ( sub_dir_name ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										add_directory ( sub_dir_path ,  p_replace_files ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//////////////////////////////////////////////////////////////////
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-05 13:01:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Error  FileAccessPack : : open_internal ( const  String  & p_path ,  int  p_mode_flags )  {  
						 
					
						
							
								
									
										
										
										
											2023-04-18 10:20:48 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ERR_PRINT ( " Can't open pack-referenced file. " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									return  ERR_UNAVAILABLE ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								bool  FileAccessPack : : is_open ( )  const  {  
						 
					
						
							
								
									
										
										
										
											2022-04-12 10:12:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( f . is_valid ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  f - > is_open ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-03-26 18:51:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  FileAccessPack : : seek ( uint64_t  p_position )  {  
						 
					
						
							
								
									
										
										
										
											2022-04-12 10:12:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ERR_FAIL_COND_MSG ( f . is_null ( ) ,  " File must be opened before use. " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if  ( p_position  >  pf . size )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										eof  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										eof  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-04-28 20:51:29 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									f - > seek ( off  +  p_position ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-04-28 21:56:43 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									pos  =  p_position ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2020-05-14 14:29:06 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								void  FileAccessPack : : seek_end ( int64_t  p_position )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									seek ( pf . size  +  p_position ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2020-05-14 14:29:06 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-03-26 18:51:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								uint64_t  FileAccessPack : : get_position ( )  const  {  
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									return  pos ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2020-05-14 14:29:06 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-05-25 07:58:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								uint64_t  FileAccessPack : : get_length ( )  const  {  
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									return  pf . size ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								bool  FileAccessPack : : eof_reached ( )  const  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  eof ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-03-26 18:51:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								uint64_t  FileAccessPack : : get_buffer ( uint8_t  * p_dst ,  uint64_t  p_length )  const  {  
						 
					
						
							
								
									
										
										
										
											2022-04-12 10:12:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ERR_FAIL_COND_V_MSG ( f . is_null ( ) ,  - 1 ,  " File must be opened before use. " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-16 22:55:11 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ERR_FAIL_COND_V ( ! p_dst  & &  p_length  >  0 ,  - 1 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-09 02:37:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( eof )  { 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										return  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-03-26 18:51:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									int64_t  to_read  =  p_length ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if  ( to_read  +  pos  >  pf . size )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										eof  =  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-03-26 18:51:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										to_read  =  ( int64_t ) pf . size  -  ( int64_t ) pos ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-12-10 16:21:16 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									pos  + =  to_read ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( to_read  < =  0 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										return  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									f - > get_buffer ( p_dst ,  to_read ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  to_read ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-05-20 14:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  FileAccessPack : : set_big_endian ( bool  p_big_endian )  {  
						 
					
						
							
								
									
										
										
										
											2022-04-12 10:12:40 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ERR_FAIL_COND_MSG ( f . is_null ( ) ,  " File must be opened before use. " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-05-20 14:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									FileAccess : : set_big_endian ( p_big_endian ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									f - > set_big_endian ( p_big_endian ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Error  FileAccessPack : : get_error ( )  const  {  
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( eof )  { 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										return  ERR_FILE_EOF ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									return  OK ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-09-22 12:56:02 +07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  FileAccessPack : : flush ( )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ERR_FAIL ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-06-15 21:21:43 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								bool  FileAccessPack : : store_buffer ( const  uint8_t  * p_src ,  uint64_t  p_length )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ERR_FAIL_V ( false ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								bool  FileAccessPack : : file_exists ( const  String  & p_name )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-02-16 15:25:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  FileAccessPack : : close ( )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									f  =  Ref < FileAccess > ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-02-20 11:08:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								FileAccessPack : : FileAccessPack ( const  String  & p_path ,  const  PackedData : : PackedFile  & p_file )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									pf  =  p_file ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( pf . bundle )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										String  simplified_path  =  p_path . simplify_path ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										f  =  FileAccess : : open ( simplified_path ,  FileAccess : : READ  |  FileAccess : : SKIP_PACK ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										off  =  0 ;  // For the sparse pack offset is always zero.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										f  =  FileAccess : : open ( pf . pack ,  FileAccess : : READ ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										f - > seek ( pf . offset ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										off  =  pf . offset ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2019-08-14 20:57:49 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-02-20 11:08:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ERR_FAIL_COND_MSG ( f . is_null ( ) ,  vformat ( " Can't open pack-referenced file '%s'. " ,  String ( pf . pack ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-04-28 20:51:29 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( pf . encrypted )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-23 11:08:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										Ref < FileAccessEncrypted >  fae ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										fae . instantiate ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-11 16:17:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										ERR_FAIL_COND_MSG ( fae . is_null ( ) ,  vformat ( " Can't open encrypted pack-referenced file '%s'. " ,  String ( pf . pack ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-04-28 20:51:29 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										Vector < uint8_t >  key ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										key . resize ( 32 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										for  ( int  i  =  0 ;  i  <  key . size ( ) ;  i + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											key . write [ i ]  =  script_encryption_key [ i ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										Error  err  =  fae - > open_and_parse ( f ,  key ,  FileAccessEncrypted : : MODE_READ ,  false ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-11 16:17:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										ERR_FAIL_COND_MSG ( err ,  vformat ( " Can't open encrypted pack-referenced file '%s'. " ,  String ( pf . pack ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-04-28 20:51:29 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										f  =  fae ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										off  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									pos  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									eof  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//////////////////////////////////////////////////////////////////////////////////
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// DIR ACCESS
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//////////////////////////////////////////////////////////////////////////////////
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-01-14 09:16:41 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Error  DirAccessPack : : list_dir_begin ( )  {  
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									list_dirs . clear ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									list_files . clear ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-08-09 14:13:42 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									for  ( const  KeyValue < String ,  PackedData : : PackedDir  * >  & E  :  current - > subdirs )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										list_dirs . push_back ( E . key ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-05-18 17:43:40 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									for  ( const  String  & E  :  current - > files )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										list_files . push_back ( E ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-01-14 09:16:41 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  OK ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								String  DirAccessPack : : get_next ( )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( list_dirs . size ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										cdir  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										String  d  =  list_dirs . front ( ) - > get ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										list_dirs . pop_front ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  d ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}  else  if  ( list_files . size ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										cdir  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										String  f  =  list_files . front ( ) - > get ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										list_files . pop_front ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  f ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  String ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2020-05-14 14:29:06 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								bool  DirAccessPack : : current_is_dir ( )  const  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  cdir ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2020-05-14 14:29:06 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-03-21 18:33:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								bool  DirAccessPack : : current_is_hidden ( )  const  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2020-05-14 14:29:06 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								void  DirAccessPack : : list_dir_end ( )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									list_dirs . clear ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									list_files . clear ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								int  DirAccessPack : : get_drive_count ( )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2020-05-14 14:29:06 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								String  DirAccessPack : : get_drive ( int  p_drive )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  " " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-01-08 22:36:19 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								PackedData : : PackedDir  * DirAccessPack : : _find_dir ( const  String  & p_dir )  {  
						 
					
						
							
								
									
										
										
										
											2024-05-28 12:15:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									String  nd  =  p_dir . replace_char ( ' \\ ' ,  ' / ' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-27 12:06:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Special handling since simplify_path() will forbid it
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( p_dir  = =  " .. " )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  current - > parent ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									bool  absolute  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( nd . begins_with ( " res:// " ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										nd  =  nd . replace_first ( " res:// " ,  " " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										absolute  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									nd  =  nd . simplify_path ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-09 03:42:46 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( nd . is_empty ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-09-03 19:35:42 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										nd  =  " . " ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2016-09-03 19:35:42 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if  ( nd . begins_with ( " / " ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										nd  =  nd . replace_first ( " / " ,  " " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										absolute  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Vector < String >  paths  =  nd . split ( " / " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									PackedData : : PackedDir  * pd ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( absolute )  { 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										pd  =  PackedData : : get_singleton ( ) - > root ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										pd  =  current ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-14 16:41:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									for  ( int  i  =  0 ;  i  <  paths . size ( ) ;  i + + )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-18 17:40:56 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										const  String  & p  =  paths [ i ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										if  ( p  = =  " . " )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										}  else  if  ( p  = =  " .. " )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if  ( pd - > parent )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												pd  =  pd - > parent ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										}  else  if  ( pd - > subdirs . has ( p ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											pd  =  pd - > subdirs [ p ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-27 12:06:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-27 12:06:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  pd ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-27 12:06:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Error  DirAccessPack : : change_dir ( String  p_dir )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									PackedData : : PackedDir  * pd  =  _find_dir ( p_dir ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( pd )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										current  =  pd ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  OK ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  ERR_INVALID_PARAMETER ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-23 11:08:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								String  DirAccessPack : : get_current_dir ( bool  p_include_drive )  const  {  
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									PackedData : : PackedDir  * pd  =  current ; 
							 
						 
					
						
							
								
									
										
										
										
											2017-05-04 02:20:53 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									String  p  =  current - > name ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-05-04 02:20:53 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									while  ( pd - > parent )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										pd  =  pd - > parent ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-29 19:34:01 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										p  =  pd - > name . path_join ( p ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  " res:// "  +  p ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								bool  DirAccessPack : : file_exists ( String  p_file )  {  
						 
					
						
							
								
									
										
										
										
											2020-07-27 12:06:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									PackedData : : PackedDir  * pd  =  _find_dir ( p_file . get_base_dir ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( ! pd )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  pd - > files . has ( p_file . get_file ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-05-25 11:34:51 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								bool  DirAccessPack : : dir_exists ( String  p_dir )  {  
						 
					
						
							
								
									
										
										
										
											2020-07-27 12:06:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  _find_dir ( p_dir )  ! =  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-05-25 11:34:51 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								Error  DirAccessPack : : make_dir ( String  p_dir )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  ERR_UNAVAILABLE ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Error  DirAccessPack : : rename ( String  p_from ,  String  p_to )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  ERR_UNAVAILABLE ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2020-05-14 14:29:06 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								Error  DirAccessPack : : remove ( String  p_name )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  ERR_UNAVAILABLE ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-03-26 18:51:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								uint64_t  DirAccessPack : : get_space_left ( )  {  
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									return  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-01-21 15:23:08 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								String  DirAccessPack : : get_filesystem_type ( )  const  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  " PCK " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 22:10:30 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								DirAccessPack : : DirAccessPack ( )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									current  =  PackedData : : get_singleton ( ) - > root ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}