项目介绍

hippie68/sfo 是一个托管在 GitHub 上的开源项目,主要使用 C 编写,目前获得 32 个 Star、8 次 Fork。

仓库全名
hippie68/sfo
Star 数
32
Fork 数
8
未关闭 Issue
3

README 摘要

sfo.c sfo.c can be compiled into a command line program, which is faster than the old "sfo" Bash script (roughly by factor 30). It is still compatible with the "pkgrename" and "fw" scripts (https://github.com/hippie68/pkgrename, https://github.com/hippie68/fw), making their output faster. It can be used to query or modify param.sfo data or to build new param.sfo files from scratch. Usage: sfo [OPTIONS] FILE Reads a…

完整内容见 GitHub 原始 README 或本页 。

常见问题

sfo 用什么语言开发?

主要使用 C 编写,目前有 32 个 Star。

如何获取 sfo 的源码?

可以直接克隆仓库:git clone https://github.com/hippie68/sfo.git,默认分支为 main;安装与运行步骤见仓库 README。

sfo 最近还在维护吗?

仓库最近一次更新为 2022年1月5日,当前有 3 个未关闭 Issue;Star 数为 32,可作为社区活跃度的参考。

关于

GitHub 原始描述(英文)

Fast C program that reads a file to print or modify its SFO parameters. Can be used for automation or to build param.sfo files from scratch. Also available as .exe file for the Windows command line.

描述取自 GitHub 官方 API,保持仓库作者书写的原文。

简要分析

热度分
80
价值分
24
活跃状态
活跃

语言占比

C
Shell

Release

贡献者

README

sfo.c

sfo.c can be compiled into a command line program, which is faster than the old “sfo” Bash script (roughly by factor 30). It is still compatible with the “pkgrename” and “fw” scripts (https://github.com/hippie68/pkgrename, https://github.com/hippie68/fw), making their output faster. It can be used to query or modify param.sfo data or to build new param.sfo files from scratch.

Usage: sfo [OPTIONS] FILE

Reads a file to print or modify its SFO parameters.
Supported file types:
  - PS4 param.sfo (print and modify)
  - PS4 disc param.sfo (print only)
  - PS4 PKG (print only)

The modification options (-a/--add, -d/--delete, -e/--edit, -s/--set) can be
used multiple times. Modifications are done in memory first, in the order in
which they appear in the program's command line arguments.
If any modification fails, all changes are discarded and no data is written:

  Modification  Fail condition
  --------------------------------------
  Add           Parameter already exists
  Delete        Parameter not found
  Edit          Parameter not found
  Set           None

Options:
  -a, --add TYPE PARAMETER VALUE  Add a new parameter, not overwriting existing
                                  data. TYPE must be either "int" or "str".
  -d, --delete PARAMETER          Delete specified parameter.
      --debug                     Print debug information.
      --decimal                   Display integer values as decimal numerals.
  -e, --edit PARAMETER VALUE      Change specified parameter's value.
  -f, --force                     Do not abort when modifications fail. Make
                                  option --new-file overwrite existing files.
  -h, --help                      Print usage information and quit.
      --new-file                  If FILE (see above) does not exist, create a
                                  new param.sfo file of the same name.
  -o, --output-file OUTPUT_FILE   Save the final data to a new file of type
                                  "param.sfo", overwriting existing files.
  -q, --query PARAMETER           Print a parameter's value and quit.
                                  If the parameter exists, the exit code is 0.
  -s, --set TYPE PARAMETER VALUE  Set a parameter, whether it exists or not,
                                  overwriting existing data.
  -v, --verbose                   Increase verbosity.
      --version                   Print version information and quit.

Examples

Viewing SFO parameters:

sfo param.sfo
sfo example.pkg --verbose --decimal

Modifying SFO parameters:

sfo -e title "Super Mario Bros." -d title_00 -s int pubtool_ver 0x123 param.sfo

Modifying SFO parameters but saving to a different file:

sfo -e title "Super Mario Bros." -d title_00 -s int pubtool_ver 0x123 param.sfo --output-file test.sfo

Extracting a param.sfo file from a PS4 PKG file:

sfo example.pkg --output-file param.sfo

Creating a new param.sfo file from scratch:

sfo --new-file -a str app_ver 01.00 -a str category gdk -a int attribute 12 param.sfo

Printing a single parameter:

$ sfo -q title param.sfo
Super Mario Bros.

Querying will return 0 if the parameter exists:

$ sfo -q title param.sfo
Super Mario Bros.
$ echo $?
0

$ sfo -q asdf param.sfo
$ echo $?
1

Use querying to save parameters in your scripts/tools, for example (Bash):

title=$(sfo -q title param.sfo)

Or parse them all (Bash):

i=0
while read -r line; do
  param[i]=${line%%=*}
  value[i]=${line#*=}
  ((i++))
done < <(sfo param.sfo)

How to compile

gcc sfo.c -O3 -s -o sfo

For Windows:

x86_64-w64-mingw32-gcc-win32 sfo.c -O3 -s -o sfo.exe

Windows binaries are available at https://github.com/hippie68/sfo/releases.

Troubleshooting

Option --debug prints the exact param.sfo file layout, making it easy to spot errors quickly.

Please report bugs or request features at https://github.com/hippie68/sfo/issues.

sfo (old Bash script)

Prints or modifies SFO parameters of a PS4 PKG or a param.sfo file. Providing a search string will output the value of that specific key only. Providing a replacement string will write it to the file (needs option -w).

Usage:

sfo [options] file [search] [replace]

Options:

-h  Display help
-w  Enable write mode

You can print all SFO info:

sfo param.sfo
sfo your-game.pkg

You can search for a specific key (case-insensitive), for example:

sfo param.sfo PUBTOOLINFO
sfo your-game.pkg content_id

You can also overwrite existing data, for example:

sfo -w param.sfo app_type 2

To overwrite integer data, you can use decimal or hexadecimal numbers.

Known issues:

  • Overwriting PKG files directly may will result in a broken PKG. Writing the original values will restore the PKG.

评论

暂无评论