Skip to content
This repository was archived by the owner on Jan 25, 2023. It is now read-only.

Path Class - #2619

Open
SirNate0 wants to merge 9 commits into
urho3d:masterfrom
SirNate0:path-class
Open

SirNate0 wants to merge 9 commits into
urho3d:masterfrom
SirNate0:path-class

Conversation

@SirNate0

@SirNate0 SirNate0 commented Apr 4, 2020

Copy link
Copy Markdown
Contributor

Rather than using strings everywhere that are almost exclusively treated as paths, I am proposing we switch to a separate class for paths and for strings. At present, this can't be considered finished (especially since the Script bindings have not been added for the new class), but I would estimate that it is most of the way to being complete at the moment. I haven't tested it on platforms other than Linux and Web at present, so we'll see the results from the CI build for that. Probably some more work remains to be done with Serializables especially, even if it compiles and runs fine at present (implicit conversion from String to the rescue).

This has been discussed some on the forum already, though that thread has more of a focus on specifically allowing relative paths as opposed to switching to a Path class: https://discourse.urho3d.io/t/adding-relative-paths-to-resource-loading/5911/42

Some design choices should probably be considered before this is merged, including (though not limited to):

  1. Should Resource and the like have const Path& GetName() const or should we stick with what I have done at the present with two methods const String& GetName() const and const Path& GetNamePath() const, though internally it is just stored as a Path.
  2. How much functionality of String should be exposed for the Path class? At present it's basically just Empty, Clear, Length, Compare, and an optional CString (the last to ease the transition). What about Contains, Find[Last], etc.?
  3. Should JSONValue have a completely separate Path type?
  4. Should we switch to a GLOB and/or REGEX based system for FileSystem::CheckAccess? What about speed considerations? Should we support multiple options, possibly with a build flag and/or (constexpr) global variable?
  5. Should we wait until the automatic binding generator is finished to work on the script stuff? (Not a design decision, but I still vote yes for this).

With that said, I know it's a long set of changes, but I would very much appreciate feedback from others.

SirNate0 added 9 commits April 2, 2020 21:46
…ll use a separate NativeWide function in the engine as refactoring will be easier this way.

Compiled, fixed some errors in variable names.
…ll runs.

Bug fix for adding/removing trailing slashes.
…e fixed, along with the Samples. Tools are updated, though.
…with some things

like setting the resource paths.
@SirNate0

SirNate0 commented Apr 9, 2020

Copy link
Copy Markdown
Contributor Author

Forgot the URHO3D_EXTRAS, I will fix those and re-upload later.

@github-actions

Copy link
Copy Markdown

Marking this stale since there has been no activity for 30 days.
It will be closed if there is no activity for another 15 days.

@github-actions github-actions Bot added the stale label May 10, 2020
@weitjong weitjong added backlog and removed stale labels May 17, 2020
Comment thread Source/Samples/Sample.inl
graphics->TakeScreenShot(screenshot);
// Here we save in the Data folder with date and time appended
screenshot.SavePNG(GetSubsystem<FileSystem>()->GetProgramDir() + "Data/Screenshot_" +
screenshot.SavePNG(GetSubsystem<FileSystem>()->GetProgramDir() + "Data/Screenshot_" +

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why padding is so big? Better to remove such trash from PRs

@1vanK

1vanK commented Dec 6, 2020

Copy link
Copy Markdown
Contributor

I still don't understand why need to put a string with a path inside another class.

Even in C# Path just contains collection of static functions to manipulate with strings

https://docs.microsoft.com/en-us/dotnet/api/system.io.path?view=net-5.0

void SetExecuteConsoleCommands(bool enable);
/// Print the whole script API (all registered classes, methods and properties) to the log. No-ops when URHO3D_LOGGING not defined.
void DumpAPI(DumpMode mode = DOXYGEN, const String& sourceTree = String::EMPTY);
void DumpAPI(DumpMode mode = DOXYGEN, Path sourceTree = Path::EMPTY);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const Path& sourceTree

}

void Script::DumpAPI(DumpMode mode, const String& sourceTree)
void Script::DumpAPI(DumpMode mode, Path sourceTree)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const Path& sourceTree

@1vanK

1vanK commented Dec 6, 2020

Copy link
Copy Markdown
Contributor

The code didn't get any easier with the new class. You just added conversions from strings and back to strings.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants