symlink-traversal

How do you determine the path of the file that a symlink points to?

旧街凉风 提交于 2020-01-13 10:57:50
问题 In Linux, if you have a path to a file which you know is a symlink, how do you programmatically determine (in C or C++) the path to the file that it points to? 回答1: The readlink function. Do a man 2 readlink . This function is part of the Posix API, so it should work on almost any Unix. If the path starts with a '/' , then its an absolute symlink and you have the full absolute path of the file to which it refers (which may be another symbolic link, and you'll have to repeat the process again)

How can I tell if a symbolic link exists at a certain path?

梦想与她 提交于 2020-01-04 01:59:08
问题 I have an original file, /path/to/foo.txt , and a symbolic link to it, /other/path/to/foo.txt . I delete /path/to/foo.txt , but leave the symbolic link in-place. How can I tell that the symbolic link still exists using Cocoa APIs? I found this by using the standard/recommended FileManager.fileExists(atPath:). The problem here, for anyone unfamiliar with that API, is that it traverses symlinks. So, when I do this: FileManager.default.fileExists(atPath: "/other/path/to/foo.txt") it returns

Firebase “symlink” to another node

痞子三分冷 提交于 2019-12-23 23:03:06
问题 In relation to my other question about modelling a real user-facing tree structure (Using firebase tree structure to represent a "document outline" structure directly), I was thinking of putting in place a generic approach to "symlinking", at certain nesting levels, to overcome the 32 nesting levels limitation and the need to fetch all sub-nodes at once. Are there some "best-practices" for "symlinking" in firebase? E.g.: syntax (contents, key-value structure) for a firebase node which would

Follow symlinks in SVN

一个人想着一个人 提交于 2019-12-10 01:58:53
问题 I have a linux directory (and don't need any windows checkout): /home/me/projects/project1 In this project, I need SVN (1.8.8) to follow a symlink "link1": /home/me/projects/project1/link1/<some_directories_and_files> But SVN won't let me do that, it just add link1 but not its content. If I try to add its content, I get an error: svn add link1/* svn: E145001: Can't schedule an addition of '/home/me/projects/project1/link1/first_directory' below a not-directory node I tried converting link1 to

How do you determine the path of the file that a symlink points to?

孤人 提交于 2019-12-05 09:58:11
In Linux, if you have a path to a file which you know is a symlink, how do you programmatically determine (in C or C++) the path to the file that it points to? The readlink function. Do a man 2 readlink . This function is part of the Posix API, so it should work on almost any Unix. If the path starts with a '/' , then its an absolute symlink and you have the full absolute path of the file to which it refers (which may be another symbolic link, and you'll have to repeat the process again). If the path does not start with ' / ', then it's a relative link and is interpreted relative to the

Follow symlinks in SVN

假装没事ソ 提交于 2019-12-05 01:24:09
I have a linux directory (and don't need any windows checkout): /home/me/projects/project1 In this project, I need SVN (1.8.8) to follow a symlink "link1": /home/me/projects/project1/link1/<some_directories_and_files> But SVN won't let me do that, it just add link1 but not its content. If I try to add its content, I get an error: svn add link1/* svn: E145001: Can't schedule an addition of '/home/me/projects/project1/link1/first_directory' below a not-directory node I tried converting link1 to hard link but I can't do that either: ln /path/to/my/linked/directory link1 ln: ‘/path/to/my/linked

Python os.walk + follow symlinks

放肆的年华 提交于 2019-12-03 11:33:22
问题 How do I get this piece to follow symlinks in python 2.6? def load_recursive(self, path): for subdir, dirs, files in os.walk(path): for file in files: if file.endswith('.xml'): file_path = os.path.join(subdir, file) try: do_stuff(file_path) except: continue 回答1: Set followlinks to True . This is the fourth argument to the os.walk method, reproduced below: os.walk(top[, topdown=True[, onerror=None[, followlinks=False]]]) This option was added in Python 2.6. 来源: https://stackoverflow.com

Python os.walk + follow symlinks

懵懂的女人 提交于 2019-12-03 01:07:37
How do I get this piece to follow symlinks in python 2.6? def load_recursive(self, path): for subdir, dirs, files in os.walk(path): for file in files: if file.endswith('.xml'): file_path = os.path.join(subdir, file) try: do_stuff(file_path) except: continue Set followlinks to True . This is the fourth argument to the os.walk method, reproduced below: os.walk(top[, topdown=True[, onerror=None[, followlinks=False]]]) This option was added in Python 2.6. 来源: https://stackoverflow.com/questions/3771696/python-os-walk-follow-symlinks

Docker follow symlink outside context

余生长醉 提交于 2019-11-27 21:46:16
Yet another Docker symlink question. I have a bunch of files that I want to copy over to all my Docker builds. My dir structure is: parent_dir - common_files - file.txt - dir1 - Dockerfile - symlink -> ../common_files In above example, I want file.txt to be copied over when I docker build inside dir1. But I don't want to maintain multiple copies of file.txt. Per this link, as of docker version 0.10 , docker build must Follow symlinks inside container's root for ADD build instructions. But I get no such file or directory when I build with either of these lines in my Dockerfile: ADD symlink

Docker follow symlink outside context

吃可爱长大的小学妹 提交于 2019-11-26 20:50:58
问题 Yet another Docker symlink question. I have a bunch of files that I want to copy over to all my Docker builds. My dir structure is: parent_dir - common_files - file.txt - dir1 - Dockerfile - symlink -> ../common_files In above example, I want file.txt to be copied over when I docker build inside dir1. But I don't want to maintain multiple copies of file.txt. Per this link, as of docker version 0.10, docker build must Follow symlinks inside container's root for ADD build instructions. But I