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

Need to return to working directory after checking if path exists #586

Merged

Conversation

lasalvavida
Copy link
Contributor

Currently this function does not work - it splits the path up as a list of paths for example:

/my/path/here

becomes

[/my, /my/path, /my/path/here]

but it changes the working directory when it checks if the path exists. So after it checks if /my exists, it will then check if /my/my/path exists because the working directory has been changed to /my during the existence check rather than checking my/path as intended.

Copy link
Contributor

@RemiArnaud RemiArnaud left a comment

Choose a reason for hiding this comment

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

I don't understand.
there is only one way out of createDirectory..() functions, the return statement
and a _wchdir(currentPath) immediately preceeds the return statement

as in https://github.com/KhronosGroup/OpenCOLLADA/blob/master/COLLADABaseUtils/src/COLLADABUUtils.cpp#L315

so I think this PR should be closed

@lasalvavida
Copy link
Contributor Author

lasalvavida commented Oct 11, 2018

Hi @RemiArnaud maybe I should have been clearer.

It sounds like you think the issue is not returning to the working directory when the function ends.

This is not the case.

The issue is that the path is not traversed properly within the createDirectoryRecursive function.

The paths being checked are relative to the original working directory, but the directory is changed by the existence check if it exists which breaks the subsequent checks. You can fix this by splitting the path into parts or (what I did here) just make sure to go back to the original working directory before checking the next path.

You can see this issue if you use the latest COLLADA2GLTF on Windows targeting an output directory more than a level deep that doesn't exist yet since it uses this function.

This pull request was created to resolve this regression in COLLADA2GLTF from switching to OpenCOLLADA's path implementation and will be fixed once it is merged.

Let me know if you need anything else clarified here.

Copy link
Contributor

@RemiArnaud RemiArnaud left a comment

Choose a reason for hiding this comment

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

ok, I understand. the issue is with the for loop.
Thanks for the fix. If you don't mind fixing the space vs tab issue (just keep whatever the file is using) and we should be on our way.
I'll start a build

@@ -349,12 +351,14 @@ namespace COLLADABU
for (std::list<String>::const_iterator iPath = paths.begin(); iPath != paths.end(); ++iPath)
{
// if path exists
if (_chdir((*iPath).c_str()) == 0)
if (_chdir((*iPath).c_str()) == 0) {
_chdir(currentPath);
Copy link
Contributor

Choose a reason for hiding this comment

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

please adopt original indentation, put a few tabs to align this statement

@@ -298,12 +298,14 @@ namespace COLLADABU
for (std::list<WideString>::const_iterator iPath = paths.begin(); iPath != paths.end(); ++iPath)
{
// if path exists
if (_wchdir((*iPath).c_str()) == 0)
if (_wchdir((*iPath).c_str()) == 0) {
_wchdir(currentPath);
Copy link
Contributor

Choose a reason for hiding this comment

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

please align with tabs

@Fl4reBot
Copy link

SUCCESS: exercise-opencollada-pull-request build #158

Pull Requests:

@lasalvavida
Copy link
Contributor Author

Spaces in my changes have been changed to tabs as requested.

I appreciate wanting consistency, but I think it's worth mentioning that the code in COLLADABUUtils.cpp switches between tabs and spaces constantly which should probably be addressed.

@RemiArnaud
Copy link
Contributor

I appreciate wanting consistency, but I think it's worth mentioning that the code in COLLADABUUtils.cpp switches between tabs and spaces constantly which should probably be addressed.

I did not realize this. files in OpenCOLLADA\COLLADABaseUtils\src have a mixture of spaces and tabs indeed. You are right that it should all be replaced by tabs.

Do you want to do this now?

@lasalvavida
Copy link
Contributor Author

@RemiArnaud, I'll open up a separate pull request for normalizing formatting I think if that's something you'd like for me to do.

@RemiArnaud RemiArnaud merged commit 77fa74e into KhronosGroup:master Oct 18, 2018
@RemiArnaud
Copy link
Contributor

@lasalvavida - there is also an issue with line ending apparently - #581
where line endings should be LF (linux style) in the repository

this PR 581 did not go through and is now with conflicts, so maybe you can address both tabs and line endings in a new RP?

I should hold on merging anything in the mean time

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