Editing PlayStation archive (PSARC)

Jump to navigation Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 1: Line 1:
=Description=
=Description=
'''P'''lay'''S'''tation '''ARC'''hive is a generic file container that uses an internal hierarchy of subfolders with defined access paths, and optional zlib or lzma per-file compression
'''P'''lay'''S'''tation '''ARC'''hive is a container that allows subfolders and per-file compression using zlib or lzma with 9 available compression levels (but in the practise only level 0 or 9 are used)


 
*Notes:
The access paths are stored in a special file generated at build time called '''manifest''', It mimics a standard tree structure of folders/files but the root of the hierarchy is not defined, this way the contents of the psarc can be "mounted" by the system/game as part of his filesystem at any place and under any device letter/name
**Compression level 9 has a compression ratio of around 50% of the original size for general file types, this ratio is variable for every file type
 
**Some file types doesnt admits much compression like audio and videos because are compressed originally (as example, max compression ratio for .BIK video and .MP3 audio when added inside a .psarc doesnt reachs 1% or 2%). For this reason is better to dont use compression with them because the size reduction is ridiculous
There are 3 different methods to generate this paths that defines how the .psarc contents are mounted by the system/game, this methods are enabled by the '''archive flags''' stored in the header, the system/game knows how to recreate the filesystem paths and mounts the .psarc contents by reading the '''archive flags''' that are needed to process the access paths in the '''manifest'''
**Very small files (smaller than 100 bytes or so) as well as dummy files (0 bytes) doesnt admits compression, they will be stored as "not compressed" inside the .psarc archive
 
 
The compression algorithms, the PS3 system, and the .psarc format, allows for 9 compression levels but in the practise only are used level 0 (no compression) or 9 (max compression used as the default compression level)
 
Compression level 9 for generic file types results as a compression ratio of around 50% of the original size, the final compression ratio can vary for different types of files, usually multimedia files (video, audio, etc) doesnt admits much compression because are already compressed originally (as example, max compression ratio for .BIK video and .MP3 audio doesnt reachs 1% or 2%). For this reason is better to dont compress multimedia files because the size reduction is ridiculous and read access times can be reduced (causing a delay/lag/freeze when trying to load the file)
 
Very small files (smaller than 100 bytes or so) as well as dummy files (0 bytes) doesnt admits compression because are so small that the compression algorithm is not able to reduce them, they will be stored without compression inside the .psarc archive even when is applyed compression over them. When listing the contents of a .psarc with this kind of files will be displayed with a percentage of 100% and both his compressed and decompressed sizes the same value
 
<small>
{{Zlib Header}}
</small>


=Structure=
=Structure=
See: debian psarc Kplugin structure. From Manuel Stahl (thymythos) @ http://opendesktop.org/content/show.php/PSARC+file+header?content=162745
See {{Talk}} page
 
==Header==
==Header==
PSARC header example:
PSARC header example:


  '''Offset(h) 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F'''
  '''Offset(h) 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F'''
  00000000  <span style="background:#ff6666;">50 53 41 52</span> <span style="background:#66ff66;">00 01 00 04</span> <span style="background:#ffff66;">7A 6C 69 62</span> <span style="background:#6666ff;">00 01 23 BA</span>  <span style="background:#ff6666;">PSAR</span>....<span style="background:#ffff66;">zlib</span>..#º
  00000000  <span style="background:#ff6666;">50 53 41 52</span> <span style="background:#66ff66;">00 01 00 04</span> <span style="background:#ffff66;">7A 6C 69 62</span> <span style="background:#6666ff;">00 01 23 BA</span>  PSAR....zlib..#º
  00000010  <span style="background:#dd00dd;">00 00 00 1E</span> <span style="background:#dddd00;">00 00 09 16</span> <span style="background:#dddddd;">00 01 00 00</span> <span style="background:#d0000d;">00 00 00 02</span>  ................
  00000010  <span style="background:#dd00dd;">00 00 00 1E</span> <span style="background:#dddd00;">00 00 09 16</span> <span style="background:#dddddd;">00 01 00 00</span> <span style="background:#d0000d;">00 00 00 02</span>  ................


Line 32: Line 20:
! Offset !! Size !! Name !! Example !! Value (conversion) !! Notes
! Offset !! Size !! Name !! Example !! Value (conversion) !! Notes
|+PSARC Header
|+PSARC Header
| style="background-color:#ff6666;" | 0x00 || style="background-color:#ff6666;" | 0x04 || '''magic''' || 50 53 41 52 || PSAR || '''P'''lay'''S'''tation '''AR'''chive
| style="background-color:#ff6666;" | 0x00 || style="background-color:#ff6666;" | 0x04 || '''magic''' || 50 53 41 52 || PSAR || '''P'''lay'''S'''tation '''Ar'''chive
|-
|-
| style="background-color:#66ff66;" | 0x04 || style="background-color:#66ff66;" | 0x04 || '''version''' || 00 01 00 04 || v1.4 || First 2 bytes is the '''major version''', next 2 bytes is the '''minor version'''
| style="background-color:#66ff66;" | 0x04 || style="background-color:#66ff66;" | 0x04 || '''version''' || 00 01 00 04 || v1.4 || First 2 bytes is the main version, next 2 bytes is the subversion and are processed separatedlly, so 0001.0004 is "translated" to 1.4 by the system
|-
|-
| style="background-color:#ffff66;" | 0x08 || style="background-color:#ffff66;" | 0x04 || '''compression_type''' || 7A 6C 69 62 || zlib || '''zlib''' (default)<br>'''lzma'''
| style="background-color:#ffff66;" | 0x08 || style="background-color:#ffff66;" | 0x04 || '''compression type''' || 7A 6C 69 62 || zlib || zlib (default) or lzma
|-
|-
| style="background-color:#6666ff;" | 0x0C || style="background-color:#6666ff;" | 0x04 || '''toc_length''' || 00 01 23 BA || 0x123BA || Includes 32 byte header length + block length table following ToC
| style="background-color:#6666ff;" | 0x0C || style="background-color:#6666ff;" | 0x04 || '''table of content length''' || 00 01 23 BA || 0x123BA ||  
|-
|-
| style="background-color:#dd00dd;" | 0x10 || style="background-color:#dd00dd;" | 0x04 || '''toc_entry_size''' || 00 00 00 1E || 30 Bytes || Default is 30 bytes
| style="background-color:#dd00dd;" | 0x10 || style="background-color:#dd00dd;" | 0x04 || '''table of content entries size''' || 00 00 00 1E || 30 Bytes || Default is 30 bytes
|-
|-
| style="background-color:#dddd00;" | 0x14 || style="background-color:#dddd00;" | 0x04 || '''toc_entries''' || 00 00 09 16 || 1 manifest + 2325 files || The '''manifest''' is always included as the first file in the archive without an assigned ID
| style="background-color:#dddd00;" | 0x14 || style="background-color:#dddd00;" | 0x04 || '''number of entries''' || 00 00 09 16 || 1+2325 files || The filecount includes the "file path/names definitions" as an additionall file always placed at first position in the list and without an assigned ID
|-
|-
| style="background-color:#dddddd;" | 0x18 || style="background-color:#dddddd;" | 0x04 || '''block_size''' || 00 01 00 00 || 65536 Bytes || Default is 65536 bytes
| style="background-color:#dddddd;" | 0x18 || style="background-color:#dddddd;" | 0x04 || '''block size''' || 00 01 00 00 || 65536 Bytes || Default is 65536 Bytes
|-
|-
| style="background-color:#d0000d;" | 0x1C || style="background-color:#d0000d;" | 0x04 || '''archive_flags''' || 00 00 00 02 || Absolute paths || 0 = '''relative''' paths (default)<br>1 = '''ignorecase''' paths<br>2 = '''absolute''' paths
| style="background-color:#d0000d;" | 0x1C || style="background-color:#d0000d;" | 0x04 || '''archive flags''' || 00 00 00 02 || Absolute paths || Default is 0. See table below
|}
|}


*'''Relative''' (default, no flags)
PSARC Archive Flags are stored in the header as a big endian number, and defines the characteristics and structure of the archive when it was created
**Default value when the .psarc is created from command line or an .xml and no special access paths modes are specifyed
**The paths in the '''manifest''' doesnt have an slash character at the start of every line, the system accesses the files exactly like if the .psarc was a folder itself
**e.g: '''Folder/File.bin"'''
**In the games that uses .psarc's without flags (like ''uncharted'' series or ''the last of us'') is posible to replace the psarc by a folder with the same name of the psarc and his contents decompressed inside
 
*'''Ignorecase''' flag
**Enabled by using the option '''--ignorecase''' in command line or '''ignorecase="true"''' in the .xml
**The paths in the '''manifest''' are case insensitive (doesnt matters wich characters are in capitals)
 
*'''Absolute''' flag
**Enabled by using the option '''--absolute''' in command line or '''absolute="true"''' in the .xml
**The paths in the '''manifest''' have an slash character at the start of every line, <!-- the .psarc contents are mounted directly in the root of the application space (under USRDIR)... this is hidden because is a bit speculative, im not so sure but this is what it looks -->
**e.g: '''/Folder/File.bin"'''
 
==TOC Table==
 
PSARC TOC example:
 
'''Offset(h) 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F'''
00000020  <span style="background:#ff6666;">00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00</span>  ................
00000030  <span style="background:#66ff66;">00 00 00 00</span> <span style="background:#6666ff;">00 00 01 79 D9</span> <span style="background:#66ffff;">00 00 01 23 BA</span> A9 A6  .......yÙ...#º©¦
00000040  AB EE E6 73 40 2A E6 C3 37 24 3F C1 81 16 00 00  «îæs@*æÃ7$?Á....
00000050  00 02 00 00 00 1D 90 00 00 01 45 3B 5A 08 E7 AC  ..........E;Z.ç¬
...
 
{| class="wikitable"
{| class="wikitable"
|+PSARC Archive Flags
! Hexadecimal<br />(big endian) !! Decimal !! Binary<br />(flags) !! Flag Name !! Notes
|-
|-
! Offset !! Size !! Name !! Example !! Value (conversion) !! Notes
| {{cellcolors|black|lime}} 00 00 00 00 || style="text-align:right;" | 0 || 00000000 00000000 00000000 00000000 || '''relative archive paths''' (no slash character at the start of every line) || default value when using command line or xml
|+PSARC TOC
| style="background-color:#ff6666;" | 0x20 || style="background-color:#ff6666;" | 0x10 || '''name digest''' || 00 00 ... 00 00  || - || 128-bit md5 hash
|-
|-
| style="background-color:#66ff66;" | 0x30 || style="background-color:#66ff66;" | 0x04 || '''block offset''' || 00 00 00 00 || 0 || Offset in block list.
| {{cellcolors|black|lime}} 00 00 00 01 || style="text-align:right;" | 1 || 00000000 00000000 00000000 00000001 || '''ignorecase archive paths''' (all characters in capitals) || same than --ignorecase in command line and ignorecase="true" in the xml
|-
|-
| style="background-color:#6666ff;" | 0x34 || style="background-color:#6666ff;" | 0x05 || '''uncompressed size''' || 00 00 01 79 D9 || 96729 || Size of this entry once uncompressed.
| {{cellcolors|black|lime}} 00 00 00 02 || style="text-align:right;" | 2 || 00000000 00000000 00000000 00000010 || '''absolute archive paths''' (slash character added at the start of every line) || same than --absolute in command line and absolute="true" in xml
|-
| style="background-color:#66ffff;" | 0x39 || style="background-color:#66ffff;" | 0x05 || '''file offset''' ||00 00 01 23 BA || 74682 || Byte offset in psarc for this entry.
|}
|}


    <array name="TOC" length="num_entries">
==TOC Table==
      <struct name="entry">
        <array name="MD5" length="16"><primitive type="UInt8"/></array>
        <primitive name="zIndex" type="UInt32" />
        <bitfield name="length" width="40" type="unsigned" />
        <bitfield name="offset" width="40" type="unsigned" />
      </struct>
    </array>


==Blocks info table==
==Blocks info table==
    <array name="block sizes" length="num_entries">
      <bitfield name="size" width="16" type="unsigned" />
    </array>


==File table==
==File table==
The compression is applyed "per-block", is posible to know the compression level by looking at the zlib header
The compression is applyed "per-block", is posible to know the compression level by looking at the zlib header
 
<small>
===Manifest===
{{Zlib Header}}
Manifest is the first file inside the psarc filetable, doesnt appears as a file when using the '''--list''' command and doesnt have an assigned '''ID'''
</small>
 
In windows all the paths uses the slash "\" but when the psarc is created the paths are stored inside the manifest as "/". When making a '''--list''' command over a psarc the slashes will appear as "/"
 
To make things more generic all examples in wiki uses full PC paths, this allows to place the sources (files to create, or psarc to extract), targets (files to create, or psarc to extract), and psarc.exe in any path of the PC, using full paths makes needed the use of the "strip" option in all creation process to remove part of the PC path and device letter from the access paths stored in the '''manifest'''


=PSARC Tools=
=PSARC Tools=
Line 118: Line 64:
GUI versions are derivated from the command line versions
GUI versions are derivated from the command line versions


==Open PSARC PS3 Extractor==
==Command line versions==
===Open PSARC PS3 Extractor===
By Matthieu Milan. It allows you to extract PSARC archive data in linux
By Matthieu Milan. It allows you to extract PSARC archive data in linux


Source code: https://www.ferb.fr/ps3/PSARC/
Source code: https://www.ferb.fr/ps3/PSARC/


==PSARC tool==
===PSARC tool===
Port of Matthieu Milan's open PSARC PS3 extractor to Windows. Tool written by Matthieu Milan (@usineur). Ported to VS2012 by AlexAltea.
Port of Matthieu Milan's open PSARC PS3 extractor to Windows. Tool written by Matthieu Milan (@usineur). Ported to VS2012 by AlexAltea.


Line 136: Line 83:
   -e START END      Extracts files with the file id specified by the range between START and END (inclusive).
   -e START END      Extracts files with the file id specified by the range between START and END (inclusive).


==PSARC Extractor==
===PSARC Extractor===
{{Missingfiles}}
By Insomniac @ xentax forums, download link: http://www.ps3hax.net/downloads.php?do=file&id=452 and http://www.modcontrol.com/Board/pc-tools/28869-psarc-ps3-extractor.html
By Insomniac @ xentax forums, download link: <s>http://www.ps3hax.net/downloads.php?do=file&id=452</s> and <s>http://www.modcontrol.com/Board/pc-tools/28869-psarc-ps3-extractor.html</s>


  '''Usage:'''
  '''Usage:'''
Line 163: Line 109:
  3      | 3,30 KB    | /my/files/dummies/dummy3.bin
  3      | 3,30 KB    | /my/files/dummies/dummy3.bin


==PSARC==
===PSARC===
{{Missingfiles}}
  1.60.008 SDK : x
  1.60.008 SDK : x
  1.92.001 SDK : x
  1.92.001 SDK : x
Line 174: Line 119:
  4.50.001 SDK : psarc-1310.001 (C++), built on Nov 16 2011 at 03:31:36
  4.50.001 SDK : psarc-1310.001 (C++), built on Nov 16 2011 at 03:31:36


*From xentax forums: http://forum.xentax.com/viewtopic.php?p=44228&sid=0a7b5167ba4599f71f85471119c918a6#p44228 Download link: <s>http://www.mediafire.com/?o3wy35uublreh</s>
*From xentax forums: http://forum.xentax.com/viewtopic.php?p=44228&sid=0a7b5167ba4599f71f85471119c918a6#p44228 Download link: http://www.mediafire.com/?o3wy35uublreh


===help===
====help====
{{Keyboard|content=<syntaxhighlight lang="bash">
{{Keyboard|content=
C:\>psarc.exe --help
'''C:\Portables\psarc>psarc.exe --help'''
usage:
'''usage:'''
  psarc verb [options] [file...]
  psarc verb [options] [file...]
  psarc --xml=XMLFILE
  psarc --xml=XMLFILE
   
   
verbs:
'''verbs:'''
  create                                  Create an archive. (default)
  create                                  Create an archive. (default)
  extract                                Extract contents of an existing archive.
  extract                                Extract contents of an existing archive.
Line 191: Line 136:
  dtd                                    Display a DTD describing psarc's XML input syntax.
  dtd                                    Display a DTD describing psarc's XML input syntax.


general options:
'''general options:'''
  -h, --help                              Show this help message and exit.
  -h, --help                              Show this help message and exit.
     --version                          Display version and exit.
     --version                          Display version and exit.
Line 200: Line 145:
  --xml=XMLFILE                          XML list of actions to perform.
  --xml=XMLFILE                          XML list of actions to perform.


create options:
'''create options:'''
  -oFILE, --output=FILE                  Archive filename to create.
  -oFILE, --output=FILE                  Archive filename to create.
  -IINPUTFILE, --inputfile=INPUTFILE      Inputfile listing files to archive. Consider --xml instead, which gives you more control.
  -IINPUTFILE, --inputfile=INPUTFILE      Inputfile listing files to archive. Consider --xml instead, which gives you more control.
Line 219: Line 164:
  --mergedups                            Compare the content of all files, and merge identical files so that only one copy of the data is included.
  --mergedups                            Compare the content of all files, and merge identical files so that only one copy of the data is included.


extract options:
'''extract options:'''
  --input=FILE                            Archive to extract files from. (default is first file argument)
  --input=FILE                            Archive to extract files from. (default is first file argument)
  --to=DIRECTORY                          Directory to write extracted files to. (default is current directory)
  --to=DIRECTORY                          Directory to write extracted files to. (default is current directory)
</syntaxhighlight>}}
}}
 
====verify====
{{Keyboard|content=
'''C:\Portables\psarc>psarc.exe verify c:\psarctests\custom_folders.psarc'''
Verifying c:\psarctests\custom_folders.psarc
Validating 1: Folder1/Image1.bmp (6220854 bytes)
Validating 2: Folder2/Folder21/Image21.png (6142 bytes)
Validating 3: Folder3/Folder31/Folder311/Image311.jpg (12524 bytes)
Archive OK
}}
{| class="wikitable"
|+verify output per-file
|| Validating <file ID/number>: || file path inside psarc archive || (file original size in bytes)
|}
 
====list====
{{Keyboard|content=
'''C:\Portables\psarc>psarc.exe list c:\psarctests\custom_folders.psarc'''
Listing c:\psarctests\custom_folders.psarc
Folder1/Image1.bmp (6220854/6220854 100%)
Folder2/Folder21/Image21.png (157/6142 2%)
Folder3/Folder31/Folder311/Image311.jpg (209/12524 1%)
}}
{| class="wikitable"
|+list output per-file
|| file path inside psarc archive || (file compressed size || file original size || compression percentage)
|}
*Notes:
**In the compression percentage: 100% is no reduction, 0% is a huge reduction
 
{{Boxtip1|content=Is posible to generate a text file containing the output of the '''list''' command by using the '''>''' arrow and the path/name of the destination file, this is usefull to convert the generated file to a '''filelist.txt''' or an '''automated.xml''' for rebuilding the psarc archive later}}
 
{{Keyboard|content=
'''C:\Portables\psarc>psarc.exe list c:\psarctests\custom_folders.psarc > c:\psarctests\custom_folders_file_output.txt'''
}}
 
There is no output in the command line, instead the file '''c:\psarctests\custom_folders_file_output.txt''' is created containing:
Listing c:\psarctests\custom_folders.psarc
Folder1/Image1.bmp (6220854/6220854 100%)
Folder2/Folder21/Image21.png (157/6142 2%)
Folder3/Folder31/Folder311/Image311.jpg (209/12524 1%)


===dtd===
====dump====
* Display a DTD describing psarc's XML input syntax.
{{Keyboard|content=
'''C:\Portables\psarc>psarc.exe dump c:\psarctests\custom_folders.psarc'''
Dumping c:\psarctests\custom_folders.psarc
Folder1/Image1.bmp  os=6220854 cs=6220854 fb=2
Folder2/Folder21/Image21.png  os=6142 cs=157 fb=97
Folder3/Folder31/Folder311/Image311.jpg  os=12524 cs=209 fb=98
}}
{| class="wikitable"
|+dump output per-file
|| file path inside psarc archive || file original size || file compressed size || file block start offset ?
|}


====dtd====
The output of this command is a layout that defines the structure of an .xml document. See: http://www.w3schools.com/DTD/
The output of this command is a layout that defines the structure of an .xml document. See: http://www.w3schools.com/DTD/


{{Keyboard|content=<syntaxhighlight lang="DTD">
{{Keyboard|content=
C:\>psarc.exe dtd
'''C:\Portables\psarc>psarc.exe dtd'''<nowiki>
<!ELEMENT psarc (create|extract)+>
<!ELEMENT psarc (create|extract)+>


Line 283: Line 280:
                   skipmissingfiles (true|false) "false"
                   skipmissingfiles (true|false) "false"
                   overwrite (true|false) "false">
                   overwrite (true|false) "false">
</syntaxhighlight>}}
</nowiki>}}


*DTD Notes:
*DTD Notes:
Line 292: Line 289:
**Required attributes are defined with: '''#REQUIRED''', and optional attributes with: '''#IMPLIED'''
**Required attributes are defined with: '''#REQUIRED''', and optional attributes with: '''#IMPLIED'''


====Performing actions with an XML list====
Based in the DTD layout is posible to create an .xml layout that automatizes all the actions of the tool, this example is a generic layout containing all the elements and attributes availables together
Is posible to automatize the '''create''' and '''extract''' actions by using an .xml


Using an xml is the most flexible way to use psarc.exe because has full support for all features of the tool (command line doesnt), some of the options of the tool are only available when using an xml, specially per-file attributes like: per-file compression (used by lot of games), or per-file extraction
{{Boxcode|content=<syntaxhighlight lang="xml">
 
<?xml version="1.0" encoding="UTF-8"?>
To use an .xml is needed to prepare it based in this layout
{{Boxcode|title=This is the xml representation of the DTD layout containing all the elements and attributes availables together, for wiki purposes only|code=<syntaxhighlight lang=xml>
<psarc>
<psarc>
<create archive="" absolute="false" ignorecase="false" mergedups="false" stripall="false" blocksize="65536" jobs="" skipmissingfiles="false" format="psarc" overwrite="false">
<create archive="" absolute="false" ignorecase="false" mergedups="false" stripall="false" blocksize="65536" jobs="" skipmissingfiles="false" format="psarc" overwrite="false">
Line 313: Line 307:
</psarc>
</psarc>
</syntaxhighlight>}}
</syntaxhighlight>}}
*The purpose of this XML is to use it as a base layout containing all, but is not posible to use it like that, is needed to delete the tags that are not needed for a specific case, the ones that are incompatibles with other tags, and is needed to add paths, etc...
*Some attributes appears as common in the DTD for "create" and "extract" but are not common, some of them has been deleted to avoid mistakes... but probably is needed to delete some more


When the xml is ready you can run it this way:
*XML Notes:
{{Keyboard|content=<syntaxhighlight lang="bash">C:\>psarc.exe --xml=C:\DTD_Layout.xml</syntaxhighlight>}}
**The purpose of this XML is to use it as a base layout containing all, but is not posible to use it like that, is needed to delete the tags that are not needed for a specific case, the ones that are incompatibles with other tags, and is needed to add paths, etc...
**Some attributes appears as common in the DTD for "create" and "extract" but are not common, some of them has been deleted to avoid mistakes... but probably is needed to delete some more
**Is posible to generate this kind of .xml by using as the source the output of the "list" command after applying over it some character strings replacing using regular expressions with a tool like http://findandreplace.codeplex.com/#


The options '''--verbose''', '''--debug''', and '''--quiet''' cant be used inside the xml, so if needed are specifyed in the command line, this way:
====extract====
{{Keyboard|content=<syntaxhighlight lang="bash">C:\>psarc.exe --debug --xml=C:\DTD_Layout.xml</syntaxhighlight>}}
The required options are '''--input''' (the source .psarc) and '''--to''' (the target folder where contents will be extracted). The example command extracts all files from the .psarc to a directory with full directory tree names, no skipped missing files, no overwrite


===verify===
{{Keyboard|content=
*Verify an existing archive's structural integrity and ensure that all files can be decompressed.
'''C:\Portables\psarc>psarc.exe extract --input=c:\psarctests\custom_folders.psarc --to=c:\psarctests\custom_folders_extracted'''
*Output info per-file is: Validating <file ID/number>: - file path inside psarc archive - (file original size in bytes)
Extracting: Folder1/Image1.bmp (6220854 bytes)
Extracting: Folder2/Folder21/Image21.png (6142 bytes)
Extracting: Folder3/Folder31/Folder311/Image311.jpg (12524 bytes)
}}


{{Keyboard|content=<syntaxhighlight lang="bash">
*There are 3 optional available attributes for extract:
C:\>psarc.exe verify "C:\psarctests\source files\test.psarc"
**'''--overwrite''' (if the files existed in the extraction folder they will be overwritten without advise)
Verifying C:\psarctests\source files\test.psarc
**'''--strip-all''' (extracts all files in the root of the target folder, incase of several extracted files with the same name the program will return an error, this can be solved by using the command --overwrite)
Validating 1: dummy.txt (0 bytes)
**'''--skip-missing-files''' (seems pointless, mostly to extract files from malformed .psarcs or .psarcs that doesnt passes the "verify" command ?)
Validating 2: BMPfolder1/Image1.bmp (6220854 bytes)
Validating 3: JPGfolder1/JPGfolder2/Image2.jpg (12524 bytes)
Validating 4: PNGfolder1/PNGfolder2/PNGfolder3/Image3.png (6142 bytes)
Archive OK
</syntaxhighlight>}}


===dump===
When using this options the command line output is the same than in the example above, there is no mention of wich files are stripped, overwritten, or missing in the extraction process, usage example:
*Print detailed info about archive for unit testing.
{{Keyboard|content=
*Output info per-file is: file path inside psarc archive - file original size - file compressed size - file block start offset ?
'''C:\Portables\psarc>psarc.exe extract --overwrite --strip-all --skip-missing-files --input=c:\psarctests\custom_folders.psarc --to=c:\psarctests\custom_folders_extracted'''
 
Extracting: Folder1/Image1.bmp (6220854 bytes)
{{Keyboard|content=<syntaxhighlight lang="bash">
Extracting: Folder2/Folder21/Image21.png (6142 bytes)
C:\>psarc.exe dump "C:\psarctests\source files\test.psarc"
Extracting: Folder3/Folder31/Folder311/Image311.jpg (12524 bytes)
Dumping C:\psarctests\source files\test.psarc
dummy.txt  os=0 cs=0 fb=1
BMPfolder1/Image1.bmp  os=6220854 cs=8018 fb=2
JPGfolder1/JPGfolder2/Image2.jpg  os=12524 cs=209 fb=97
PNGfolder1/PNGfolder2/PNGfolder3/Image3.png  os=6142 cs=6142 fb=98
</syntaxhighlight>}}
 
===list===
*List contents of an existing archive.
*Output info per-file is: file path inside psarc archive - (file compressed size - file original size - compression percentage)
*In the compression percentage: 100% is no reduction, 0% is a huge reduction
 
{{Keyboard|content=<syntaxhighlight lang="bash">
C:\>psarc.exe list "C:\psarctests\source files\test.psarc"
Listing C:\psarctests\source files\test.psarc
dummy.txt (0/0 100%)
BMPfolder1/Image1.bmp (8018/6220854 0%)
JPGfolder1/JPGfolder2/Image2.jpg (209/12524 1%)
PNGfolder1/PNGfolder2/PNGfolder3/Image3.png (6142/6142 100%)
</syntaxhighlight>}}
 
{{Boxframe2|content=
{{Boxtip1|content=Is posible to generate a text file containing the output of the '''list''' command by using the character '''>''' (right arrow) and the path/name of the destination file, this is usefull to convert the generated file to a '''filelist.txt''' for rebuilding the psarc archive later}}
{{Keyboard|content=<syntaxhighlight lang="bash">C:\>psarc.exe list "C:\psarctests\source files\test.psarc" > c:\psarctests\filelist.txt</syntaxhighlight>}}
}}
}}


----
====create====
 
Ther are 3 different ways to create a psarc archive (by '''directory''', by '''filelist''', or by '''file'''). '''By directory''' creates the psarc using the contents of a specifyed folder and all subfolders, all them ordered alphabetically (windows style), this method cant be used to rebuild psarcs where every file needs to be assigned with an specific ID (and im not sure if is available in command line). '''By file''' means every path of every file in the PC is needed to be specifyed and this is not posible in command line when the archive has lot of files (for a single file is fine, but when are thousand of files is a no way). For this reason the only method explained here is '''by filelist'''
===create===
* Create an archive.


====create by directory====
The filelist is a plain .txt file where every file is defined by a single line, composed by his path, filename, and file extension, 1 line per file, in any order (not needed to be ordered alphabetically). Is posible to generate this kind of filelists automatically by using the output of the '''--list''' command and some regular expressions to replace characters (this is long explain and doesnt fits here by now)
Creates a psarc using the contents of a specifyed folder and all subfolders. Is only available when using an .xml because command line doesnt allows to specify a source folder


Is the most rude method to create a psarc because all folders and files will be archived alphabetically based in his names (there is no controll of the ID's that will be assigned to each file in the '''manifest'''). Cant be used to rebuild psarcs
As explained before, the examples used here in wiki uses full PC paths to be more flexible (no need to place psarc.exe next to the source folder, actually you can place psarc.exe in c:\ the source folder in d:\ and create the psarc in x:\). When using full paths is mandatory to use the '''--strip''' option with an explicit path or a regular expression (regex) to remove part of the PC path (e.g: if you strip '''psarctests\custom_folders_extracted\''' from '''c:\psarctests\custom_folders_extracted\Folder1\Image1.bmp''' the resulting path of the file inside the archive will be '''Folder1\Image1.bmp''')


Note in the next examle the file dummy.txt (located in the root of the folder in windows, so considered first) has been archived after BMPfolder1
In the next example the filelist is in '''c:\psarctests\custom_folders_filelist.txt''' and contains the PC paths of the files that will be included inside the psarc archive:
C:\psarctests\custom_folders_extracted\Folder1\Image1.bmp
C:\psarctests\custom_folders_extracted\Folder2\Folder21\Image21.png
C:\psarctests\custom_folders_extracted\Folder3\Folder31\Folder311\Image311.jpg


{{Boxcode|title=Create_by_directory.xml|code=<syntaxhighlight lang="xml">
The psarc archive is created by using the filelist as the '''--inputfile''' and uses an explicit path to '''--strip''' from every file inside the filelist
<psarc>
{{Keyboard|content=
<create archive="C:\psarctests\by_directory.psarc" absolute="false" ignorecase="false">
'''C:\Portables\psarc>psarc.exe create --strip=C:\psarctests\custom_folders_extracted\ --output=c:\psarctests\custom_folders.psarc --inputfile=c:\psarctests\custom_folders_filelist.txt'''
<compression type="zlib" enabled="true" />
Strip: c:\psarctests\custom_folders_extracted
<strip regex="C:\psarctests\source files\test" />
<directory path="C:\psarctests\source files\test" />
</create>
</psarc>
</syntaxhighlight>}}
{{Keyboard|content=<syntaxhighlight lang="bash">
C:\>psarc.exe --xml="c:\psarctests\CREATE by_directory.xml"
Strip: C:\psarctests\source files\test
Flags: relative
Flags: relative
NumJobs: 2
NumJobs: 2
Output: C:\psarctests\by_directory.psarc
InputFile: c:\psarctests\custom_folders_filelist.txt
Output: c:\psarctests\custom_folders.psarc
Compression: zlib level 9
Compression: zlib level 9
Archiving C:\psarctests\source files\test
Archiving C:/psarctests/custom_folders_extracted/Folder1/Image1.bmp
Archiving C:/psarctests/custom_folders_extracted/Folder2/Folder21/Image21.png
Archiving C:/psarctests/custom_folders_extracted/Folder3/Folder31/Folder311/Image311.jpg
Compressing TOC
Compressing TOC
Compressing C:\psarctests\source files\test\BMPfolder1\Image1.bmp
Compressing C:\psarctests\custom_folders_extracted\Folder1\Image1.bmp
Compressing C:\psarctests\source files\test\dummy.txt
Compressing C:\psarctests\custom_folders_extracted\Folder2\Folder21\Image21.png
Compressing C:\psarctests\source files\test\JPGfolder1\JPGfolder2\Image2.jpg
Compressing C:\psarctests\custom_folders_extracted\Folder3\Folder31\Folder311\Image311.jpg
Compressing C:\psarctests\source files\test\PNGfolder1\PNGfolder2\PNGfolder3\Image3.png


           4: Total Files Archived
           3: Total Files Archived
     6239520: Original Size
     6239520: Original Size
        108: Manifest (uncompressed)
          87: Manifest (uncompressed)
           72: Manifest (compressed)
           57: Manifest (compressed)
         380: TOC size
         348: TOC size
         8836: Final Size
         8789: Final Size
         4.3%: Directory Overhead
         4.0%: Directory Overhead
       99.9%: Compression Ratio
       99.9%: Compression Ratio
           9: Compression Level
           9: Compression Level
C:\>psarc.exe list C:\psarctests\by_directory.psarc
}}
Listing C:\psarctests\by_directory.psarc
BMPfolder1/Image1.bmp (8018/6220854 0%)
dummy.txt (0/0 100%)
JPGfolder1/JPGfolder2/Image2.jpg (209/12524 1%)
PNGfolder1/PNGfolder2/PNGfolder3/Image3.png (157/6142 2%)
</syntaxhighlight>}}


====create by filelist====
*Notes:
This method allows to order the files inside the archive in a specific position (so is posible to know the ID that will have every files before creating the psarc)
**The program replaces the windows slash "\" by "/" when archiving the files (note the difference in the creation process between '''Archiving C:/...''' and '''Compressing C:\...'''). When making a '''--list''' command over the created psarc the slashes will appear as "/" because this is how they was archived in the '''Manifest''' (manifest is the first file inside the psarc filetable, doesnt appears as a file when using the '''--list''' command and doesnt have an assigned '''ID''')
**'''--strip''' option removes part of the paths from the filelist, can be used several times with different stripped paths, this is usefull when the psarc archive is generated from a filelist that contains paths from different folders and/or devices in the PC (e.g: is posible to create a filelist including a file from '''F:\textures\packed\texture1.jpg''' and another file from '''G:\models\packed\model1.xxx''' and strip the paths: '''F:\textures\''' and '''G:\models\''', this way both files will be stored inside the psarc archive together under path: '''packed/texture1.jpg''' and '''packed/model1.xxx''')


When rebuilding a psarc from a game is needed to preserve the original ID's of ALL the files inside the archive (is posible to replace files but never remove). By replacing files (e.g: by dummyes) all the others preserves his positions
====xml====
To use an .xml is needed to prepare it before using psarc.exe, using an xml is the most flexible way to use psarc.exe because allows to place the source (files to create, or psarc to extract), target (files to create, or psarc to extract), and psarc.exe in any path of the PC, it allows the usage of a filelist.txt (that defines all files inside the archive), create psarcs based in a directory, or specify all the files inside the xml, also to specify the compression level for every file (needed for video or audio files that doesnt admits compression), etc...


The filelist is a plain .txt file where every file is defined by a single line, composed by his path, filename, and file extension, 1 line per file. Is posible to generate this kind of filelists automatically by using the output of the '''--list''' command and some regular expressions to replace characters
Is also the most complicated method because is needed to specify full PC paths inside the xml, and when creating is needed to specify regular expressions to strip part of the PC path


The examples used in wiki uses full PC paths to be more flexible (no need to place psarc.exe next to the source folder, actually you can place psarc.exe in c:\ the source folder in d:\ and create the psarc in x:\). When using full paths is mandatory to use the '''--strip''' option with an explicit path or a regular expression (regex) to remove part of the PC path (e.g: if you strip '''C:\psarctests\source files\test''' from '''C:\psarctests\source files\test\BMPfolder1\Image1.bmp''' the resulting path of the file inside the archive will be '''BMPfolder1/Image1.bmp''')
When the xml is ready you can run it this way:
{{Keyboard|content=
'''C:\Portables\psarc>psarc.exe --xml=c:\psarctests\extract_custom_folders.xml'''
}}


The '''--strip''' option removes part of the paths from the filelist, can be used several times with different stripped paths, this is usefull when the psarc archive is generated from a filelist that contains paths from different folders and/or devices in the PC (e.g: is posible to create a filelist including a file from '''F:\textures\packed\texture1.jpg''' and another file from '''G:\models\packed\model1.xxx''' and strip the paths: '''F:\textures\''' and '''G:\models\''', this way both files will be stored inside the psarc archive together under path: '''packed/texture1.jpg''' and '''packed/model1.xxx''')
The options '''--verbose''', '''--debug''', and '''--quiet''' cant be used inside the xml, so if needed are specifyed in the command line, this way:
 
{{Keyboard|content=
First is needed to prepare a '''filelist.txt''' like this example, located in '''C:\psarctests\source files\filelist.txt''', contains the PC paths of the files that are in the folder '''C:\psarctests\source files\test''' and will be included inside the psarc archive:
'''C:\Portables\psarc>psarc.exe --debug --xml=c:\psarctests\create_custom_folders.xml'''
C:\psarctests\source files\test\dummy.txt
}}
C:\psarctests\source files\test\BMPfolder1\Image1.bmp
C:\psarctests\source files\test\JPGfolder1\JPGfolder2\Image2.jpg
C:\psarctests\source files\test\PNGfolder1\PNGfolder2\PNGfolder3\Image3.png
 
The psarc archive is created by using the filelist as the '''--inputfile''' and uses an explicit path to '''--strip''' from every file inside the filelist, this way:
{{Keyboard|content=<syntaxhighlight lang="bash">C:\>psarc.exe create --strip="C:\psarctests\source files\test" --output=C:\psarctests\by_filelist.psarc --inputfile="C:\psarctests\source files\filelist.txt"</syntaxhighlight>}}
 
Or you can prepare an .xml that contains the path to the filelist.txt
{{Boxcode|title=Create_by_filelist.xml|code=<syntaxhighlight lang="xml">
<psarc>
<create archive="C:\psarctests\by_filelist.psarc" absolute="false" ignorecase="false">
<compression type="zlib" enabled="true" />
<strip regex="C:\psarctests\source files\test" />
<filelist path="C:\psarctests\source files\filelist.txt" />
</create>
</psarc>
</syntaxhighlight>}}
 
Then run the contents of the .xml this way:
{{Keyboard|content=<syntaxhighlight lang="bash">C:\>psarc.exe --xml="c:\psarctests\CREATE by_filelist.xml"</syntaxhighlight>}}
 
The output of the tool is the same in both cases (except the InputFile not present when using an xml)
{{Keyboard|content=<syntaxhighlight lang="bash">
Strip: C:\psarctests\source files\test
Flags: relative
NumJobs: 2
InputFile: C:\psarctests\source files\filelist.txt
Output: C:\psarctests\by_filelist.psarc
Compression: zlib level 9
Archiving C:\psarctests\source files\test\dummy.txt
Archiving C:\psarctests\source files\test\BMPfolder1\Image1.bmp
Archiving C:\psarctests\source files\test\JPGfolder1\JPGfolder2\Image2.jpg
Archiving C:\psarctests\source files\test\PNGfolder1\PNGfolder2\PNGfolder3\Image3.png
Compressing TOC
Compressing C:\psarctests\source files\test\dummy.txt
Compressing C:\psarctests\source files\test\BMPfolder1\Image1.bmp
Compressing C:\psarctests\source files\test\JPGfolder1\JPGfolder2\Image2.jpg
Compressing C:\psarctests\source files\test\PNGfolder1\PNGfolder2\PNGfolder3\Image3.png
 
          4: Total Files Archived
    6239520: Original Size
        108: Manifest (uncompressed)
          72: Manifest (compressed)
        380: TOC size
        8836: Final Size
        4.3%: Directory Overhead
      99.9%: Compression Ratio
          9: Compression Level
C:\>psarc.exe list C:\psarctests\by_filelist.psarc
Listing C:\psarctests\by_filelist.psarc
dummy.txt (0/0 100%)
BMPfolder1/Image1.bmp (8018/6220854 0%)
JPGfolder1/JPGfolder2/Image2.jpg (209/12524 1%)
PNGfolder1/PNGfolder2/PNGfolder3/Image3.png (157/6142 2%)
</syntaxhighlight>}}
 
====create by file====
This method is the real deal, only available by using an xml, superceedes all the other creation methods and is the only method where is posible to use per-file attributes
 
The xml includes a list of files where every path of every file in the PC is specifyed (paths are the same than the filelist.txt explained before) but every file line allows for attributes
 
Note in the next example the compression attribute is enabled and affects all files, except Image3.png that has been archived without compression (appears as 100% in the list command output)
 
The other per-file attribute avoids the tool to output an error in the case the file dummy.txt is missing in the source folder
 
{{Boxcode|title=Create_by_file.xml|code=<syntaxhighlight lang="xml">
<psarc>
<create archive="C:\psarctests\by_file.psarc" absolute="false" ignorecase="false">
<compression type="zlib" enabled="true" />
<strip regex="C:\psarctests\source files\test" />
<file path="C:\psarctests\source files\test\dummy.txt" skipifmissing="true" />
<file path="C:\psarctests\source files\test\BMPfolder1\Image1.bmp" />
<file path="C:\psarctests\source files\test\JPGfolder1\JPGfolder2\Image2.jpg" />
<file path="C:\psarctests\source files\test\PNGfolder1\PNGfolder2\PNGfolder3\Image3.png" compressed="false" />
</create>
</psarc>
</syntaxhighlight>}}
{{Keyboard|content=<syntaxhighlight lang="bash">
C:\>psarc.exe --xml="c:\psarctests\CREATE by_file.xml"
Strip: C:\psarctests\source files\test
Flags: relative
NumJobs: 2
Output: C:\psarctests\by_file.psarc
Compression: zlib level 9
Archiving C:\psarctests\source files\test\dummy.txt
Archiving C:\psarctests\source files\test\BMPfolder1\Image1.bmp
Archiving C:\psarctests\source files\test\JPGfolder1\JPGfolder2\Image2.jpg
Archiving C:\psarctests\source files\test\PNGfolder1\PNGfolder2\PNGfolder3\Image3.png
Compressing TOC
Compressing C:\psarctests\source files\test\dummy.txt
Compressing C:\psarctests\source files\test\BMPfolder1\Image1.bmp
Compressing C:\psarctests\source files\test\JPGfolder1\JPGfolder2\Image2.jpg
    Storing C:\psarctests\source files\test\PNGfolder1\PNGfolder2\PNGfolder3\Image3.png
 
          4: Total Files Archived
    6239520: Original Size
        108: Manifest (uncompressed)
          72: Manifest (compressed)
        380: TOC size
      14821: Final Size
        2.6%: Directory Overhead
      99.8%: Compression Ratio
          9: Compression Level
C:\>psarc.exe list C:\psarctests\by_file.psarc
Listing C:\psarctests\by_file.psarc
dummy.txt (0/0 100%)
BMPfolder1/Image1.bmp (8018/6220854 0%)
JPGfolder1/JPGfolder2/Image2.jpg (209/12524 1%)
PNGfolder1/PNGfolder2/PNGfolder3/Image3.png (6142/6142 100%)
</syntaxhighlight>}}
 
Batch. This is an useless example to show how the .psarcs are created sequentially and how to create several .psarc's with only one .xml, it uses all default values for compressions, formats, flags etc...
 
In step 1 it creates an egg.psarc containing a dummy.txt. In step 2 it creates a chiken.psarc containing the egg.psarc made in step 1. In step 3 it creates an egg.psarc containing the chicken.psarc made in step 2 (egg.psarc created in step 3 overwrites egg.psarc made in step 1)
 
{{Boxcode|title=Create_by_file_paradox.xml|code=<syntaxhighlight lang="xml">
<psarc>
<create archive="C:\psarctests\egg.psarc">
<strip regex="C:\psarctests\source files\test" />
<file path="C:\psarctests\source files\test\dummy.txt" />
</create>
<create archive="C:\psarctests\chicken.psarc">
<strip regex="C:\psarctests" />
<file path="C:\psarctests\egg.psarc" />
</create>
<create archive="C:\psarctests\egg.psarc" overwrite="true">
<strip regex="C:\psarctests" />
<file path="C:\psarctests\chicken.psarc" />
</create>
</psarc>
</syntaxhighlight>}}
{{Keyboard|content=<syntaxhighlight lang="bash">
C:\>psarc.exe --xml="c:\psarctests\CREATE by_file_paradox.xml"
Strip: C:\psarctests\source files\test
Flags: relative
NumJobs: 2
Output: C:\psarctests\egg.psarc
Compression: zlib level 9
Archiving C:\psarctests\source files\test\dummy.txt
Compressing TOC
Compressing C:\psarctests\source files\test\dummy.txt
 
          1: Total Files Archived
          0: Original Size
          9: Manifest (uncompressed)
          9: Manifest (compressed)
          96: TOC size
        105: Final Size
      91.4%: Directory Overhead
      -1.$%: Compression Ratio
          9: Compression Level
 
Strip: C:\psarctests
Flags: relative
NumJobs: 2
Output: C:\psarctests\chicken.psarc
Compression: zlib level 9
Archiving C:\psarctests\egg.psarc
Compressing TOC
Compressing C:\psarctests\egg.psarc
 
          1: Total Files Archived
        105: Original Size
          9: Manifest (uncompressed)
          9: Manifest (compressed)
          96: TOC size
        174: Final Size
      55.2%: Directory Overhead
      -65.7%: Compression Ratio
          9: Compression Level
 
Strip: C:\psarctests
Flags: relative
NumJobs: 2
Output: C:\psarctests\egg.psarc
Compression: zlib level 9
Archiving C:\psarctests\chicken.psarc
Compressing TOC
Compressing C:\psarctests\chicken.psarc
 
          1: Total Files Archived
        174: Original Size
          13: Manifest (uncompressed)
          26: Manifest (compressed)
          96: TOC size
        252: Final Size
      38.1%: Directory Overhead
      -44.8%: Compression Ratio
          9: Compression Level
C:\>psarc.exe list C:\psarctests\egg.psarc
Listing C:\psarctests\egg.psarc
chicken.psarc (143/174 82%)
C:\>psarc.exe list C:\psarctests\chicken.psarc
Listing C:\psarctests\chicken.psarc
egg.psarc (69/105 65%)
</syntaxhighlight>}}
 
----
 
===extract===
* Extract contents of an existing archive.
*There are 3 optional available attributes for extract:
**'''--overwrite''' (if the files existed in the extraction folder they will be overwritten without advise)
**'''--strip-all''' (extracts all files in the root of the target folder, incase of several extracted files with the same name the program will return an error, this can be solved by using the command --overwrite)
**'''--skip-missing-files''' (seems pointless, mostly to extract files from malformed .psarcs or .psarcs that doesnt passes the "verify" command ?)
 
The required options are '''--input''' (the source .psarc) and '''--to''' (the target folder where contents will be extracted)
 
====extract all====
The example command extracts all files from the .psarc to a directory with full directory tree names, no skipped missing files, no overwrite
 
When using this options the command line output is the same, there is no mention of wich files are stripped, overwritten, or missing in the extraction process
 
{{Keyboard|content=<syntaxhighlight lang="bash">
C:\>psarc.exe extract --input="C:\psarctests\source files\test.psarc" --to="C:\psarctests\test"
Extracting: dummy.txt (0 bytes)
Extracting: BMPfolder1/Image1.bmp (6220854 bytes)
Extracting: JPGfolder1/JPGfolder2/Image2.jpg (12524 bytes)
Extracting: PNGfolder1/PNGfolder2/PNGfolder3/Image3.png (6142 bytes)
C:\>psarc.exe extract --overwrite --strip-all --skip-missing-files --input="C:\psarctests\source files\test.psarc" --to="C:\psarctests\test"
Extracting: dummy.txt (0 bytes)
Extracting: BMPfolder1/Image1.bmp (6220854 bytes)
Extracting: JPGfolder1/JPGfolder2/Image2.jpg (12524 bytes)
Extracting: PNGfolder1/PNGfolder2/PNGfolder3/Image3.png (6142 bytes)
</syntaxhighlight>}}


'''extract all (xml)'''
=====xml extract=====
 
Extracting all files
{{Boxcode|title=Extract_all.xml|code=<syntaxhighlight lang="xml">
{{Boxcode|content=<syntaxhighlight lang="xml">
<?xml version="1.0" encoding="UTF-8"?>
<psarc>
<psarc>
<extract archive="C:\psarctests\source files\test.psarc" to="C:\psarctests\all">
<extract archive="c:\psarctests\custom_folders.psarc" to="c:\psarctests\custom_folders_extracted">
</extract>
</extract>
</psarc>
</psarc>
</syntaxhighlight>}}
{{Keyboard|content=<syntaxhighlight lang="bash">
C:\>psarc.exe --xml="c:\psarctests\EXTRACT all.xml"
Extracting: dummy.txt (0 bytes)
Extracting: BMPfolder1/Image1.bmp (6220854 bytes)
Extracting: JPGfolder1/JPGfolder2/Image2.jpg (12524 bytes)
Extracting: PNGfolder1/PNGfolder2/PNGfolder3/Image3.png (6142 bytes)
</syntaxhighlight>}}
</syntaxhighlight>}}


====extract by file====
Extracting a single file
This extraction method is only available when using an xml because command line doesnt allows to specify files inside the archive
{{Boxcode|content=<syntaxhighlight lang="xml">
 
<?xml version="1.0" encoding="UTF-8"?>
{{Boxcode|title=Extract_by_file.xml|code=<syntaxhighlight lang="xml">
<psarc>
<psarc>
<extract archive="C:\psarctests\source files\test.psarc" to="C:\psarctests\by_file">
<extract archive="c:\psarctests\custom_folders.psarc" to="c:\psarctests\custom_folders_extracted">
<file archivepath="BMPfolder1/Image1.bmp" />
<file archivepath="Folder1/Image1.bmp" />
</extract>
</extract>
</psarc>
</psarc>
</syntaxhighlight>}}
{{Keyboard|content=<syntaxhighlight lang="bash">
C:\>psarc.exe --xml="c:\psarctests\EXTRACT by_file.xml"
Extracting: BMPfolder1/Image1.bmp (6220854 bytes)
</syntaxhighlight>}}
</syntaxhighlight>}}


When extracting single files is also posible to use the same attributes availables in command line, and attributes per-file, but they uses different names inside the xml (see the DTD example)
When extracting single files is also posible to use the same attributes availables in command line, and attributes per-file, but they uses different names inside the xml (see the DTD example)
{{Boxcode|title=Extract_by_file.xml|code=<syntaxhighlight lang="xml">
{{Boxcode|content=<syntaxhighlight lang="xml">
<?xml version="1.0" encoding="UTF-8"?>
<psarc>
<psarc>
<extract archive="C:\psarctests\source files\test.psarc" to="C:\psarctests\by_file" stripall="true" skipmissingfiles="false" overwrite="true">
<extract archive="c:\psarctests\custom_folders.psarc" to="c:\psarctests\custom_folders_extracted" stripall="true" skipmissingfiles="false" overwrite="true">
<file archivepath="dummy.txt" skipifmissing="true" />
<file archivepath="Folder1/Image1.bmp" skipifmissing="true" />
<file archivepath="PNGfolder1/PNGfolder2/PNGfolder3/Image3.png" />
<file archivepath="Folder3/Folder31/Folder311/Image311.jpg" />
</extract>
</extract>
</psarc>
</psarc>
Line 706: Line 429:
**The element "extract" uses the attribute '''archive''' but could be replaced by '''input''', in this case are exactly the same and both will work, actually '''--input''' is the same option used in comand line but the examples in wiki uses the name '''archive''' because is more intuitive (is also used as an attribute for "create" and in both cases is refered to the compressed archive.psarc). Both (archive and input) appears in the DTD as optional (#IMPLIED) but only one of them can be used in the xml
**The element "extract" uses the attribute '''archive''' but could be replaced by '''input''', in this case are exactly the same and both will work, actually '''--input''' is the same option used in comand line but the examples in wiki uses the name '''archive''' because is more intuitive (is also used as an attribute for "create" and in both cases is refered to the compressed archive.psarc). Both (archive and input) appears in the DTD as optional (#IMPLIED) but only one of them can be used in the xml
**The element "file" uses the attribute '''archivepath''' but could be replaced by '''path''', in this case are exactly the same and both will work, but the examples in wiki uses the name '''archivepath''' because is more intuitive (is refered to the path of a file inside archive.psarc). Both (archivepath and path) appears in the DTD as optional (#IMPLIED) but only one of them can be used in the xml
**The element "file" uses the attribute '''archivepath''' but could be replaced by '''path''', in this case are exactly the same and both will work, but the examples in wiki uses the name '''archivepath''' because is more intuitive (is refered to the path of a file inside archive.psarc). Both (archivepath and path) appears in the DTD as optional (#IMPLIED) but only one of them can be used in the xml
**To identify the paths inside the psarc archive use '''--list''' option in command line. By default the paths inside the psarc are relative (path names starts with the name of the folder) but in some cases the paths starts with a slash"/" (when the psarc has been created with '''absolute''' flag), in this case the slash needs to be specifyed as part of the path here (e.g: '''archivepath="Folder1/Image1.bmp"''' is a relative path, and '''archivepath="/Folder1/Image1.bmp"''' is an absolute path)


===Other options===
=====xml create=====
 
====Regular expression support (regex)====
-sREGEX, --strip=REGEX                  Perl-compatible regex specifying a prefix to strip from the pathnames stored in the archive. This may be specified more than once. (default = current dir)
 
Psarc uses regular expressions compatibles with PERL 5, specifically the ones used by the PCRE library http://www.pcre.org/ As can be seen in the PS3 firmware third party software licenses in XMB/Settings/System Settings/About PlayStation®3 (PS3™)
 
====Compression levels====
--level=N                              Compression quality. 1 is fastest, 9 is best. (default = 9)
 
*Notes
**(default = 9)
**when --level is not defined at creation time, the info about compression level in the creation process window appears with a value of 9, even when using --nocompress
 
{{Boxcode|code=<syntaxhighlight lang="xml">
<psarc>
<create archive="C:\psarctests\by_file.psarc">
<compression type="zlib" level="9" />
...
</syntaxhighlight>}}
 
====Create mself====
-m, --mself                            Create a PSARC-MSELF hybrid file for PS3, which can contain encrypted special files like SDATA, SPRX, and SPU SELF.
 
For rebuilding purposes is needed to verify if some of this files are present in the original filelist, by searching for this file extensions (.sdata .sprx and .self), though file extensions could not be accurate because game developers can use custom names for file extensions
 
*As far i remember this option doesnt stores any data in the psarc header so it seems the only way to identify his presence is by looking at the files itself--[[User:Sandungas|Sandungas]] ([[User talk:Sandungas|talk]]) 18:34, 20 March 2017 (UTC)


==Total Commander plugin==
==Total Commander plugin==
http://www.totalcmd.net/plugring/PSARC.html
http://www.totalcmd.net/plugring/PSARC.html


==PS3 PSARC GUI==
==GUI versions==
===PS3 PSARC GUI===
It's a graphical user interface to view, extract or create psarc archives. GUI written by aldo, unknown psarc tool used internally
It's a graphical user interface to view, extract or create psarc archives. GUI written by aldo, unknown psarc tool used internally


Download link: http://aldostools.org/ps3_psarc_gui.rar
Download link: http://aldostools.org/ps3_psarc_gui.rar


=PSARC Related Tools=
=Related Tools=
*All the files and xml's from the examples to practise and to use as layouts http://www.multiup.org/en/mirror/c5b18ca6d3b0c4a24ea3c753d6df7a76/psarctests.zip
When rebuilding a psarc is needed to preserve the original positions of all the files inside the archive (because every file in the original psarc has assigned an '''ID''' number, and after rebuilding this numbers must match with the original positions). for this same reason when rebuilding is not a good idea to remove files (because the other files that comes after will be displaced). When the purpose of the rebuild is to  reduce the sze (by removing languages, etc...) the method consists in replacing them by dummies (0kb files), this dummies preserves the positions of all the files
*http://findandreplace.codeplex.com/
*http://fart-it.sourceforge.net/
*http://textmechanic.com/Remove-Duplicate-Lines.html
 
=Rebuilding PSARC files=
When rebuilding a psarc is needed to preserve the original positions of all the files inside the archive (because every file in the original psarc has assigned an '''ID''' number, and after rebuilding this numbers must match with the original positions). for this same reason when rebuilding is not a good idea to remove files (because the other files that comes after will be displaced). When the purpose of the rebuild is to  reduce the size (by removing languages, etc...) the method consists in replacing them by dummies (0kb files), this dummies preserves the positions of all the files


This need to preserve the original positions of all the files inside the archive in the practise means there are only 2 methods to rebuild a psarc: "by filelist" or "by file". For both is needed to create a list of files
To be sure all the files are in the correct positions can be used as a base file (to edit later) the output of the '''list''' command as explained before


{{Boxframe3|content='''Rebuilding PSARC files, step-by-step summary'''
This edition of the file generated by the '''list''' command can be automated completly (not needed to edit a single character by hand). Is posible to generate a '''filelist.txt''' or an '''automated.xml''' by replacing/erasing/adding characters with other programs that identifies and replaces characters by using regular expressions, the examples used here are commands for fnr.exe (find and replace tool) and contains regular expressions (to search) and a character string (to replace)
* Step 1 - Identify compression method, archive flags, and verify default structure sizes
* Step 2 - Identify if per-file compression was used <!-- and dupes --->
* Step 3 - Rebuild
** Step 3a - If per-file compression was not used, rebuild with the method "by filelist" or "by file"
** Step 3a - If per-file compression was used, rebuild with the method "by file"
* Step 4 - Verify
}}


'''Step 1'''
*The file paths inside filelist.txt or inside an automated.xml admits 2 formats:
 
**'''full PC paths''' (where the full PC file path included the device letter is used by psarc.exe to locate the file in any device and/or any folder). This method is the most flexible but needs an ''strip'' command to remove part of the PC path when creating the psarc archive
Is needed to look at the psarc header to identify some settings
'''Offset(h) 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F'''
00000000  50 53 41 52 00 01 00 04 <span style="background:#ffff66;">7A 6C 69 62</span> 00 01 23 BA  PSAR....<span style="background:#ffff66;">zlib</span>..#º
00000010  <span style="background:#dd00dd;">00 00 00 1E</span> 00 00 09 16 <span style="background:#dddddd;">00 01 00 00</span> <span style="background:#d0000d;">00 00 00 03</span>  ................
 
Most important ones are the '''<span style="background:#ffff66;">compression method</span>''' (zlib/lzma) and the '''<span style="background:#d0000d;">archive flags</span>''' (relative/absolute, and ignorecase), this settings will be used when rebuilding from command line or from xml this way:
{{Boxcode|code=<syntaxhighlight lang="xml">
<psarc>
<create archive="C:\psarctests\by_file.psarc" absolute="true" ignorecase="true">
<compression type="zlib" />
...
</syntaxhighlight>}}
 
The other values in the header that needs to be verifyed are the '''<span style="background:#dd00dd;">TOC entry size</span>''' and the '''<span style="background:#dddddd;">Block size</span>''', is needed to know if the original psarc we are trying to rebuild uses the default values (all i found used defaults), otherway is posible to use non-default values this way: <!-- not sure if is posible to change the "TOC entry size" -->
{{Boxcode|code=<syntaxhighlight lang="xml">
<psarc>
<create archive="C:\psarctests\by_file.psarc" absolute="true" ignorecase="true" blocksize="65536">
<compression type="zlib" />
...
</syntaxhighlight>}}
 
'''Step2'''
 
Now is needed to know if the psarc uses per-file compression (if some of the files inside the archive are compressed, and others are not compressed)
 
This is important to know wich rebuild method will be used in the next step, is needed to make a --list command with psarc tool and store the output of the command as a .txt
 
Open the .txt in a text editor (like notepad++) and search for the string '''100%''' (the files that appears with a 100% has been archived but are not compressed). Is needed to do it this way semi automatized because is usual to find psarc with thousand of files inside
 
*Check how many files are not compressed, his sizes, and file extensions
**If there are no files with 100% or if there are only a few and his sizes are minimal this is normal, it means the archive doesnt uses per-file compression
**If there some files with the 100%, normal sizes (not minimal), using the same file extension, and can be identifyed (like audio or video formats) then you have a psarc with per-file compression
**If all the files appears as 100% it means the psarc has been created with the compression attibute set as "false" this way:
{{Boxcode|code=<syntaxhighlight lang="xml">
<psarc>
<create archive="C:\psarctests\by_file.psarc" absolute="true" ignorecase="true" blocksize="65536">
<compression type="zlib" enabled="false" />
...
</syntaxhighlight>}}
 
'''Step3'''
 
If the psarc doesnt uses per-file compression then is posible to rebuild it with the '''create by filelist''' method from command line by using an external filelist.txt
 
If the psarc uses per-file compression then the only way to rebuild it is with the '''create by file''' method by using an xml (the xml includes a list of files like the filelist.txt)
 
----
 
*Special rebuild notes:
**Mass effect 3 MAIN.PSARC contains a group of generic files compressed with level 9, and another group of .TXT, .BIN, and .BIK videos not compressed at all. In the creation options suggested above in the table the compression level is not defined and this means all them will use the default compression level 9 (so the .BIK files will have a ridiculous 1% or 2% of compression ratio because is the max they will admit). This is not how the original file was created (but works), the correct way to rebuild it is by defining specific compression levels "per file" in a predefined .xml
**Killzone 3 data_ps3.psarc (BCES01007 version) contains 8324 files (included 5.3GB of audio files for 21 languages with a compression of around 50%)... 2883 of all the files uses the same path/filenames repeated up to 3 times (because was created using 3 or more different working directories). This duplication of paths/filenames inside the .psarc in the practise means when doing a standard extraction 2833 files will be missing, overwrited, or they will give an error at extraction time, the correct way to mess with it is by doing several partiall extractions to different directories, and rebuild it by using a preconfigured .xml where the different paths for each file are specifyed, when rebuilding is also needed to use the --strip option several times to remove part of the paths from all the different working directories, this way the paths/filenames will be duplicated inside the .psarc archive (but are different files located at different positions and with a different ID number assigned).
**Ape Escape target.psarc includes "dupes" (or duplicated files) in the TOC (table of contents) of the psarc archive. This method used at creation time basically works by making several entries of the TOC to point to the same file, this way a single file inside the psarc is indexed several times in the TOC and can be accessed from several different paths/filenames. The only way to identify this dupes before extraction is by reading the TOC of the psarc for all the files and compare wich position are pointing to. As an example the original size of target.psarc is 328mb... after a "standard" extraction is 2.52GB (this extraction doesnt identify the dupes so are extracted several times under different paths/filenames)... if you try to rebuild it again his final size will be much bigger than the original target.psarc
 
----
 
*The file paths inside filelist.txt or inside an xml admits 2 formats:
**'''full PC paths''' (where the full PC file path included the device letter is used by psarc.exe to locate the file in any device and/or any folder). This method is the most flexible but needs an '''strip''' command to remove part of the PC path when creating the psarc archive
**'''relative to work directory paths''' (where work directory is the path to psarc.exe and the files needs to be placed in a subfolder under it). This method needs to copy psarc.exe to the parent folder of the files
**'''relative to work directory paths''' (where work directory is the path to psarc.exe and the files needs to be placed in a subfolder under it). This method needs to copy psarc.exe to the parent folder of the files


The file list we need to generate contains the access paths stored in the '''manifest''', the easy way to have have a copy of the manifest is by using the '''list''' command of psarc tool
==Generating a filelist with regular expressions==


The output of the '''list''' command has some characters that are needed ro remove or replace, the purpose of automatizing this process by using regular expressions is because usually psarc files contains thousand of files, the examples used here are commands for fnr.exe (find and replace tool) and contains regular expressions (to search) and a character strings (to replace)
==Generating an xml with regular expressions==
 
===Generating a filelist.txt by using regular expressions===
{{Boxframe3|content='''Generating a filelist.txt, step-by-step summary'''
* Step 1 - Save list command output as a .txt
* Step 2 - Remove first line
* Step 3 - Remove parentheses
* Step 4 - Remove last line
* Step 5 - Replace slashes (optional, recommended)
* Step 6 - Add local paths (optional, recommended)
** Step 6a - Absolute flag blind fix (optional, recommended)
}}
 
*'''Step 1 - Save list command output as a .txt'''
Generate a .txt file containing the output of the '''list''' comand
{{Boxframe1|content=
{{Keyboard|content=<syntaxhighlight lang="bash">C:\>psarc.exe list "C:\psarctests\source files\test.psarc" > "C:\psarctests\filelist.txt"</syntaxhighlight>}}
The file generated by the list command will have this content (note there is en empty line at the end):
Listing C:\psarctests\source files\test.psarc
dummy.txt (0/0 100%)
BMPfolder1/Image1.bmp (8018/6220854 0%)
JPGfolder1/JPGfolder2/Image2.jpg (209/12524 1%)
PNGfolder1/PNGfolder2/PNGfolder3/Image3.png (6142/6142 100%)
<br>}}
 
*'''Step 2 - Remove first line'''
{{Boxframe1|content=
find (and replace by nothing):
Listing.*\n
The resulting file:
dummy.txt (0/0 100%)
BMPfolder1/Image1.bmp (8018/6220854 0%)
JPGfolder1/JPGfolder2/Image2.jpg (209/12524 1%)
PNGfolder1/PNGfolder2/PNGfolder3/Image3.png (6142/6142 100%)
<br>}}
 
*'''Step 3 - Remove parentheses'''
{{Boxframe1|content=
find (and replace by nothing):
[^\b]\(.*\)
The resulting file:
dummy.txt
BMPfolder1/Image1.bmp
JPGfolder1/JPGfolder2/Image2.jpg
PNGfolder1/PNGfolder2/PNGfolder3/Image3.png
<br>}}
 
*'''Step 4 - Remove last line'''
{{Boxframe1|content=
find (and replace by nothing):
\r\n$
The resulting file:
dummy.txt
BMPfolder1/Image1.bmp
JPGfolder1/JPGfolder2/Image2.jpg
PNGfolder1/PNGfolder2/PNGfolder3/Image3.png
<br>}}
*'''Step 5 - Replace slashes (optional, recommended)'''
This step is optional, both slashes are valid, but is good to do it to standarize all paths formats, otherway is a mess
{{Boxframe1|content=
find:
/
replace by:
\\
The resulting file:
dummy.txt
BMPfolder1\Image1.bmp
JPGfolder1\JPGfolder2\Image2.jpg
PNGfolder1\PNGfolder2\PNGfolder3\Image3.png
<br>}}
 
*'''Step 6 - Add local paths (optional, recommended)'''
Now is needed to add the local paths (where the psarc contents are decompressed), e.g: '''C:\psarctests\source files\test\''', remember this is exactly the part of the path that is needed to '''strip''' later (because we dont want to include our local path '''C:\psarctests\source files\test\''' inside the manifest)
 
This is a perfect filelist.txt that can be used for the rebuild method '''by filelist''' from command line (usefull when the psarc doesnt uses per-file compression), remember is needed to use the '''strip''' option
{{Boxframe1|content=
find:
^
replace by:
C:\\psarctests\\source files\\test\\
The resulting file:
C:\psarctests\source files\test\dummy.txt
C:\psarctests\source files\test\BMPfolder1\Image1.bmp
C:\psarctests\source files\test\JPGfolder1\JPGfolder2\Image2.jpg
C:\psarctests\source files\test\PNGfolder1\PNGfolder2\PNGfolder3\Image3.png
<br>}}
 
*'''Step 6a - Absolute flag blind fix (optional, recommended)'''
The purpose of this step is to fix a posible problem that could appear in step 6, the psarc used as an example in step 1 to generate the initial list of files was created without '''archive flags''' (in other words, his access paths in the manifest was '''relative''' paths)
 
The other posible paths format used by the manifest is when the psarc was created with '''absolute''' archive flag, in this case all the lines of the file list in step 5 starts with an slash \ (e.g: the first file in the list that is supposed to be archived in the root of the psarc should be listed as '''\dummy.txt''' instead of '''dummy.txt'''
 
In step 6 is added a local path that ends with an slash too... so the result is '''C:\psarctests\source files\test\\dummy.txt''' (note the double slash), this is wrong and this step fixes it blindlly (because doesnt matters if the problem exists or not, the final result will be the same)
{{Boxframe1|content=
find:
\\\\
replace by:
\\
<br>}}
 
----
 
===Generating a XML by using regular expressions===
{{Boxframe3|content='''Generating a xml, step-by-step summary'''
* Step 1 - Save list command output as a list.txt
* Step 2 - Replace slashes
* Step 3 - Replace first line start (preserves original .psarc path)
* Step 4 - Replace first line end (for relative flag)
* Step 5 - Replace first line end (for absolute flag)
* Step 6 - Replace parentheses (per-file compression autodetection)
* Step 7 - Replace other parentheses
* Step 8 - Replace last line
* Step 9 - Absolute flag blind fix
}}
 
*'''Step 1 - Save list command output as a list.txt'''
Generate a list.txt file containing the output of the '''list''' command
{{Boxframe1|content=
{{Keyboard|content=<syntaxhighlight lang="bash">C:\>psarc.exe list "C:\psarctests\source files\test.psarc" > "C:\psarctests\list.txt"</syntaxhighlight>}}
The file generated by the list command will have this content:
{{Boxcode|code=<syntaxhighlight lang="xml">
Listing C:\psarctests\source files\test.psarc
/dummy.txt (0/0 100%)
/BMPfolder1/Image1.bmp (8018/6220854 0%)
/JPGfolder1/JPGfolder2/Image2.jpg (209/12524 1%)
/PNGfolder1/PNGfolder2/PNGfolder3/Image3.png (6142/6142 100%)
 
</syntaxhighlight>}}
*Notes of the example:
**The original path of the .psarc is '''C:\psarctests\source files\test.psarc''' (it will be used as the path where the rebuild .psarc will be created)
**Paths starts with an slash  '''/''' (so the .psarc was created with absolute flag)
**'''dummy.txt''' and '''Image3.png''' was archived without compression (appears with 100%)
**There is an empty line at the end (not visible in wiki because yeah... is empty)
}}
 
*'''Step 2 - Replace slashes'''
This step is to standarize paths formats
{{Boxframe1|content=
find:
/
replace by:
\\
The resulting file:
{{Boxcode|code=<syntaxhighlight lang="xml">
Listing C:\psarctests\source files\test.psarc
\dummy.txt (0\0 100%)
\BMPfolder1\Image1.bmp (8018\6220854 0%)
\JPGfolder1\JPGfolder2\Image2.jpg (209\12524 1%)
\PNGfolder1\PNGfolder2\PNGfolder3\Image3.png (6142\6142 100%)
</syntaxhighlight>}}
}}
 
*'''Step 3 - Replace first line start (preserves original .psarc path)'''
This step keeps the original local path of the .psarc file that appears in the output of the list command (is the path where the .psarc will be created)
{{Boxframe1|content=
find:
Listing.
replace by:
<psarc>\r\n\t<create archive="
The resulting file:
{{Boxcode|code=<syntaxhighlight lang="xml">
<psarc>
<create archive="C:\psarctests\source files\test.psarc
\dummy.txt (0\0 100%)
\BMPfolder1\Image1.bmp (8018\6220854 0%)
\JPGfolder1\JPGfolder2\Image2.jpg (209\12524 1%)
\PNGfolder1\PNGfolder2\PNGfolder3\Image3.png (6142\6142 100%)
</syntaxhighlight>}}
}}
 
*'''Step 4 - Replace first line end (for relative flag)'''
Relative paths is the default value, this step completes the replacement of the first line by using the default '''absolute="false"''' attribute
{{Boxframe1|content=
find:
\.psarc\r\n
replace by:
\.psarc" absolute="false" ignorecase="false">\r\n\t\t<compression type="zlib" />\r\n\t\t<strip regex="C:\\source\\folder\\" />\r\n\r\n\t\t<file path="C:\\source\\folder\\
The resulting file:
{{Boxcode|code=<syntaxhighlight lang="xml">
<psarc>
<create archive="C:\psarctests\source files\test.psarc" absolute="false" ignorecase="false">
<compression type="zlib" />
<strip regex="C:\source\folder\" />
 
<file path="C:\source\folder\\dummy.txt (0\0 100%)
\BMPfolder1\Image1.bmp (8018\6220854 0%)
\JPGfolder1\JPGfolder2\Image2.jpg (209\12524 1%)
\PNGfolder1\PNGfolder2\PNGfolder3\Image3.png (6142\6142 100%)
</syntaxhighlight>}}
}}
 
*'''Step 5 - Replace first line end (for absolute flag)'''
This step finds the same pattern replaced in step before followed by an slash, if found is replaced by the same pattern but with '''absolute="true"''' attribute
{{Boxframe1|content=
find:
\.psarc" absolute="false" ignorecase="false">\r\n\t\t<compression type="zlib" />\r\n\t\t<strip regex="C:\\source\\folder\\" />\r\n\r\n\t\t<file path="C:\\source\\folder\\\\
replace by:
\.psarc" absolute="true" ignorecase="false">\r\n\t\t<compression type="zlib" />\r\n\t\t<strip regex="C:\\source\\folder\\" />\r\n\r\n\t\t<file path="C:\\source\\folder\\\\
The resulting file:
{{Boxcode|code=<syntaxhighlight lang="xml">
<psarc>
<create archive="C:\psarctests\source files\test.psarc" absolute="true" ignorecase="false">
<compression type="zlib" />
<strip regex="C:\source\folder\" />
 
<file path="C:\source\folder\\dummy.txt (0\0 100%)
\BMPfolder1\Image1.bmp (8018\6220854 0%)
\JPGfolder1\JPGfolder2\Image2.jpg (209\12524 1%)
\PNGfolder1\PNGfolder2\PNGfolder3\Image3.png (6142\6142 100%)
</syntaxhighlight>}}
}}
 
*'''Step 6 - Replace parentheses (per-file compression autodetection)'''
This step replaces only the parentheses for the lines of the files that was archived without compression and adds the attribute '''compressed="false"'''
{{Boxframe1|content=
find:
[^\b]\(.*100.\)\r\n
replace by:
" compressed="false" />\r\n\t\t<file path="C:\\source\\folder\\
The resulting file:
{{Boxcode|code=<syntaxhighlight lang="xml">
<psarc>
<create archive="C:\psarctests\source files\test.psarc" absolute="true" ignorecase="false">
<compression type="zlib" />
<strip regex="C:\source\folder\" />
 
<file path="C:\source\folder\\dummy.txt" compressed="false" />
<file path="C:\source\folder\\BMPfolder1\Image1.bmp (8018\6220854 0%)
\JPGfolder1\JPGfolder2\Image2.jpg (209\12524 1%)
\PNGfolder1\PNGfolder2\PNGfolder3\Image3.png" compressed="false" />
<file path="C:\source\folder\
</syntaxhighlight>}}
}}
 
*'''Step 7 - Replace other parentheses'''
This step replaces all the other parentheses for the lines of the files that willl be compressed
{{Boxframe1|content=
find:
[^\b]\(.*\n
replace by:
" />\r\n\t\t<file path="C:\\source\\folder\\
The resulting file:
{{Boxcode|code=<syntaxhighlight lang="xml">
<psarc>
<create archive="C:\psarctests\source files\test.psarc" absolute="true" ignorecase="false">
<compression type="zlib" />
<strip regex="C:\source\folder\" />
 
<file path="C:\source\folder\\dummy.txt" compressed="false" />
<file path="C:\source\folder\\BMPfolder1\Image1.bmp" />
<file path="C:\source\folder\\JPGfolder1\JPGfolder2\Image2.jpg" />
<file path="C:\source\folder\\PNGfolder1\PNGfolder2\PNGfolder3\Image3.png" compressed="false" />
<file path="C:\source\folder\
</syntaxhighlight>}}
}}
 
*'''Step 8 - Replace last line'''
This step replaces a useless line at the end and completes the xml structure
{{Boxframe1|content=
find:
\t\t<file path="C:\\source\\folder\\$
replace by:
\t</create>\r\n</psarc>
The resulting file:
{{Boxcode|code=<syntaxhighlight lang="xml">
<psarc>
<create archive="C:\psarctests\source files\test.psarc" absolute="true" ignorecase="false">
<compression type="zlib" />
<strip regex="C:\source\folder\" />
 
<file path="C:\source\folder\\dummy.txt" compressed="false" />
<file path="C:\source\folder\\BMPfolder1\Image1.bmp" />
<file path="C:\source\folder\\JPGfolder1\JPGfolder2\Image2.jpg" />
<file path="C:\source\folder\\PNGfolder1\PNGfolder2\PNGfolder3\Image3.png" compressed="false" />
</create>
</psarc>
</syntaxhighlight>}}
}}
 
*'''Step 9 - Absolute flag blind fix'''
The purpose of this step is to fix a posible problem that only happens when the .psarc was created with absolute flag (when the paths created from the list command starts with an slash, like in the examples)
 
The fix is made blindlly because it will remove an slash only if two consecutive slashes are found (if there are no double slashes it will do nothing)
{{Boxframe1|content=
find:
\\\\
replace by:
\\
The resulting file:
{{Boxcode|code=<syntaxhighlight lang="xml">
<psarc>
<create archive="C:\psarctests\source files\test.psarc" absolute="true" ignorecase="false">
<compression type="zlib" />
<strip regex="C:\source\folder\" />
 
<file path="C:\source\folder\dummy.txt" compressed="false" />
<file path="C:\source\folder\BMPfolder1\Image1.bmp" />
<file path="C:\source\folder\JPGfolder1\JPGfolder2\Image2.jpg" />
<file path="C:\source\folder\PNGfolder1\PNGfolder2\PNGfolder3\Image3.png" compressed="false" />
</create>
</psarc>
</syntaxhighlight>}}
}}


=Games or Apps using PSARC files=
=Games or Apps using PSARC files=
Line 1,139: Line 462:
! colspan="13" {{cellcolors|lightblue}} {{icon content ps3}}
! colspan="13" {{cellcolors|lightblue}} {{icon content ps3}}
|-
|-
! colspan="2" | Game/App info !! colspan="5" | PSARC Header info !! rowspan="2" | Compression<BR />Method !! rowspan="2" | Notes
! colspan="2" | Game/App info !! colspan="5" | PSARC Header info !! colspan="2" | PSARC Manifest info !! colspan="3" | PSARC TOC info !! rowspan="2" | Notes
|-
|-
! TITLE !! PSARC files || Version<BR />(offset 0x04) !! Compression<BR />(offset 0x08) !! TOC entry size<BR />(offset 0x10) !! Block Size<BR />(offset 0x18) !! Flags<BR />(offset 0x1C)
! TITLE !! PSARC files || Version<BR />(offset 0x04) !! Compression<BR />(offset 0x08) !! TOC entry size<BR />(offset 0x10) !! Block Size<BR />(offset 0x18) !! Flags<BR />(offset 0x1C) !! ignorecase !! absolute !! no<BR />compress !! per-file<BR />compress !! TOC Dupes
|-
|-
| rowspan="3" | Ape Escape || sound.psarc || 00010004 || zlib || 0000001E || 00010000 || 00000000 (no flags) || no compress || Contains not-compressed audio
| Ape Escape || sound.psarc || 00010004 || zlib || 0000001E || 00010000 || 00000000 || {{no}} || {{no}} || {{yes}} || {{no}} || {{no}} || Contains not-compressed audio
|-
|-
| <language>.psarc || 00010004 || zlib || 0000001E || 00010000 || 00000002 (absolute) || compress all ||  
| Ape Escape || <language>.psarc || 00010004 || zlib || 0000001E || 00010000 || 00000002 || {{no}} || {{yes}} || {{no}} || {{no}} || {{no}} ||  
|-
|-
| target.psarc || 00010004 || zlib || 0000001E || 00010000 || 00000002 (absolute) || compress all || TOC dupes!!!, see notes below
| Ape Escape || target.psarc || 00010004 || zlib || 0000001E || 00010000 || 00000002 || {{no}} || {{yes}} || {{no}} || {{no}} || {{yes}} || TOC dupes!!!, see notes below
|-
|-
| Atelier Rorona Plus || ? || 00010004 || zlib || 0000001E || 00010000 || 00000002 (absolute) || ? ||  
| Atelier Rorona Plus || ? || 00010004 || zlib || 0000001E || 00010000 || 00000002 || {{no}} || {{yes}} ||  ||  ||  ||  
|-
|-
| Eiyuu Densetsu Sen no Kiseki ||  data.psarc || ||  ||  ||  ||  ||  ||  
| Eiyuu Densetsu Sen no Kiseki ||  ? || ||  ||  ||  ||  ||  ||  ||  ||  ||  ||  
|-
|-
| Eiyuu Densetsu Sen no Kiseki II || data.psarc  || || || || || || ||  
| God of War III || All || 00010004 || zlib || 0000001E || 00010000 || 00000002 || {{no}} || {{yes}} || {{no}} || {{no}} || ? ||  
|-
|-
| God of War III || All || 00010004 || zlib || 0000001E || 00010000 || 00000002 (absolute) || compress all ||  
| God of War Ascension || INTROCIN.PSARC || || || || || || || {{yes}} || {{yes}} || {{no}} || {{no}} || Intro video
|-
|-
| rowspan="6" | God of War Ascension || INTROCIN.PSARC ||  ||  ||  ||  ||  || no compress || Intro video
| God of War Ascension || CRTN.PSARC<BR />CYN.PSARC<BR />FURY.PSARC<BR />HECA.PSARC<BR />HRTN.PSARC<BR />LAN.PSARC<BR />PHI.PSARC<BR />STAT.PSARC<BR />STINT.PSARC<BR />TEM.PSARC ||  ||  ||  ||  ||  ||  || {{yes}} || {{no}} || {{yes}} || {{no}} || Contains not-compressed audio, and other compressed files<BR />game levels, and game levels soundtracks
|-
|-
| CRTN.PSARC<BR />CYN.PSARC<BR />FURY.PSARC<BR />HECA.PSARC<BR />HRTN.PSARC<BR />LAN.PSARC<BR />PHI.PSARC<BR />STAT.PSARC<BR />STINT.PSARC<BR />TEM.PSARC ||  ||  ||  ||  ||  || per-file compress || Contains not-compressed audio, and other compressed files<BR />game levels, and game levels soundtracks
| God of War Ascension || RESOURCES.PSARC ||  ||  ||  ||  ||  || || {{yes}} || {{no}} || {{yes}} || {{no}} || Game resources, included not-compresed audio
|-
|-
| RESOURCES.PSARC ||  ||  ||  ||  ||  || per-file compress || Game resources, included not-compresed audio
| God of War Ascension || <LANGUAGE>.PSARC ||  ||  ||  ||  ||  || || {{yes}} || {{no}} || {{yes}} || {{no}} || Contains not-compressed audio, and other compressed files
|-
|-
| <LANGUAGE>.PSARC ||  ||  ||  ||  ||  || per-file compress || Contains not-compressed audio, and other compressed files
| God of War Ascension || SHELL.PSARC<BR />TPPS.PSARC ||  ||  ||  ||  ||  || || {{yes}} || {{no}} || {{no}} || {{no}} || Main menu<BR />Game updates stub (dummy file)
|-
|-
| SHELL.PSARC<BR />TPPS.PSARC || || || || || || compress all || Main menu<BR />Game updates stub (dummy file)
| God of War Ascension || GAME.PSARC<BR />(or all others ?) || 00010004 || zlib || 0000001E || 00010000 || 00000002 || {{no}} || {{yes}} || {{no}} || {{no}} || {{no}} || Game settings
|-
|-
| GAME.PSARC<BR />(or all others ?) || 00010004 || zlib || 0000001E || 00010000 || 00000002 (absolute) || compress all || Game settings
| ICO & Shadow of the Colossus HD || || || || || || ||  ||  ||  ||  ||  ||  
|-
|-
| ICO & Shadow of the Colossus HD || || || || || || || ||  
| Killzone 3 || data_ps3.psarc || 00010004 || zlib || 0000001E || 00010000 || 00000001 || {{yes}} || {{no}} || {{no}} || {{no}} || {{no}} || created from 3 working directories, lot of duplicated paths
|-
|-
| Killzone 3 || data_ps3.psarc || 00010004 || zlib || 0000001E || 00010000 || 00000001 (ignorecase) || compress all || created from 3 working directories, lot of duplicated paths
| Mass Effect 3 || AUDIO.PSARC || 00010004 || lzma || 0000001E || 00010000 || 00000003 || {{yes}} || {{yes}} || {{yes}} || {{no}} || {{no}} || Contains not-compressed audio
|-
|-
| rowspan="3" | Mass Effect 3 || AUDIO.PSARC || 00010004 || lzma || 0000001E || 00010000 || 00000003 (ignorecase + absolute) || no compress || Contains not-compressed audio
| Mass Effect 3 || MAIN.PSARC || 00010004 || lzma || 0000001E || 00010000 || 00000003 || {{yes}} || {{yes}} || {{no}} || {{yes}} || {{no}} || Contains not-compressed video, and other compressed files
|-
|-
| MAIN.PSARC || 00010004 || lzma || 0000001E || 00010000 || 00000003 (ignorecase + absolute) || per-file compress || Contains not-compressed video, and other compressed files
| Mass Effect 3 || TEXTURES.PSARC || ||  ||  ||  ||  || || || || || ||  
|-
|-
| TEXTURES.PSARC ||  ||  ||  ||  ||  ||  ||  
| Motorstorm Pacific Rift ||  ? || ||  ||  ||  ||  ||  ||  ||  ||  ||  ||  
|-
|-
| Metal Gear Solid V. Ground Zeroes || data.psarc || 00010004 || zlib || 0000001E || 00010000 || 00000002 (absolute) || per-file compress || whole game, included texture.qar (452mb) duplicated out of the .psarc
| Ni No Kuni || bd03.adat ?<BR />hd01.adat ?<BR />hd05<language>.adat ? || ||  ||  || || || || || || || || .psarc file extensions renamed to .adat
|-
|-
| Motorstorm Pacific Rift ||  ? || ||  ||  ||  ||  ||  ||   
| Ninja Gaiden 3 Razors Edge ||  || ||  ||  ||  ||  ||  ||  ||  ||  ||  ||
|-
|-
| Ni No Kuni || bd03.adat ?<BR />hd01.adat ?<BR />hd05<language>.adat ? || || || || || || || .psarc file extensions renamed to .adat
| Ratchet & Clank. A Crack in Time || *_uncached.psarc || 00010003 || zlib || 0000001E || 00010000 || 00000003 || {{yes}} || {{yes}} || {{no}} || {{yes}} || {{no}} || Contains not-compressed audio, and other compressed files
|-
|-
| Ninja Gaiden 3 Razors Edge || || || || || || ||  ||  
| Ratchet & Clank A Crack in Time || All others || 00010003 || zlib || 0000001E || 00010000 || 00000003 || {{yes}} || {{yes}} || {{no}} || {{no}} ||  ||
|-
|-
| rowspan="2" | Ratchet & Clank. Tools of Destruction || *_uncached.psarc || 00010002 || zlib || 0000001E || 00010000 || 00000003 (ignorecase + absolute) || per-file compress || Contains not-compressed audio, and other compressed files
| The Last Of Us || All ? || 00010003 || zlib || 0000001E || 00010000 || 00000000 || {{no}} || {{no}} ||  ||  || ||  
|-
|-
| All others || 00010002 || zlib || 0000001E || 00010000 || 00000003 (ignorecase + absolute) || compress all ||  
| The Shoot || All || 00010004 || zlib || 0000001E || 00010000 || 00000002 || {{no}} || {{yes}} ||  ||  || ||  
|-
|-
| rowspan="2" | Ratchet & Clank. Quest for Booty || *_uncached.psarc || 00010002 || zlib || 0000001E || 00010000 || 00000003 (ignorecase + absolute) || per-file compress || Contains not-compressed audio, and other compressed files
| Time and Eternity || || || || || || || ||  ||  ||  ||  ||  
|-
|-
| All others || 00010002 || zlib || 0000001E || 00010000 || 00000003 (ignorecase + absolute) || compress all || global_cached.psarc contains TOC dupes!!! (icon0.png)
| Uncharted 2 || All ? || 00010003 || zlib || 0000001E || 00010000 || 00000000 || {{no}} || {{no}} ||  ||  || ||  
|-
|-
| rowspan="2" | Ratchet & Clank. A Crack in Time || *_uncached.psarc || 00010003 || zlib || 0000001E || 00010000 || 00000003 (ignorecase + absolute) || per-file compress || Contains not-compressed audio, and other compressed files
| Uncharted 3 || All || 00010003 || zlib || 0000001E || 00010000 || 00000000 || {{no}} || {{no}} ||  ||  || ||  
|-
|-
| All others || 00010003 || zlib || 0000001E || 00010000 || 00000003 (ignorecase + absolute) || compress all ||  
| Warhawk || ? || || || || || ||  ||  ||  ||  ||  ||  
|-
|-
| rowspan="3" | Ratchet & Clank. Into the Nexus || global_cached.psarc<BR />level_cached.psarc || 00010003 || zlib || 0000001E || 00010000 || 00000003 (ignorecase + absolute) || per-file compress || Contains not-compressed files, and other compressed files
| White Knight Chronicles II || All .psarc || 00010003 || zlib || 0000001E || 00010000 || 00000002 || {{no}} || {{yes}} || {{yes}} || {{no}} || ? || Contains not-compressed audio
|-
|-
| global_uncached.psarc<BR />global_sound_**.psarc || 00010003 || zlib || 0000001E || 00010000 || 00000003 (ignorecase + absolute) || per-file compress || Contains not-compressed audio, and other compressed files
| White Knight Chronicles II || All .psarc.sdat || 00010003 || zlib || 0000001E || 00010000 || 00000002 || {{no}} || {{yes}} || {{no}} || {{no}} || ? || Default compression, NPD signed psarcs
|-
|-
| All others || 00010003 || zlib || 0000001E || 00010000 || 00000003 (ignorecase + absolute) || compress all ||  
| Wipeout HD Fury || data01.psarc || 00010003 || zlib || 0000001E || 00010000 || 00000003 || {{yes}} || {{yes}} || {{yes}} || {{no}} ||  || Contains not-compressed audio
|-
|-
|Sonic the Fighters
| Wipeout HD Fury || All others || 00010003 || zlib || 0000001E || 00010000 || 00000003 || {{yes}} || {{yes}} || {{no}} ||  ||  ||  
|rom.psarc
|
|
|
|
|
|
|Contains arcade ROM files, audio, and UI graphics
|-
| The Last Of Us || All ? || 00010003 || zlib || 0000001E || 00010000 || 00000000 (no flags) ||  ||
|-
| The Shoot || All || 00010004 || zlib || 0000001E || 00010000 || 00000002 (absolute) ||  ||
|-
| Time and Eternity ||  || ||  ||  ||  ||  ||  ||
|-
| Uncharted 2 || All ? || 00010003 || zlib || 0000001E || 00010000 || 00000000 (no flags) ||  ||
|-
| Uncharted 3 || All || 00010003 || zlib || 0000001E || 00010000 || 00000000 (no flags) ||  ||
|-
| Warhawk || ? ||  ||  ||  ||  ||  ||  ||
|-
| rowspan="2" | White Knight Chronicles II || All .psarc || 00010003 || zlib || 0000001E || 00010000 || 00000002 (absolute) || no compress || Contains not-compressed audio
|-
| All .psarc.sdat || 00010003 || zlib || 0000001E || 00010000 || 00000002 (absolute) || compress all || Default compression, NPD signed psarcs
|-
| rowspan="2" | Wipeout HD Fury || data01.psarc || 00010003 || zlib || 0000001E || 00010000 || 00000003 (ignorecase + absolute) || no compress || Contains not-compressed audio
|-
| All others || 00010003 || zlib || 0000001E || 00010000 || 00000003 (ignorecase + absolute) || compress all ||  
|-
|-
! colspan="13" {{cellcolors|lightblue}} {{icon content ps4}}
! colspan="13" {{cellcolors|lightblue}} {{icon content ps4}}
|-
|-
! colspan="2" | Game/App info !! colspan="5" | PSARC Header info !! rowspan="2" | Compression<BR />Method !! rowspan="2" | Notes
! colspan="2" | Game/App info !! colspan="5" | PSARC Header info !! colspan="2" | PSARC Manifest info !! colspan="3" | PSARC TOC info !! rowspan="2" | Notes
|-
|-
! TITLE !! PSARC files || Version<BR />(offset 0x04) !! Compression<BR />(offset 0x08) !! TOC entry size<BR />(offset 0x10) !! Block Size<BR />(offset 0x18) !! Flags<BR />(offset 0x1C)
! TITLE !! PSARC files || Version<BR />(offset 0x04) !! Compression<BR />(offset 0x08) !! TOC entry size<BR />(offset 0x10) !! Block Size<BR />(offset 0x18) !! Flags<BR />(offset 0x1C) !! ignorecase !! absolute !! no<BR />compress !! per-file<BR />compress !! TOC Dupes
|-
|-
| No Man's Sky || *.pak  || 00010004 || zlib || 0000001E || 00010000 || 00000001 (ignorecase)  || all compress? || .PAK files are actually PSARC files, see https://www.youtube.com/watch?v=xlJfy1dvmGI <abbr title="the original PSARC uses flag --ignorecase it can be seen at minute 1:12 but when he rebuilds it he uses the flag --absolute instead, this is wrong though the game seems to dont care but is important and can cause some of the files to dont load">there is a mistake in the video</abbr>
| VidZone || ? || 00010004 || zlib || 0000001E || 00010000 || 00000000 || {{no}} || {{no}} || ||  ||  ||  
|-
| VidZone || vidzone*.db.psarc || 00010004 || zlib || 0000001E || 00010000 || 00000000 (no flags) || compress all || Vidzone is a web service, the .psarc is hosted in the web
|-
! colspan="13" {{cellcolors|lightblue}} {{icon content psvita}}
|-
! colspan="2" | Game/App info !! colspan="5" | PSARC Header info !! rowspan="2" | Compression<BR />Method !! rowspan="2" | Notes
|-
! TITLE !! PSARC files || Version<BR />(offset 0x04) !! Compression<BR />(offset 0x08) !! TOC entry size<BR />(offset 0x10) !! Block Size<BR />(offset 0x18) !! Flags<BR />(offset 0x1C)
|-
| Gravity Rush || Gravite.psarc || 00010004 || zlib || 0000001E || 00010000 || 00000000 (no flags) ||  ||
|-
| Chasm || content.psarc || 00010004 || zlib || 0000001E ||00010000 || 00000000 (no flags) ||  ||  
|}
|}
*Special rebuild notes:
**Mass effect 3 MAIN.PSARC contains a group of generic files compressed with level 9, and another group of .TXT, .BIN, and .BIK videos not compressed at all. In the creation options suggested above in the table the compression level is not defined and this means all them will use the default compression level 9 (so the .BIK files will have a ridiculous 1% or 2% of compression ratio because is the max they will admit). This is not how the original file was created (but works), the correct way to rebuild it is by defining specific compression levels "per file" in a predefined .xml
**Killzone 3 data_ps3.psarc (BCES01007 version) contains 8324 files (included 5.3GB of audio files for 21 languages with a compression of around 50%)... 2883 of all the files uses the same path/filenames repeated up to 3 times (because was created using 3 or more different working directories). This duplication of paths/filenames inside the .psarc in the practise means when doing a standard extraction 2833 files will be missing, overwrited, or they will give an error at extraction time, the correct way to mess with it is by doing several partiall extractions to different directories, and rebuild it by using a preconfigured .xml where the different paths for each file are specifyed, when rebuilding is also needed to use the --strip option several times to remove part of the paths from all the different working directories, this way the paths/filenames will be duplicated inside the .psarc archive (but are different files located at different positions and with a different ID number assigned).
**Ape Escape target.psarc includes "dupes" (or duplicated files) in the TOC (table of contents) of the psarc archive. This method used at creation time basically works by making several entries of the TOC to point to the same file, this way a single file inside the psarc is indexed several times in the TOC and can be accessed from several different paths/filenames. The only way to identify this dupes before extraction is by reading the TOC of the psarc for all the files and compare wich position are pointing to. As an example the original size of target.psarc is 328mb... after a "standard" extraction is 2.52GB (this extraction doesnt identify the dupes so are extracted several times under different paths/filenames)... if you try to rebuild it again his final size will be much bigger than the original target.psarc


*Other games that probably uses PSARC's
*Other games that probably uses PSARC's
Line 1,263: Line 552:


{{File Formats}}
{{File Formats}}
<noinclude>
<noinclude>[[Category:Main]]</noinclude>
[[Category:Main]]
</noinclude>
Please note that all contributions to PS3 Developer wiki are considered to be released under the GNU Free Documentation License 1.2 (see PS3 Developer wiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To protect the wiki against automated edit spam, we kindly ask you to solve the following hCaptcha:

Cancel Editing help (opens in new window)