-
Notifications
You must be signed in to change notification settings - Fork 252
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
Need to return to working directory after checking if path exists #586
Conversation
There was a problem hiding this 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
so I think this PR should be closed
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. |
There was a problem hiding this 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); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please align with tabs
SUCCESS: exercise-opencollada-pull-request build #158
Pull Requests:
|
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 |
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? |
@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. |
@lasalvavida - there is also an issue with line ending apparently - #581 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 |
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 checkingmy/path
as intended.