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 8: Line 8:




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)


The compression algorithms, the PS3 system, and the .psarc format, allows for 9 compression levels but in the practice 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)


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) doesn't allow much compression because are already compressed originally (as example, max compression ratio for .BIK video and .MP3 audio doesn't reach 1% or 2%). For this reason is better not to 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
 
Very small files (smaller than 100 bytes or so) as well as dummy files (0 bytes) doesn't 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 applied 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>
<small>
Line 20: Line 19:


=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:
Line 37: Line 35:
| 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 '''major version''', next 2 bytes is the '''minor version'''
|-
|-
| 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)<br>'''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 || '''toc 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 || '''toc entry 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 || '''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:#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 || 0 = '''relative''' paths (default)<br>1 = '''ignorecase''' paths<br>2 = '''absolute''' paths
|}
|}


*'''Relative''' (default, no flags)
*'''Relative''' (default, no flags)
**Default value when the .psarc is created from command line or an .xml and no special access paths modes are specified
**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''' doesn't have an slash character at the start of every line, the system accesses the files exactly like if the .psarc was a folder itself
**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"'''
**e.g: '''Folder/File.bin"'''
**In the games that uses .psarc's without flags (like ''uncharted'' series or ''the last of us'') is possible to replace the psarc by a folder with the same name of the psarc and his contents decompressed inside
**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
*'''Ignorecase''' flag
Line 66: Line 64:


==TOC Table==
==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"
|-
! Offset !! Size !! Name !! Example !! Value (conversion) !! Notes
|+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.
|-
| style="background-color:#6666ff;" | 0x34 || style="background-color:#6666ff;" | 0x05 || '''uncompressed size''' || 00 00 01 79 D9 || 96729 || Size of this entry once uncompressed.
|-
| 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">
      <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 applied "per-block", is possible 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


===Manifest===
===Manifest===
Manifest is the first file inside the psarc filetable, doesn't appears as a file when using the '''--list''' command and doesn't have an assigned '''ID'''
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'''


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 "/"
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 "/"
Line 117: Line 80:
There are several versions of PSARC related tools, features has been implemented along the different versions and is hard to keep a record of them, please help filling the info in the page
There are several versions of PSARC related tools, features has been implemented along the different versions and is hard to keep a record of them, please help filling the info in the page


GUI versions are derived from the command line versions
GUI versions are derivated from the command line versions


==Open PSARC PS3 Extractor==
==Open PSARC PS3 Extractor==
Line 138: Line 101:


==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 165: Line 127:


==PSARC==
==PSARC==
{{Missingfiles}}
  1.60.008 SDK : x
  1.60.008 SDK : x
  1.92.001 SDK : x
  1.92.001 SDK : x
Line 175: Line 136:
  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:\>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 192: Line 153:
  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 201: Line 162:
  --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 220: Line 181:
  --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>}}
}}


===dtd===
===dtd===
Line 230: Line 191:
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:\>psarc.exe dtd'''<nowiki>
<!ELEMENT psarc (create|extract)+>
<!ELEMENT psarc (create|extract)+>


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


*DTD Notes:
*DTD Notes:
Line 299: Line 260:


To use an .xml is needed to prepare it based in this layout
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>
{{Boxframe2|content=
This is the xml representation of the DTD layout containing all the elements and attributes availables together, is only for wiki purpose
{{Boxcode|content=<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 314: Line 277:
</psarc>
</psarc>
</syntaxhighlight>}}
</syntaxhighlight>}}
*The purpose of this XML is to use it as a base layout containing all, but is not possible 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...
*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
*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:
When the xml is ready you can run it this way:
{{Keyboard|content=<syntaxhighlight lang="bash">C:\>psarc.exe --xml=C:\DTD_Layout.xml</syntaxhighlight>}}
{{Keyboard|content=
'''C:\>psarc.exe --xml=C:\DTD_Layout.xml'''
}}


The options '''--verbose''', '''--debug''', and '''--quiet''' cant be used inside the xml, so if needed are specifyed in the command line, this way:
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=<syntaxhighlight lang="bash">C:\>psarc.exe --debug --xml=C:\DTD_Layout.xml</syntaxhighlight>}}
{{Keyboard|content=
'''C:\>psarc.exe --debug --xml=C:\DTD_Layout.xml'''
}}


===verify===
===verify===
Line 327: Line 295:
*Output info per-file is: Validating <file ID/number>: - file path inside psarc archive - (file original size in bytes)
*Output info per-file is: Validating <file ID/number>: - file path inside psarc archive - (file original size in bytes)


{{Keyboard|content=<syntaxhighlight lang="bash">
{{Keyboard|content=
C:\>psarc.exe verify "C:\psarctests\source files\test.psarc"
'''C:\>psarc.exe verify "C:\psarctests\source files\test.psarc"'''
Verifying C:\psarctests\source files\test.psarc
Verifying C:\psarctests\source files\test.psarc
Validating 1: dummy.txt (0 bytes)
Validating 1: dummy.txt (0 bytes)
Line 335: Line 303:
Validating 4: PNGfolder1/PNGfolder2/PNGfolder3/Image3.png (6142 bytes)
Validating 4: PNGfolder1/PNGfolder2/PNGfolder3/Image3.png (6142 bytes)
Archive OK
Archive OK
</syntaxhighlight>}}
}}


===dump===
===dump===
Line 341: Line 309:
*Output info per-file is: file path inside psarc archive - file original size - file compressed size - file block start offset ?
*Output info per-file is: file path inside psarc archive - file original size - file compressed size - file block start offset ?


{{Keyboard|content=<syntaxhighlight lang="bash">
{{Keyboard|content=
C:\>psarc.exe dump "C:\psarctests\source files\test.psarc"
'''C:\>psarc.exe dump "C:\psarctests\source files\test.psarc"'''
Dumping C:\psarctests\source files\test.psarc
Dumping C:\psarctests\source files\test.psarc
dummy.txt  os=0 cs=0 fb=1
dummy.txt  os=0 cs=0 fb=1
Line 348: Line 316:
JPGfolder1/JPGfolder2/Image2.jpg  os=12524 cs=209 fb=97
JPGfolder1/JPGfolder2/Image2.jpg  os=12524 cs=209 fb=97
PNGfolder1/PNGfolder2/PNGfolder3/Image3.png  os=6142 cs=6142 fb=98
PNGfolder1/PNGfolder2/PNGfolder3/Image3.png  os=6142 cs=6142 fb=98
</syntaxhighlight>}}
}}


===list===
===list===
Line 355: Line 323:
*In the compression percentage: 100% is no reduction, 0% is a huge reduction
*In the compression percentage: 100% is no reduction, 0% is a huge reduction


{{Keyboard|content=<syntaxhighlight lang="bash">
{{Keyboard|content=
C:\>psarc.exe list "C:\psarctests\source files\test.psarc"
'''C:\>psarc.exe list "C:\psarctests\source files\test.psarc"'''
Listing C:\psarctests\source files\test.psarc
Listing C:\psarctests\source files\test.psarc
dummy.txt (0/0 100%)
dummy.txt (0/0 100%)
Line 362: Line 330:
JPGfolder1/JPGfolder2/Image2.jpg (209/12524 1%)
JPGfolder1/JPGfolder2/Image2.jpg (209/12524 1%)
PNGfolder1/PNGfolder2/PNGfolder3/Image3.png (6142/6142 100%)
PNGfolder1/PNGfolder2/PNGfolder3/Image3.png (6142/6142 100%)
</syntaxhighlight>}}
}}


{{Boxframe2|content=
{{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}}
{{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>}}
{{Keyboard|content='''C:\>psarc.exe list "C:\psarctests\source files\test.psarc" > c:\psarctests\filelist.txt'''}}
}}
}}


Line 375: Line 343:


====create by directory====
====create by directory====
Creates a psarc using the contents of a specified folder and all subfolders. Is only available when using an .xml because command line doesn't allow to specify a source folder
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 control of the ID's that will be assigned to each file in the '''manifest'''). Cant be used to rebuild psarcs
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


Note in the next example the file dummy.txt (located in the root of the folder in windows, so considered first) has been archived after BMPfolder1
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


{{Boxcode|title=Create_by_directory.xml|code=<syntaxhighlight lang="xml">
{{Boxcode|content=CREATE by_directory.xml<syntaxhighlight lang="xml">
<psarc>
<psarc>
<create archive="C:\psarctests\by_directory.psarc" absolute="false" ignorecase="false">
<create archive="C:\psarctests\by_directory.psarc" absolute="false" ignorecase="false">
Line 390: Line 358:
</psarc>
</psarc>
</syntaxhighlight>}}
</syntaxhighlight>}}
{{Keyboard|content=<syntaxhighlight lang="bash">
{{Keyboard|content=
C:\>psarc.exe --xml="c:\psarctests\CREATE by_directory.xml"
'''C:\>psarc.exe --xml="c:\psarctests\CREATE by_directory.xml"'''
Strip: C:\psarctests\source files\test
Strip: C:\psarctests\source files\test
Flags: relative
Flags: relative
Line 413: Line 381:
       99.9%: Compression Ratio
       99.9%: Compression Ratio
           9: Compression Level
           9: Compression Level
C:\>psarc.exe list C:\psarctests\by_directory.psarc
'''C:\>psarc.exe list C:\psarctests\by_directory.psarc'''
Listing C:\psarctests\by_directory.psarc
Listing C:\psarctests\by_directory.psarc
BMPfolder1/Image1.bmp (8018/6220854 0%)
BMPfolder1/Image1.bmp (8018/6220854 0%)
Line 419: Line 387:
JPGfolder1/JPGfolder2/Image2.jpg (209/12524 1%)
JPGfolder1/JPGfolder2/Image2.jpg (209/12524 1%)
PNGfolder1/PNGfolder2/PNGfolder3/Image3.png (157/6142 2%)
PNGfolder1/PNGfolder2/PNGfolder3/Image3.png (157/6142 2%)
</syntaxhighlight>}}
}}


====create by filelist====
====create by filelist====
Line 439: Line 407:


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:
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>}}
{{Keyboard|content='''C:\>psarc.exe create --strip="C:\psarctests\source files\test" --output=C:\psarctests\by_filelist.psarc --inputfile="C:\psarctests\source files\filelist.txt"'''}}


Or you can prepare an .xml that contains the path to the filelist.txt
Or you can prepare an .xml that contains the path to the filelist.txt
{{Boxcode|title=Create_by_filelist.xml|code=<syntaxhighlight lang="xml">
{{Boxcode|content=CREATE by_filelist.xml<syntaxhighlight lang="xml">
<psarc>
<psarc>
<create archive="C:\psarctests\by_filelist.psarc" absolute="false" ignorecase="false">
<create archive="C:\psarctests\by_filelist.psarc" absolute="false" ignorecase="false">
Line 453: Line 421:


Then run the contents of the .xml this way:
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>}}
{{Keyboard|content='''C:\>psarc.exe --xml="c:\psarctests\CREATE by_filelist.xml"'''}}


The output of the tool is the same in both cases (except the InputFile not present when using an xml)
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">
{{Keyboard|content=
Strip: C:\psarctests\source files\test
Strip: C:\psarctests\source files\test
Flags: relative
Flags: relative
Line 482: Line 450:
       99.9%: Compression Ratio
       99.9%: Compression Ratio
           9: Compression Level
           9: Compression Level
C:\>psarc.exe list C:\psarctests\by_filelist.psarc
'''C:\>psarc.exe list C:\psarctests\by_filelist.psarc'''
Listing C:\psarctests\by_filelist.psarc
Listing C:\psarctests\by_filelist.psarc
dummy.txt (0/0 100%)
dummy.txt (0/0 100%)
Line 488: Line 456:
JPGfolder1/JPGfolder2/Image2.jpg (209/12524 1%)
JPGfolder1/JPGfolder2/Image2.jpg (209/12524 1%)
PNGfolder1/PNGfolder2/PNGfolder3/Image3.png (157/6142 2%)
PNGfolder1/PNGfolder2/PNGfolder3/Image3.png (157/6142 2%)
</syntaxhighlight>}}
}}


====create by file====
====create by file====
Line 499: Line 467:
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
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">
{{Boxcode|content=CREATE by_file.xml<syntaxhighlight lang="xml">
<psarc>
<psarc>
<create archive="C:\psarctests\by_file.psarc" absolute="false" ignorecase="false">
<create archive="C:\psarctests\by_file.psarc" absolute="false" ignorecase="false">
Line 512: Line 480:
</psarc>
</psarc>
</syntaxhighlight>}}
</syntaxhighlight>}}
{{Keyboard|content=<syntaxhighlight lang="bash">
{{Keyboard|content=
C:\>psarc.exe --xml="c:\psarctests\CREATE by_file.xml"
C:\>psarc.exe --xml="c:\psarctests\CREATE by_file.xml"
Strip: C:\psarctests\source files\test
Strip: C:\psarctests\source files\test
Line 538: Line 506:
       99.8%: Compression Ratio
       99.8%: Compression Ratio
           9: Compression Level
           9: Compression Level
C:\>psarc.exe list C:\psarctests\by_file.psarc
'''C:\>psarc.exe list C:\psarctests\by_file.psarc'''
Listing C:\psarctests\by_file.psarc
Listing C:\psarctests\by_file.psarc
dummy.txt (0/0 100%)
dummy.txt (0/0 100%)
Line 544: Line 512:
JPGfolder1/JPGfolder2/Image2.jpg (209/12524 1%)
JPGfolder1/JPGfolder2/Image2.jpg (209/12524 1%)
PNGfolder1/PNGfolder2/PNGfolder3/Image3.png (6142/6142 100%)
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...
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...
Line 550: Line 518:
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)
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">
{{Boxcode|content=CREATE by_file_paradox<syntaxhighlight lang="xml">
<psarc>
<psarc>
<create archive="C:\psarctests\egg.psarc">
<create archive="C:\psarctests\egg.psarc">
Line 568: Line 536:
</psarc>
</psarc>
</syntaxhighlight>}}
</syntaxhighlight>}}
{{Keyboard|content=<syntaxhighlight lang="bash">
{{Keyboard|content=
C:\>psarc.exe --xml="c:\psarctests\CREATE by_file_paradox.xml"
'''C:\>psarc.exe --xml="c:\psarctests\CREATE by_file_paradox.xml"'''
Strip: C:\psarctests\source files\test
Strip: C:\psarctests\source files\test
Flags: relative
Flags: relative
Line 626: Line 594:
       -44.8%: Compression Ratio
       -44.8%: Compression Ratio
           9: Compression Level
           9: Compression Level
C:\>psarc.exe list C:\psarctests\egg.psarc
'''C:\>psarc.exe list C:\psarctests\egg.psarc
Listing C:\psarctests\egg.psarc
Listing C:\psarctests\egg.psarc
chicken.psarc (143/174 82%)
chicken.psarc (143/174 82%)
C:\>psarc.exe list C:\psarctests\chicken.psarc
'''C:\>psarc.exe list C:\psarctests\chicken.psarc
Listing C:\psarctests\chicken.psarc
Listing C:\psarctests\chicken.psarc
egg.psarc (69/105 65%)
egg.psarc (69/105 65%)
</syntaxhighlight>}}
}}


----
----
Line 650: Line 618:
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
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">
{{Keyboard|content=
C:\>psarc.exe extract --input="C:\psarctests\source files\test.psarc" --to="C:\psarctests\test"
'''C:\>psarc.exe extract --input="C:\psarctests\source files\test.psarc" --to="C:\psarctests\test"'''
Extracting: dummy.txt (0 bytes)
Extracting: dummy.txt (0 bytes)
Extracting: BMPfolder1/Image1.bmp (6220854 bytes)
Extracting: BMPfolder1/Image1.bmp (6220854 bytes)
Extracting: JPGfolder1/JPGfolder2/Image2.jpg (12524 bytes)
Extracting: JPGfolder1/JPGfolder2/Image2.jpg (12524 bytes)
Extracting: PNGfolder1/PNGfolder2/PNGfolder3/Image3.png (6142 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"
'''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: dummy.txt (0 bytes)
Extracting: BMPfolder1/Image1.bmp (6220854 bytes)
Extracting: BMPfolder1/Image1.bmp (6220854 bytes)
Extracting: JPGfolder1/JPGfolder2/Image2.jpg (12524 bytes)
Extracting: JPGfolder1/JPGfolder2/Image2.jpg (12524 bytes)
Extracting: PNGfolder1/PNGfolder2/PNGfolder3/Image3.png (6142 bytes)
Extracting: PNGfolder1/PNGfolder2/PNGfolder3/Image3.png (6142 bytes)
</syntaxhighlight>}}
}}


'''extract all (xml)'''
'''extract all (xml)'''


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


====extract by file====
====extract by file====
This extraction method is only available when using an xml because command line doesnt allows to specify files inside the archive
This extraction method is only available when using an xml because command line doesnt allows to specify files inside the archive


{{Boxcode|title=Extract_by_file.xml|code=<syntaxhighlight lang="xml">
{{Boxcode|content=EXTRACT by_file.xml<syntaxhighlight lang="xml">
<psarc>
<psarc>
<extract archive="C:\psarctests\source files\test.psarc" to="C:\psarctests\by_file">
<extract archive="C:\psarctests\source files\test.psarc" to="C:\psarctests\by_file">
Line 689: Line 657:
</psarc>
</psarc>
</syntaxhighlight>}}
</syntaxhighlight>}}
{{Keyboard|content=<syntaxhighlight lang="bash">
{{Keyboard|content=
C:\>psarc.exe --xml="c:\psarctests\EXTRACT by_file.xml"
'''C:\>psarc.exe --xml="c:\psarctests\EXTRACT by_file.xml"'''
Extracting: BMPfolder1/Image1.bmp (6220854 bytes)
Extracting: BMPfolder1/Image1.bmp (6220854 bytes)
</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">
<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\source files\test.psarc" to="C:\psarctests\by_file" stripall="true" skipmissingfiles="false" overwrite="true">
Line 707: Line 675:
**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
===Other options===
====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==
Line 743: Line 683:


Download link: http://aldostools.org/ps3_psarc_gui.rar
Download link: http://aldostools.org/ps3_psarc_gui.rar
=PSARC 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
*http://findandreplace.codeplex.com/
*http://fart-it.sourceforge.net/
*http://textmechanic.com/Remove-Duplicate-Lines.html


=Rebuilding PSARC files=
=Rebuilding PSARC files=
Line 755: Line 689:
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
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


{{Boxframe3|content='''Rebuilding PSARC files, step-by-step summary'''
{{Boxframe1|content='''Rebuilding PSARC files, step-by-step summary'''
* Step 1 - Identify compression method, archive flags, and verify default structure sizes
* Step 1 - Identify compression method, archive flags, and verify default structure sizes
* Step 2 - Identify if per-file compression was used <!-- and dupes --->
* 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 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 3a - If per-file compression was used, rebuild with the method "by file"
* Step 4 - Verify
}}
}}


Line 772: Line 704:


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:
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">
{{Boxcode|content=<syntaxhighlight lang="xml">
<psarc>
<psarc>
<create archive="C:\psarctests\by_file.psarc" absolute="true" ignorecase="true">
<create archive="C:\psarctests\by_file.psarc" absolute="true" ignorecase="true">
Line 780: Line 712:


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" -->
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">
{{Boxcode|content=<syntaxhighlight lang="xml">
<psarc>
<psarc>
<create archive="C:\psarctests\by_file.psarc" absolute="true" ignorecase="true" blocksize="65536">
<create archive="C:\psarctests\by_file.psarc" absolute="true" ignorecase="true" blocksize="65536">
Line 789: Line 721:
'''Step2'''
'''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)
Now is needed to know if the psarc uses per-file compression (if some of the files inside the archive ara 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
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
Line 799: Line 731:
**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 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:
**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">
{{Boxcode|content=<syntaxhighlight lang="xml">
<psarc>
<psarc>
<create archive="C:\psarctests\by_file.psarc" absolute="true" ignorecase="true" blocksize="65536">
<create archive="C:\psarctests\by_file.psarc" absolute="true" ignorecase="true" blocksize="65536">
Line 819: Line 751:
**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
**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


----
==Generating a filelist.txt or xml by using regular expressions==


*The file paths inside filelist.txt or inside an xml admits 2 formats:
*The file paths inside filelist.txt or inside an xml admits 2 formats:
Line 829: Line 761:
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)
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 a filelist.txt by using regular expressions===
===Generating a filelist===
{{Boxframe3|content='''Generating a filelist.txt, step-by-step summary'''
First generate a .txt file containing the output of the '''list''' comand
* Step 1 - Save list command output as a .txt
{{Keyboard|content='''C:\>psarc.exe list "C:\psarctests\source files\test.psarc" > "C:\psarctests\filelist.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):
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
  Listing C:\psarctests\source files\test.psarc
Line 851: Line 771:
  PNGfolder1/PNGfolder2/PNGfolder3/Image3.png (6142/6142 100%)
  PNGfolder1/PNGfolder2/PNGfolder3/Image3.png (6142/6142 100%)
   
   
<br>}}


*'''Step 2 - Remove first line'''
*'''Replacing slashes''' (this step is not really needed, both slashes are valid, but is good to do it to standarize all paths formats, otherway is a mess)
{{Boxframe1|content=
find:
find (and replace by nothing):
/
replace by:
\\
The resulting file:
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%)
*'''Removing first line'''
find:
  Listing.*\n
  Listing.*\n
replace by:
sourcepath
The resulting file:
The resulting file:
  dummy.txt (0/0 100%)
  sourcepathdummy.txt (0\0 100%)
  BMPfolder1/Image1.bmp (8018/6220854 0%)
  BMPfolder1\Image1.bmp (8018\6220854 0%)
  JPGfolder1/JPGfolder2/Image2.jpg (209/12524 1%)
  JPGfolder1\JPGfolder2\Image2.jpg (209\12524 1%)
  PNGfolder1/PNGfolder2/PNGfolder3/Image3.png (6142/6142 100%)
  PNGfolder1\PNGfolder2\PNGfolder3\Image3.png (6142\6142 100%)
   
   
<br>}}
*'''Removing parenthesis'''
 
find: (note there is an space as the first character to find)
*'''Step 3 - Remove parentheses'''
  \(.*\)\r\n
{{Boxframe1|content=
replace by:
find (and replace by nothing):
\r\nsourcepath
[^\b]\(.*\)
The resulting file:
The resulting file:
  dummy.txt
  sourcepathdummy.txt
  BMPfolder1/Image1.bmp
  sourcepathBMPfolder1\Image1.bmp
  JPGfolder1/JPGfolder2/Image2.jpg
  sourcepathJPGfolder1\JPGfolder2\Image2.jpg
  PNGfolder1/PNGfolder2/PNGfolder3/Image3.png
  sourcepathPNGfolder1\PNGfolder2\PNGfolder3\Image3.png
   
  sourcepath
<br>}}


*'''Step 4 - Remove last line'''
*'''Removing 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:
find:
  /
  \r\nsourcepath$
replace by:
replace by: nothing, the resulting file:
\\
  sourcepathdummy.txt
The resulting file:
  sourcepathBMPfolder1\Image1.bmp
  dummy.txt
  sourcepathJPGfolder1\JPGfolder2\Image2.jpg
  BMPfolder1\Image1.bmp
  sourcepathPNGfolder1\PNGfolder2\PNGfolder3\Image3.png
  JPGfolder1\JPGfolder2\Image2.jpg
  PNGfolder1\PNGfolder2\PNGfolder3\Image3.png
<br>}}


*'''Step 6 - Add local paths (optional, recommended)'''
*'''Replacing sourcepath by a real path''' (this step was not really needed because you could use the real path in the steps before, but i prefer to make the change in this last step because all the previous ones are generic)
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)
Now you can replace the word "sourcepath" we have been using as a placeholder by the folder path 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:
find:
  ^
  sourcepath
replace by:
replace by:
  C:\\psarctests\\source files\\test\\
  C:\psarctests\source files\test\
The resulting file:
The resulting file:
  C:\psarctests\source files\test\dummy.txt
  C:\psarctests\source files\test\dummy.txt
Line 916: Line 828:
  C:\psarctests\source files\test\JPGfolder1\JPGfolder2\Image2.jpg
  C:\psarctests\source files\test\JPGfolder1\JPGfolder2\Image2.jpg
  C:\psarctests\source files\test\PNGfolder1\PNGfolder2\PNGfolder3\Image3.png
  C:\psarctests\source files\test\PNGfolder1\PNGfolder2\PNGfolder3\Image3.png
<br>}}
And thats all, this is a perfect filelist.txt that can be used for the rebuild method '''by filelist''' (usefull when the psarc doesnt uses per-file compression)
 
*'''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===
===Generating a XML===
{{Boxframe3|content='''Generating a xml, step-by-step summary'''
The way to create an xml is pretty similar, first generate a .xml file containing the output of the '''list''' comand
* Step 1 - Save list command output as a list.txt
{{Keyboard|content='''C:\>psarc.exe list "C:\psarctests\source files\test.psarc" > "C:\psarctests\filelist.xml"'''}}
* Step 2 - Replace slashes
The file generated by the list command will have this content (note there is en empty line at the end):
* Step 3 - Replace first line start (preserves original .psarc path)
{{Boxcode|content=<syntaxhighlight lang="xml">
* 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
Listing C:\psarctests\source files\test.psarc
/dummy.txt (0/0 100%)
dummy.txt (0/0 100%)
/BMPfolder1/Image1.bmp (8018/6220854 0%)
BMPfolder1/Image1.bmp (8018/6220854 0%)
/JPGfolder1/JPGfolder2/Image2.jpg (209/12524 1%)
JPGfolder1/JPGfolder2/Image2.jpg (209/12524 1%)
/PNGfolder1/PNGfolder2/PNGfolder3/Image3.png (6142/6142 100%)
PNGfolder1/PNGfolder2/PNGfolder3/Image3.png (6142/6142 100%)


</syntaxhighlight>}}
</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'''
*'''Replacing slashes''' (this step is not really needed, both slashes are valid, but is good to do it to standarize all paths formats, otherway is a mess)
This step is to standarize paths formats
{{Boxframe1|content=
find:
find:
  /
  /
Line 974: Line 851:
  \\
  \\
The resulting file:
The resulting file:
{{Boxcode|code=<syntaxhighlight lang="xml">
{{Boxcode|content=<syntaxhighlight lang="xml">
Listing C:\psarctests\source files\test.psarc
Listing C:\psarctests\source files\test.psarc
\dummy.txt (0\0 100%)
dummy.txt (0\0 100%)
\BMPfolder1\Image1.bmp (8018\6220854 0%)
BMPfolder1\Image1.bmp (8018\6220854 0%)
\JPGfolder1\JPGfolder2\Image2.jpg (209\12524 1%)
JPGfolder1\JPGfolder2\Image2.jpg (209\12524 1%)
\PNGfolder1\PNGfolder2\PNGfolder3\Image3.png (6142\6142 100%)
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>}}
</syntaxhighlight>}}
}}
 
*'''Replacing first line'''
*'''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:
find:
  \.psarc\r\n
  Listing.*\n
replace by:
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\\
  <psarc>
<create archive="targetpsarc" absolute="false" ignorecase="false">
<compression type="zlib" enabled="true" />
<strip regex="sourcepath" />
<file path="sourcepath
The resulting file:
The resulting file:
{{Boxcode|code=<syntaxhighlight lang="xml">
{{Boxcode|content=<syntaxhighlight lang="xml">
<psarc>
<psarc>
<create archive="C:\psarctests\source files\test.psarc" absolute="false" ignorecase="false">
<create archive="targetpsarc" absolute="false" ignorecase="false">
<compression type="zlib" />
<compression type="zlib" enabled="true" />
<strip regex="C:\source\folder\" />
<strip regex="sourcepath" />
<file path="sourcepathdummy.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%)


<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>}}
</syntaxhighlight>}}
}}


*'''Step 5 - Replace first line end (for absolute flag)'''
*'''Replacing parenthesis'''
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:
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\\\\
  .\(.*\n
replace by:
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\\\\
  " />
<file path="sourcepath
The resulting file:
The resulting file:
{{Boxcode|code=<syntaxhighlight lang="xml">
{{Boxcode|content=<syntaxhighlight lang="xml">
<psarc>
<psarc>
<create archive="C:\psarctests\source files\test.psarc" absolute="true" ignorecase="false">
<create archive="targetpsarc" absolute="false" ignorecase="false">
<compression type="zlib" />
<compression type="zlib" enabled="true" />
<strip regex="C:\source\folder\" />
<strip regex="sourcepath" />
 
<file path="C:\source\folder\\dummy.txt (0\0 100%)
<file path="sourcepathdummy.txt" />
\BMPfolder1\Image1.bmp (8018\6220854 0%)
<file path="sourcepathBMPfolder1\Image1.bmp" />
\JPGfolder1\JPGfolder2\Image2.jpg (209\12524 1%)
<file path="sourcepathJPGfolder1\JPGfolder2\Image2.jpg" />
\PNGfolder1\PNGfolder2\PNGfolder3\Image3.png (6142\6142 100%)
<file path="sourcepathPNGfolder1\PNGfolder2\PNGfolder3\Image3.png" />
<file path="sourcepath
</syntaxhighlight>}}
</syntaxhighlight>}}
}}


*'''Step 6 - Replace parentheses (per-file compression autodetection)'''
*'''Replacing last line'''
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:
find:
[^\b]\(.*100.\)\r\n
<file path="sourcepath$
replace by:
replace by:
  " compressed="false" />\r\n\t\t<file path="C:\\source\\folder\\
</create>
  </psarc>
The resulting file:
The resulting file:
{{Boxcode|code=<syntaxhighlight lang="xml">
{{Boxcode|content=<syntaxhighlight lang="xml">
<psarc>
<psarc>
<create archive="C:\psarctests\source files\test.psarc" absolute="true" ignorecase="false">
<create archive="targetpsarc" absolute="false" ignorecase="false">
<compression type="zlib" />
<compression type="zlib" enabled="true" />
<strip regex="C:\source\folder\" />
<strip regex="sourcepath" />
<file path="sourcepathdummy.txt" />
<file path="sourcepathBMPfolder1\Image1.bmp" />
<file path="sourcepathJPGfolder1\JPGfolder2\Image2.jpg" />
<file path="sourcepathPNGfolder1\PNGfolder2\PNGfolder3\Image3.png" />
</create>
</psarc>
</syntaxhighlight>}}


<file path="C:\source\folder\\dummy.txt" compressed="false" />
*'''Replacing path placeholders'''
<file path="C:\source\folder\\BMPfolder1\Image1.bmp (8018\6220854 0%)
This step was not really needed because you could use the real path in the steps before, but i prefer to make the change in this last step because all the previous ones are generic
\JPGfolder1\JPGfolder2\Image2.jpg (209\12524 1%)
Now you can replace the word "sourcepath" we have been using as a placeholder by the folder path where the psarc contents are decompressed, e.g: '''C:\psarctests\source files\test\''', also replace the path "targetpsarc" where the psarc will be created, e.g: '''C:\psarctests\test.psarc'''
\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:
find:
  [^\b]\(.*\n
  sourcepath
replace by:
replace by:
  " />\r\n\t\t<file path="C:\\source\\folder\\
  C:\psarctests\source files\test\
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:
find:
  \t\t<file path="C:\\source\\folder\\$
  targetpsarc
replace by:
replace by:
  \t</create>\r\n</psarc>
  C:\psarctests\test.psarc
The resulting file:
The resulting file:
{{Boxcode|code=<syntaxhighlight lang="xml">
{{Boxcode|content=<syntaxhighlight lang="xml">
<psarc>
<psarc>
<create archive="C:\psarctests\source files\test.psarc" absolute="true" ignorecase="false">
<create archive="C:\psarctests\test.psarc" absolute="false" ignorecase="false">
<compression type="zlib" />
<compression type="zlib" enabled="true" />
<strip regex="C:\source\folder\" />
<strip regex="C:\psarctests\source files\test\" />


<file path="C:\source\folder\\dummy.txt" compressed="false" />
<file path="C:\psarctests\source files\test\dummy.txt" />
<file path="C:\source\folder\\BMPfolder1\Image1.bmp" />
<file path="C:\psarctests\source files\test\BMPfolder1\Image1.bmp" />
<file path="C:\source\folder\\JPGfolder1\JPGfolder2\Image2.jpg" />
<file path="C:\psarctests\source files\test\JPGfolder1\JPGfolder2\Image2.jpg" />
<file path="C:\source\folder\\PNGfolder1\PNGfolder2\PNGfolder3\Image3.png" compressed="false" />
<file path="C:\psarctests\source files\test\PNGfolder1\PNGfolder2\PNGfolder3\Image3.png" />
</create>
</create>
</psarc>
</psarc>
</syntaxhighlight>}}
</syntaxhighlight>}}
}}


*'''Step 9 - Absolute flag blind fix'''
Now is needed to verify all the common settings are fine (ive used default values for the replacements in the examples)
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)
 
*'''Adding per-file attributes''' (optional)
If the psarc uses per-file attributes now is needed to apply them by identifying filenames or file extensions, e.g: if we know the png images doesnt have compression it can be automatized this way:


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:
find:
  \\\\
  .png" />
replace by:
replace by:
  \\
  .png" compressed="false" />
The resulting file:
The resulting file:
{{Boxcode|code=<syntaxhighlight lang="xml">
{{Boxcode|content=<syntaxhighlight lang="xml">
<psarc>
<psarc>
<create archive="C:\psarctests\source files\test.psarc" absolute="true" ignorecase="false">
<create archive="C:\psarctests\test.psarc" absolute="false" ignorecase="false">
<compression type="zlib" />
<compression type="zlib" enabled="true" />
<strip regex="C:\source\folder\" />
<strip regex="C:\psarctests\source files\test\" />


<file path="C:\source\folder\dummy.txt" compressed="false" />
<file path="C:\psarctests\source files\test\dummy.txt" />
<file path="C:\source\folder\BMPfolder1\Image1.bmp" />
<file path="C:\psarctests\source files\test\BMPfolder1\Image1.bmp" />
<file path="C:\source\folder\JPGfolder1\JPGfolder2\Image2.jpg" />
<file path="C:\psarctests\source files\test\JPGfolder1\JPGfolder2\Image2.jpg" />
<file path="C:\source\folder\PNGfolder1\PNGfolder2\PNGfolder3\Image3.png" compressed="false" />
<file path="C:\psarctests\source files\test\PNGfolder1\PNGfolder2\PNGfolder3\Image3.png" compressed="false" />
</create>
</create>
</psarc>
</psarc>
</syntaxhighlight>}}
</syntaxhighlight>}}
}}


=Games or Apps using PSARC files=
=Games or Apps using PSARC files=
Line 1,179: Line 1,020:
|-
|-
| TEXTURES.PSARC ||  ||  ||  ||  ||  ||  ||  
| TEXTURES.PSARC ||  ||  ||  ||  ||  ||  ||  
|-
| 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
|-
|-
| Motorstorm Pacific Rift ||  ? || ||  ||  ||  ||  ||  ||   
| Motorstorm Pacific Rift ||  ? || ||  ||  ||  ||  ||  ||   
Line 1,205: Line 1,044:
|-
|-
| All others || 00010003 || zlib || 0000001E || 00010000 || 00000003 (ignorecase + absolute) || compress all ||  
| All others || 00010003 || zlib || 0000001E || 00010000 || 00000003 (ignorecase + absolute) || compress all ||  
|-
|Sonic the Fighters
|rom.psarc
|
|
|
|
|
|
|Contains arcade ROM files, audio, and UI graphics
|-
|-
| The Last Of Us || All ? || 00010003 || zlib || 0000001E || 00010000 || 00000000 (no flags) ||  ||  
| The Last Of Us || All ? || 00010003 || zlib || 0000001E || 00010000 || 00000000 (no flags) ||  ||  
Line 1,241: Line 1,070:
|-
|-
! 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)
|-
| 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 || vidzone*.db.psarc || 00010004 || zlib || 0000001E || 00010000 || 00000000 (no flags) || compress all || Vidzone is a web service, the .psarc is hosted in the web
| 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) ||  ||
|}
|}


Line 1,264: Line 1,081:


{{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)