Skip to content

Commit

Permalink
When walking for imports, try-open each file to skip symlinks to erro…
Browse files Browse the repository at this point in the history
…neous destinations. Closes #113. Thanks nixeagle for catching this!
  • Loading branch information
fredreichbier committed Jul 12, 2010
1 parent 0aef726 commit 03c0478
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions source/rock/middle/tinker/Resolver.ooc
Expand Up @@ -102,6 +102,14 @@ Resolver: class {
if (!f getPath() endsWith(".ooc")) return

fullName := f getAbsolutePath()

// try to open the file to sort out links to non-existent destinations.
tempFile := FStream open(fullName, "r")
if(!tempFile)
return
else
tempFile close()

module := AstBuilder cache get(fullName)

fullName = fullName substring(pathElem getAbsolutePath() length() + 1, fullName length() - 4)
Expand Down

3 comments on commit 03c0478

@nddrylliog
Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't a call to exists() suffice? Imho it does exactly that.

@nddrylliog
Copy link
Member

Choose a reason for hiding this comment

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

Also, you do that in Resolver walkImports - which is good and fancy - but rock will then still segfault when being handed over a path to a non-existent file? Ie. rock bad_link.ooc ?

@fredreichbier
Copy link
Member Author

Choose a reason for hiding this comment

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

Haha, alright, that was one thought too much. Thank you, fixed in cd0cbee.
rock link.ooc will print File not found: link.ooc which is enough imo.

Please sign in to comment.