C_GetRestartParentFileName

Call C_GetRestartParentFileName to obtain the parent file name for a restart analysis file.

void C_GetRestartParentFileName(

LPCTSTR lpFileName,

TOrcFxAPIHandle *lpBufferHandle,

int64_t *lpBufferLen,

int *lpStatus

);

Parameters

lpFileName (IN)

Points to a null-terminated string containing the name of the restart analysis file. This can be either a data file (.dat or .yml) or a simulation file (.sim).

lpBufferHandle (OUT)

Points to a variable in which a handle to the buffer containing the parent file name will be returned.

lpBufferLen (OUT)

Points to a variable in which the length of the buffer containing the parent file name will be returned.

lpStatus (OUT)

Points to a variable in which the status result for the function call will be returned.

Remarks

The parent file name is returned as a null-terminated string. If the specified file is not a restart file then the empty string is returned.

In order to extract the contents of the buffer, you must follow the call to C_GetRestartParentFileName with calls to C_CopyBuffer and C_FreeBuffer. Use the value returned in lpBufferLen to allocate a suitably sized buffer. Pass this to C_CopyBuffer to perform the copy. Finally, call C_FreeBuffer to free the buffer handle.

Such code typically looks like this:

TOrcFxAPIHandle BufferHandle;

int64_t BufferLen;

int Status;

C_GetRestartParentFileNameW(ChildFileName, &BufferHandle, &BufferLen, &Status);

std::wstring parentFileName;

parentFileName.resize(BufferLen / sizeof(wchar_t));

C_CopyBuffer(BufferHandle, reinterpret_cast<unsigned char*>(&parentFileName[0]), BufferLen, &Status);

C_FreeBuffer(BufferHandle, &Status);

parentFileName.resize(parentFileName.size() - 1); // remove null terminator

Note that, for the sake of brevity, error checking has been omitted from the above code.

Unicode and ANSI

The Unicode function name is C_GetRestartParentFileNameW and the ANSI function name is C_GetRestartParentFileNameA.

See also

C_CopyBuffer, C_FreeBuffer, C_GetRestartParentFileNames.