Title development scenarios often require the reading and writing of files that are not required in the retail scenario. Examples of these types of files include profiling and tracing log files, test run results and so on. When these development-time files are read from, or written to, the hard drive, the file IO characteristics of the title are changed significantly from what they are when the title is running in retail mode. The file io performance of the retail title cannot be accurately measured if files needed only during development are stored on the hard drive.
An external USB drive can be used as an alternative place to store files required during development. By moving the storage of these files from the hard drive to a USB drive, the file io performance of your title under development will more closely match the retail scenario.
Before using an external USB storage device, you must format it as NTFS using a PC.
After formatting the drive for NTFS you need to place an empty file named $NoSurface in the root of the USB drive.
After the external drive has been inserted, the additional storage is visible to the title under the path d:\profiling. This directory will only be present when the title is running.
The following code sample demonstrates how to create a log file on the external USB storage device:
HANDLE hFile = CreateFile(L"d:\\profiling\\log.txt",
GENERIC_WRITE, // open for write
0, // do not share
NULL, // default security
CREATE_ALWAYS, // overwrite existing
FILE_ATTRIBUTE_NORMAL,// normal file
NULL); // no template
if (hFile != INVALID_HANDLE_VALUE)
{
// access log.txt
CloseHandle(hFile);
}
else
{
// file could not be created. USB drive likely not present
}
The presence, or absence, of d:\profling determines whether a USB drive is available. Note that in the example above the code is written to handle the case in which no USB drive is present. In this case, it’s likely the title would elect to store it’s development time files on the console.
The Xbox One console has several USB ports, so it’s possible that more than one external drive might be present. When looking for an external development drive, the system enumerates the USB ports in order and selects the first drive it finds. When a drive is selected, the system creates an XVD on the drive and mounts it at d:\profling. If more than one drive is present, it’s possible that the system may overwrite data on a drive you don’t intend when it creates the xvd used to store development files. As a result, it is highly recommended that only one drive be plugged in.
it’s also important that the USB drive not be unplugged from the console while the title is trying to write to it or read from it. Any such file io operations are not guaranteed to complete and the title can hang waiting for them to finish.
Note The USB drive must be inserted while the title is not running for it to show up when the title starts running. The USB drive is mounted on title start and won’t be recognized until the title is restarted if inserted while the title is running.
Files can be copied off of the USB drive using xbcp command line tool or the Xbox One Neighborhood. The following example uses xbcp to copy a log file from the USB drive back to the PC. The title must be running in order for the copy to succeed.
xbcp /x/title xd:\profiling\log.txt
Note it’s currently not possible to unplug the USB drive from the console, insert it into a PC and read the files directly. This capability is expected to be added in a future release.