Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace uriparser usage with CesiumUtility::Uri #1589

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Source/CesiumEditor/Private/CesiumIonSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
#include "CesiumIonServer.h"
#include "CesiumRuntimeSettings.h"
#include "CesiumSourceControl.h"
THIRD_PARTY_INCLUDES_START
#include "CesiumUtility/Uri.h"
THIRD_PARTY_INCLUDES_END
#include "FileHelpers.h"
#include "HAL/PlatformProcess.h"
#include "Misc/App.h"
Expand Down
2 changes: 2 additions & 0 deletions Source/CesiumEditor/Private/CesiumIonTokenTroubleshooting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
#include "CesiumIonRasterOverlay.h"
#include "CesiumIonServerDisplay.h"
#include "CesiumRuntimeSettings.h"
THIRD_PARTY_INCLUDES_START
#include "CesiumUtility/Uri.h"
THIRD_PARTY_INCLUDES_END
#include "EditorStyleSet.h"
#include "LevelEditor.h"
#include "ScopedTransaction.h"
Expand Down
2 changes: 2 additions & 0 deletions Source/CesiumEditor/Private/CesiumPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
#include "CesiumIonServerSelector.h"
#include "CesiumRuntime.h"
#include "CesiumRuntimeSettings.h"
THIRD_PARTY_INCLUDES_START
#include "CesiumUtility/Uri.h"
THIRD_PARTY_INCLUDES_END
#include "Editor.h"
#include "Framework/MultiBox/MultiBoxBuilder.h"
#include "Interfaces/IPluginManager.h"
Expand Down
2 changes: 2 additions & 0 deletions Source/CesiumEditor/Private/IonQuickAddPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
#include "CesiumIonRasterOverlay.h"
#include "CesiumIonServer.h"
#include "CesiumRuntimeSettings.h"
THIRD_PARTY_INCLUDES_START
#include "CesiumUtility/Uri.h"
THIRD_PARTY_INCLUDES_END
#include "Editor.h"
#include "PropertyCustomizationHelpers.h"
#include "SelectCesiumIonToken.h"
Expand Down
33 changes: 6 additions & 27 deletions Source/CesiumRuntime/Private/UnrealAssetAccessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
#include "CesiumAsync/AsyncSystem.h"
#include "CesiumAsync/IAssetRequest.h"
#include "CesiumAsync/IAssetResponse.h"
THIRD_PARTY_INCLUDES_START
#include "CesiumUtility/Uri.h"
THIRD_PARTY_INCLUDES_END
#include "CesiumCommon.h"
#include "CesiumRuntime.h"
#include "HttpManager.h"
Expand All @@ -21,7 +24,6 @@
#include <cstring>
#include <optional>
#include <set>
#include <uriparser/Uri.h>

namespace {

Expand Down Expand Up @@ -338,32 +340,9 @@ const std::string UnrealFileAssetRequestResponse::getMethod = "GET";
const CesiumAsync::HttpHeaders UnrealFileAssetRequestResponse::emptyHeaders{};

std::string convertFileUriToFilename(const std::string& url) {
// According to the uriparser docs, both uriUriStringToWindowsFilenameA and
// uriUriStringToUnixFilenameA require an output buffer with space for at most
// length(url)+1 characters.
// https://uriparser.github.io/doc/api/latest/Uri_8h.html#a4afbc8453c7013b9618259bc57d81a39
std::string result(url.size() + 1, '\0');

#ifdef _WIN32
int errorCode = uriUriStringToWindowsFilenameA(url.c_str(), result.data());
#else
int errorCode = uriUriStringToUnixFilenameA(url.c_str(), result.data());
#endif

// Truncate the string if necessary by finding the first null character.
size_t end = result.find('\0');
if (end != std::string::npos) {
result.resize(end);
}

// Remove query parameters from the URL if present, as they are no longer
// ignored by Unreal.
size_t pos = result.find("?");
if (pos != std::string::npos) {
result.erase(pos);
}

return result;
CesiumUtility::Uri parsedUri(url);
return CesiumUtility::Uri::uriPathToNativePath(
std::string(parsedUri.getPath()));
}

class FCesiumReadFileWorker : public FNonAbandonableTask {
Expand Down
Loading