How the PS4 User ID Maps to Save Directories in Apollo-PS4
Apollo-PS4 maps each PlayStation 4 profile's 32-bit hexadecimal user ID to the path template /user/home/%08x/savedata/, ensuring every user maintains an isolated save data tree that other profiles cannot access.
The open-source save manager Apollo-PS4 (bucanero/apollo-ps4) relies on the console's native user identification system to partition save data storage. Understanding how the PS4 user ID system maps to save directories is essential for developers working with homebrew tools or analyzing PlayStation 4 file system structures. This mapping guarantees that each profile's game progress remains segregated under distinct directory hierarchies.
Understanding the PS4 User ID Structure
The PlayStation 4 assigns every user profile a unique 32-bit hexadecimal identifier represented as an eight-digit zero-padded value. Apollo-PS4 retrieves this identifier at startup through the OrbisPad configuration interface and stores it in apollo_config.user_id for subsequent path construction operations.
Base Path Template and Initialization
Defining the Save Data Root
In include/saves.h at line 34, the project defines the base directory template:
#define SAVES_PATH_HDD "/user/home/%08x/savedata/"
The %08x format specifier reserves exactly eight hexadecimal characters for the user ID insertion, producing consistent zero-padded directory names like 00000001 or 0000000A.
Retrieving the Current User ID
During initialization in main.c at line 246, Apollo-PS4 populates the user ID from the system pad configuration:
apollo_config.user_id = orbisPadGetConf()->userId;
This captures the active profile's identifier immediately upon application launch, ensuring all subsequent file operations target the correct user directory.
Constructing User-Specific File Paths
Apollo-PS4 uses snprintf operations to inject the hexadecimal user ID into file paths across three primary categories.
Save Game Binary Files
When reading or writing actual save data in source/saves.c at line 99, the code constructs the full path:
snprintf(keyPath, sizeof(keyPath),
SAVES_PATH_HDD "%s/%s.bin",
apollo_config.user_id,
save->title_id,
save->dir_name);
This generates paths resembling /user/home/00000001/savedata/CUSA00000/savedata.bin, where 00000001 represents the formatted user ID, CUSA00000 is the game's title identifier, and savedata.bin represents the specific save slot.
Icon and Metadata Assets
For user interface assets, source/menu_main.c at line 356 builds icon paths using a similar pattern:
snprintf(iconfile, sizeof(iconfile),
SAVE_ICON_PATH_HDD "%s/%s_icon0.png",
apollo_config.user_id,
selected_entry->title_id,
selected_entry->dir_name);
According to the bucanero/apollo-ps4 source code, these operations resolve to paths like /user/home/00000001/savedata_meta/user/CUSA00000_icon0.png, ensuring that thumbnail images and metadata files remain segregated per user.
Cross-User Isolation Mechanisms
By strictly formatting the user ID into the /user/home/ subdirectory path, Apollo-PS4 leverages the PlayStation 4's native file system permissions. Each profile's save data remains physically separated under distinct hexadecimal directories, preventing accidental overwrites or unauthorized access between different console users. The exec_cmd.c file at line 247 utilizes identical path construction logic for copy and download operations, maintaining consistent isolation across all file management functions.
Summary
- Apollo-PS4 retrieves the 32-bit user ID from
orbisPadGetConf()->userIdduring startup (main.cline 246). - The base path template
/user/home/%08x/savedata/defined ininclude/saves.hline 34 uses zero-padded hexadecimal formatting. - Save file paths combine the formatted user ID with title IDs and directory names via
snprintfoperations insource/saves.cline 99. - Icon and metadata files follow identical mapping patterns in
source/menu_main.cline 356 to maintain UI consistency. - This architecture enforces strict per-user data isolation on the PlayStation 4 file system.
Frequently Asked Questions
What hexadecimal format does Apollo-PS4 use for PS4 user IDs in directory paths?
Apollo-PS4 formats the 32-bit user ID as an eight-digit zero-padded hexadecimal string using the %08x specifier. This ensures consistent directory naming across all user profiles, producing paths like /user/home/0000000A/savedata/ where the value always occupies exactly eight characters regardless of the numeric value.
Where does the application retrieve the active user ID from?
The application obtains the current user ID from the OrbisPad configuration structure at startup. Specifically, main.c line 246 executes apollo_config.user_id = orbisPadGetConf()->userId, capturing the PlayStation 4's active profile identifier immediately upon launch before any file operations commence.
How does the mapping prevent users from accessing each other's save files?
By embedding the hexadecimal user ID directly into the /user/home/ path structure, Apollo-PS4 creates physically distinct directory trees for each profile. Since the PlayStation 4 operating system enforces file system permissions at the user directory level, this mapping guarantees that save data, icons, and metadata remain isolated to the specific profile that created them, preventing cross-contamination between users.
Which source files contain the path construction logic for save directories?
The primary definitions reside in include/saves.h (line 34) for base path templates, while source/saves.c (line 99) handles save file operations and source/menu_main.c (line 356) manages icon asset paths. Additional copy and download operations in source/exec_cmd.c (line 247) also utilize these macros for consistent path generation across the entire application.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →