openplanet-nl / issues

Issue tracker for Openplanet.
10 stars 0 forks source link

Implement `string::NthIndexOf` #538

Open st-AR-gazer opened 1 month ago

st-AR-gazer commented 1 month ago

Heyo Miss, I've made quite a few custom functions over the past while and I though I should finally sit down and a short list of some functions/improvements to existing functions that it'd be nice to have in Openplanet :D

So, lets get started: (Most of these can be found in arUtils)

class string NthIndexOf (gets the Nth index of a character, needs (string value, int n))). LastIndexOf (gets the last index of a character, needs (string value)). NthLastIndexOf (gets the Nth last index of a character, needs (string value, int n)).

namespace IO Move (should get a 'recursive' parameter). Rename (should exist, having to read a file to end, and then re-write it in a different location is not good...) FileCreatedDate (I'm currently getting this with a dll, which isn't exactly ideal... It'd be amazing if this could be added as well :))

namespace Json PrettyPrint (pretty prints a Json::Value).

And yeah, that's about it :) I have more utility functions, but I don't think they really fit in Openplanet, though, if I come across any more functions I think need adding I'll setup another issue (or maybe add to this one, idk what is best xD)

codecat commented 1 month ago

String:

IO:

Json:

st-AR-gazer commented 1 month ago

I currently have no use for NthIndexOf (I do remember needing it at one point though, iirc it was some movement through directories, though it was a litte while back so I don't fully remember at this point...). I'm using NthLastIndexOf for moving between different directories, as well as getting the type of gbx file e.g filename.Replay.Gbx, using NthLastIndexOf makes getting the "relplay" (or any other 'type' for that matter) a lot easier.

The recursive parameter would create the path input into the 'move' if it didn't already exist.

I didn't think of using move as a rename function, should work, I think.

FileCreatedTime nice!

And the PrettyPrint json is also nice!

codecat commented 1 month ago

I did not think you meant a recursive parameter on IO::Move to create directories. I'm not sure it's appropriate to have a parameter like that. Instead, you could use IO::CreateFolder and Path::GetDirectoryName to achieve this pretty easily:

string pathSource = "file.wav";
string pathTarget = "some/directory/file.wav";
IO::CreateDirectory(Path::GetDirectoryName(pathTarget));
IO::Move(pathSource, pathTarget);
st-AR-gazer commented 1 month ago

Ah, yes that makes sense 👍