2012-04-17 2 views
13

는 내가 설정을 심볼릭 링크를 말해?창 심볼릭 링크의 대상

+0

또는 가능한 경우 어떻게하면 perl에서 링크를 추적합니까 –

+5

mytextfile.txt라는 디렉토리가 약간 이상합니다./D 옵션을 사용 하시겠습니까? –

+3

어쨌든 "dir"명령은 기본적으로 심볼릭 링크 대상을 보여줍니다. –

답변

12

으로 해리 존스턴 dir 명령

2014/07/31 11:22 <DIR>   libs 
2014/08/01 13:53    4,997 mobile.iml 
2014/07/31 11:22    689 proguard-rules.pro 
2014/09/28 10:54 <JUNCTION>  res [\??\C:\Users\_____\mobile\src\main\res] 
+2

실제로는 연결 지점이 아닌 심볼 링크이지만, 심볼 링크에 대한 디렉토리 목록은 매우 유사합니다. –

+1

git bash를 사용할 때'dir'을 사용할 수 없지만'cmd // C dir' 대신 쓸 수 있습니다. –

1

어쩌면 누군가가 Directory.GetDirectories 유사한 디렉토리()에있는 모든 디렉토리의 심볼릭 링크를 해결하기 위해 C#을 방법에 관심 심볼릭 링크의 대상을 표시했다. Junctions 또는 File symlinks를 나열하려면 단순히 정규식을 변경하십시오.

static IEnumerable<Symlink> GetAllSymLinks(string workingdir) 
{ 
    Process converter = new Process(); 
    converter.StartInfo = new ProcessStartInfo("cmd", "/c dir /Al") { RedirectStandardOutput = true, UseShellExecute = false, CreateNoWindow = true, WorkingDirectory = workingdir }; 
    string output = ""; 
    converter.OutputDataReceived += (sender, e) => 
    { 
     output += e.Data + "\r\n"; 
    }; 
    converter.Start(); 
    converter.BeginOutputReadLine(); 
    converter.WaitForExit(); 

    Regex regex = new Regex(@"\n.*\<SYMLINKD\>\s(.*)\s\[(.*)\]\r"); 

    var matches = regex.Matches(output); 
    foreach (Match match in matches) 
    { 
     var name = match.Groups[1].Value.Trim(); 
     var target = match.Groups[2].Value.Trim(); 
     Console.WriteLine("Symlink: " + name + " --> " + target); 

     yield return new Symlink() { Name = name, Target = target }; 
    } 
} 

class Symlink 
{ 
    public string Name { get; set; } 
    public string Target { get; set; } 
} 
관련 문제