Skip to content

Commit

Permalink
Merge pull request #1589 from CesiumGS/ada-url
Browse files Browse the repository at this point in the history
Replace `uriparser` usage with `CesiumUtility::Uri`
  • Loading branch information
kring authored Feb 1, 2025
2 parents 1044f5c + 17820f0 commit f78cb02
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 28 deletions.
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

0 comments on commit f78cb02

Please sign in to comment.