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

Symlinks to directories reported as symlinks to files #1985

Closed
gradha opened this issue Jan 19, 2015 · 1 comment
Closed

Symlinks to directories reported as symlinks to files #1985

gradha opened this issue Jan 19, 2015 · 1 comment

Comments

@gradha
Copy link
Contributor

gradha commented Jan 19, 2015

Under OSX and Linux symlinks to directories are reported as symlinks to files. See the following test.nim:

import os

const target = "target_dir"

proc test() =
  discard execShellCmd("mkdir -p source_dir")
  if not target.existsDir:
    discard execShellCmd("ln -s source_dir " & target)

  for kind, path in walkDir("."):
    echo kind, " with path '", path, "'"

when isMainModule: test()

Compiling and running generates:

$ nim c -r test.nim
…
pcDir with path './nimcache'
pcDir with path './source_dir'
pcLinkToFile with path './target_dir'
pcFile with path './test'
pcFile with path './test.nim'

I was expecting to get a pcLinkToDir instead.

@Varriount
Copy link
Contributor

I don't have a linux system at the moment to test this on, but I suspect this might be due to S_ISDIR not returning true for symlinks to directories.

As a side note, the directory walking procedures should be replaced with something more efficient and flexible - the current ones have unnecessary limitations.

@Varriount Varriount added the Easy label Jan 22, 2015
@dom96 dom96 closed this as completed in 059b05a Jun 14, 2015
dom96 added a commit that referenced this issue Jun 14, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants