Code Monkey home page Code Monkey logo

Comments (4)

soredake avatar soredake commented on June 12, 2024 1

@ralish mainly for having windows terminal hot-reload my config when i change it, that is possible only with hard link

from psdotfiles.

soredake avatar soredake commented on June 12, 2024

Patiently waiting for this.

from psdotfiles.

ralish avatar ralish commented on June 12, 2024

@soredake I'll try and find some time for this but sadly have little time to invest in personal projects at the moment. Out of curiosity, can you provide more details on your use case for this feature? I've got my own scenarios, but would be interested to hear of others.

from psdotfiles.

ralish avatar ralish commented on June 12, 2024

I don't believe there's any mechanism available in PowerShell to enumerate all hard links for a file so this would need to be implemented via P/Invoke calls to the Win32 API. We'd need FirstFirstFileNameW, FindNextFileNameW, and FindClose. The GetFinalPathNameByHandleW API may also be needed.

The P/Invoke method signatures are probably something like this (untested):

[DllImport("kernel32.dll", CharSet = CharSet.Unicode, EntryPoint = "GetFinalPathNameByHandleW", ExactSpelling = true, SetLastError = true)]
public extern static int GetFinalPathNameByHandle(Microsoft.Win32.SafeHandles.SafeFileHandle hFile,
                                                  System.Text.StringBuilder lpszFilePath,
                                                  int cchFilePath,
                                                  int dwFlags);

[DllImport("kernel32.dll", CharSet = CharSet.Unicode, EntryPoint = "FindFirstFileNameW", ExactSpelling = true, SetLastError = true)]
public extern static Microsoft.Win32.SafeHandles.SafeFileHandle FindFirstFileName(string lpFileName,
                                                                                  int dwFlags,
                                                                                  ref int StringLength,
                                                                                  System.Text.StringBuilder LinkName);

[DllImport("kernel32.dll", CharSet = CharSet.Unicode, EntryPoint = "FindNextFileNameW", ExactSpelling = true, SetLastError = true)]
public extern static bool FindNextFileName(Microsoft.Win32.SafeHandles.SafeFileHandle hFindStream,
                                           ref int StringLength,
                                           System.Text.StringBuilder LinkName);

[DllImport("kernel32.dll", SetLastError = true)]
public extern static bool FindClose(Microsoft.Win32.SafeHandles.SafeFileHandle hFindFile);

from psdotfiles.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.