Saving to an X File (Legacy)
Use the following procedure in legacy applications to save .x file templates and data to a .x file.
- Use the DirectXFileCreate function to create an IDirectXFile object.
- Use the IDirectXFile::RegisterTemplates method to inform the DirectX file system about any templates that you will use.
- Use the IDirectXFile::CreateSaveObject method to create an IDirectXFileSaveObject object.
- Use the IDirectXFileSaveObject::SaveTemplates method to save templates, if desired.
- Loop through the objects to save. For each top-level object, perform the following steps.
- Use the IDirectXFileSaveObject::CreateDataObject method to create an IDirectXFileData object as a top-level object in the file. If the top-level data object has optional child objects, add them to the object by using the appropriate method from the next step.
- Each IDirectXFileData object can have optional child objects if its template allows it. The child objects can be any of the three types of objects: IDirectXFileData, IDirectXFileDataReference, or IDirectXFileBinary. Loop through the objects you need to save, adding each optional child member to the object list in the manner appropriate to its type, as illustrated in the following steps. Then, if the object type is Data, call the IDirectXFileSaveObject::CreateDataObject method to create an IDirectXFileData object, and then call the IDirectXFileData::AddDataObject method to add it as a child of the object. If the object type is Data Reference, call the IDirectXFileData::AddDataReference method to create and add the data reference object as a child of the object. Or, if the object type is Binary, call the IDirectXFileData::AddBinaryObject method to create and add the binary object as a child of the object.
- Call the IDirectXFileSaveObject::SaveData method to save the data object and its children.
- Release the IDirectXFileData object.
- Release the IDirectXFileSaveObject object.
- Release the IDirectXFile object.