Help needed to get SqLite to work in realtime once packaged for windows

Hello :).

Are you using the correct path to the db?

This is from my own project, where the paths are specified like:

    RelativePathToGMKernel = TEXT("NonAssetData/naif/kernels/Generic/PCK/gm_de431.tpc");

And used like:

    FString fullPathToFile = toPath(file);
FString toPath(const FString& file)
{
    // BaseGame.ini [/Script/UnrealEd.ProjectPackagingSettings] DirectoriesToAlwaysStageAsNonUFS
    // is relative to the project's Content directory...  Copying kernel files, then, means the directory must be relative to the content directory
    if(FPaths::IsRelative(file))
    {
        auto gameDir = FPaths::ConvertRelativePathToFull(FPaths::ProjectContentDir());
        return FPaths::Combine(gameDir, file);
    }

    return file;
}

Could you need to set the working directory? I do so like this (windows only):

void furnsh(
    const FString& file
)
{
    FString fullPathToFile = toPath(file);

#ifdef SET_WORKING_DIRECTORY_IN_FURNSH
    // Get the current working directory...
    TCHAR buffer[WINDOWS_MAX_PATH];
    TCHAR* oldWorkingDirectory = _tgetcwd(buffer, sizeof(buffer)/sizeof(buffer[0]));

    // Trim the file name to just the full directory path...
    FString fullPathToDirectory = FPaths::GetPath(fullPathToFile);
    fullPathToDirectory.ReplaceCharInline('/', '\\');

    if (FPaths::DirectoryExists(fullPathToDirectory))
    {
        // Set the current working directory
        _tchdir(*fullPathToDirectory);
    }
#endif

    furnsh_c(TCHAR_TO_ANSI(*fullPathToFile));

#ifdef SET_WORKING_DIRECTORY_IN_FURNSH
    // Reset the working directory to prior state...
    if (oldWorkingDirectory)
    {
        _tchdir(oldWorkingDirectory);
    }
#endif
}
1 Like