symlink

realpath() without resolving symlinks?

▼魔方 西西 提交于 2019-11-28 11:03:17
I already read about realpath() , but is there a function that I can pass a base directory and a filename that would give me the following result without resolving symlinks or checking whether files actually exist? Or do I have to use a modified realpath() ? "/var/", "../etc///././/passwd" => "/etc/passwd" Here is a normalize_path() function: If the given path is relative, the function starts by prepending the current working directory to it. Then the special path components like .. , . or empty components are treated, and the result is returned. For .. , the last component is removed if there

What replaces the now-deprecated Carbon.File.FSResolveAliasFile in Python on OSX?

别说谁变了你拦得住时间么 提交于 2019-11-28 10:43:48
问题 In Python 2, I can use the following code to resolve either a MacOS alias or a symbolic link: from Carbon import File File.FSResolveAliasFile(alias_fp, True)[0].as_pathname() where alias_fp is the path to the file I'm curious about, stored as a string (source). However, the documentation cheerfully tells me that the whole Carbon family of modules is deprecated. What should I be using instead? EDIT: I believe the code below is a step in the right direction for the PyObjC approach. It doesn't

Telling git to ignore symlinks

心已入冬 提交于 2019-11-28 06:42:58
This question has appeared in similar forms here and here , but they don't seem to match up with what I'm looking for. I'm making a project in StaticMatic, a Ruby static site generator. Basically, it's just a src/ directory with Haml templates, Sass, and CoffeeScript. StaticMatic provides a development server to keep compiling these into a static site, as well as a build command that generates the static site in build/. My modification to StaticMatic is to allow the addition of src/_modules/foo/, which might contain src/_modules/foo/bar.haml. When running the server or building the site, a

Nginx not following symlinks

余生长醉 提交于 2019-11-28 06:14:19
I have installed nginx on Ubuntu 12.04. However, nginx does not seem to follow symlinks. I understand that there is a config change required for this but I am not able to find where to make the change. Any help appreciated. cobaco Have a look at the following config option from nginx docs : Syntax: disable_symlinks off; disable_symlinks on | if_not_owner [from=part]; Default: disable_symlinks off; Context: http, server, location This directive appeared in version 1.1.15. In my case nginx was already configured to follow symbolic links. But the issue was the user nginx could not access my home

difference between sh and bash when symlink is used

别说谁变了你拦得住时间么 提交于 2019-11-28 05:50:32
问题 I have a shell script which uses process substitution The script is: #!/bin/bash while read line do echo "$line" done < <( grep "^abcd$" file.txt ) When I run the script using sh file.sh I get the following output $sh file.sh file.sh: line 5: syntax error near unexpected token `<' file.sh: line 5: `done < <( grep "^abcd$" file.txt )' When I run the script using bash file.sh , the script works. Interestingly, sh is a soft-link mapped to /bin/bash . $ which bash /bin/bash $ which sh /usr/bin/sh

Renaming a file without using renameTo() - Java

我只是一个虾纸丫 提交于 2019-11-28 03:34:07
问题 Disregarding my last post, I've found the source of the problem. I'm using a.renameTo(b) when b doesn't exist. The reason it doesn't exist is because there is a symbolic link so if b is /usr/name/folder/file , then b really is /mnt/MountTest because the symlink is to that directory. So the question is, is there an alternative way to rename a file in Java using a string value? If not, how can this rename procedure be done differently? 回答1: A rename would rename it... if it were on the same

How do you determine using stat() whether a file is a symbolic link?

丶灬走出姿态 提交于 2019-11-27 23:35:16
I basically have to write a clone of the UNIX ls command for a class, and I've got almost everything working. One thing I can't seem to figure out how to do is check whether a file is a symbolic link or not. From the man page for stat() , I see that there is a mode_t value defined, S_IFLNK . This is how I'm trying to check whether a file is a sym-link, with no luck (note, stbuf is the buffer that stat() returned the inode data into): switch(stbuf.st_mode & S_IFMT){ case S_IFLNK: printf("this is a link\n"); break; case S_IFREG: printf("this is not a link\n"); break; } My code ALWAYS prints this

Detecting a symlink in Java [duplicate]

六眼飞鱼酱① 提交于 2019-11-27 22:47:47
This question already has an answer here: Java 1.6 - determine symbolic links 7 answers Given a Java 'File' object, how can I detect whether or not it refers to a symlink? (If it helps/matters, I know the file refers to a directory, not to a file) Also you can use isSymbolicLink(Path path) method. It will be more reliable. java.io.File file = ...; boolean isSymbolicLink = Files.isSymbolicLink(file.toPath()); Similar examples from Java Doc ' Detecting a Symbolic Link '. Bozho File.getCanonicalPath() resolves symlinks A canonical pathname is both absolute and unique. The precise definition of

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

Tomcat context.xml files, is there a hierarchy?

穿精又带淫゛_ 提交于 2019-11-27 21:26:21
问题 I am trying to use symbolic links in one of the applications I have running on Tomcat5. Thanks to some help from another StackOverflow question I was able to do it by creating a context.xml file in /...myapplication/META-INF/context.xml I am now trying to implement this on a production server. However, there are other applications running on it. And there is another context file /...tomcat/conf/context.xml It seems to me these are setting configurations server-wide to all applications. If I