Skip to content

Conversation

@roymacdonald
Copy link
Contributor

of::filesystem::path fileName { "" }; ///< selected file or directory name
std::string filePath = ""; ///< full path to selected file or directory
std::string fileName = ""; ///< selected file or directory name
bool bSuccess = false; ///< true if the dialog action was successful, aka file select not cancel
Copy link
Member

Choose a reason for hiding this comment

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

I think the above could all be of::filesystem::path internally and then std::string getName(); / std::string getPath(); just uses the filePath.string() in its return.

Copy link
Member

Choose a reason for hiding this comment

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

Yes or ofPathToString(filePath)

Copy link
Member

Choose a reason for hiding this comment

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

hey @ofTheo just for your information, this was reverted back to string . just unsure if it was the idea

Copy link
Member

Choose a reason for hiding this comment

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

Yes - I think the issue was that because the members were public they had to be string for usage not to break on Windows.

My thought was we could do a new PR and maybe have these std::string variables as legacy support but have a protected of::filesystem::path internally be used by the class with the string values copies of the path data.

And then a method for accessing as a file path.

But it felt like it needed a bit of thought and we needing to revert to string because of the direct variable usage anyway.

/// \return dialog result with selection (if any)
ofFileDialogResult ofSystemLoadDialog(std::string windowTitle="", bool bFolderSelection = false, of::filesystem::path defaultPath="");
ofFileDialogResult ofSystemLoadDialog(std::string windowTitle="", bool bFolderSelection = false, std::string defaultPath="");

Copy link
Member

Choose a reason for hiding this comment

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

As with the previous comment I think this argument could be left as is.

@ofTheo
Copy link
Member

ofTheo commented Oct 16, 2024

Thanks @roymacdonald - I added a couple of comments but apart from that looks good to go.
I am going to take a stab at the ofBaseVideoPlayer stuff now.

@roymacdonald
Copy link
Contributor Author

@ofTheo should we merge?

@ofTheo
Copy link
Member

ofTheo commented Oct 21, 2024

@roymacdonald - If you can address the two comments I left then I think its good to merge!
Thanks!

@roymacdonald
Copy link
Contributor Author

@ofTheo as for the public members, I think it is better to leave as strings, since changing to ::path will break stuff (actually, the ofDropInfo class whose public members were changed to path break backwards compatibility, such as the example in ofxHapPlayer). So, I think we should leave those as strings.

As of the function parameter, changing string to ::path requires some implementation reworking so it is an useful change and to make sure it works properly.
In the implementation, defaultPath could be renamed to _defaultPath and then internally declare std::string defaultPath so there is no need to rework any of the code.

ofFileDialogResult ofSystemLoadDialog(std::string windowTitle, bool bFolderSelection, of::filesystem::path _defaultPath){
    std::string defaultPath = ofPathToString(_defaultPath);
...
}

But that would give the false impresion that the use of std::filesystem::path is done properly, and because of such I think it is better to keep the function parameter as std::string, and only change it when it is properly handled.

@ofTheo
Copy link
Member

ofTheo commented Oct 22, 2024

Thanks @roymacdonald !

@dimitre - I am tempted to just merge this due to the public member issue Roy mentioned.

Would that be fine with you and then we can PR in some improvements for ofFileDialogResult where we can make the std::string filePath a copy of the real internal path ( which can be protected ) and then getter functions for Path and String?

@dimitre
Copy link
Member

dimitre commented Oct 23, 2024

Hey @ofTheo great. if this makes a smoother transition
I still consider your comment in ofSystemUtils.h valid, preserving internally as fs::path. @roymacdonald can comment if he has any objection to this

@ofTheo ofTheo merged commit a7a1a7a into openframeworks:master Oct 23, 2024
@ofTheo
Copy link
Member

ofTheo commented Oct 23, 2024

Thanks @dimitre - I think we can now go in and fix up some of this stuff with the goal of not breaking Windows and then figure out a 'path' ;-) forward for making path returns Win compatible.

@roymacdonald roymacdonald deleted the noFsPathReturn branch October 25, 2024 03:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants