Contents Menu Expand Light mode Dark mode Auto light/dark mode
Hpk for FFT
Light Logo Dark Logo
Hpk for FFT
  • Home
  • Introduction
  • Building
  • API Design
  • Real Time Domain
  • Advanced
  • C++ Examples
    • CMakeLists.txt
    • meson.build
    • example.cpp
    • fft_cc.cpp
    • fft_cc_2d.cpp
    • fft_rc.cpp
    • advanced/CMakeLists.txt
    • advanced/meson.build
    • advanced/link-f.py
    • advanced/fft_12.cpp
    • advanced/fft_3x6.cpp
    • advanced/ncpu.cpp
  • C++ API Reference
    • AlignedAllocator
    • Architecture
    • Complex type traits
    • Configuration
    • Detection
    • FFT
      • makeFactory()
      • InplaceDim
      • OoplaceDim
      • Factory
      • Inplace
      • Ooplace
  • Python Bindings
  • Python API Reference
    • Arrays
    • Architecture
    • Configuration
    • Detection
    • FFT
      • makeFactory
      • InplaceDim
      • OoplaceDim
      • Factory
      • Inplace
      • Ooplace
Back to top

advanced/link-f.py#

The file advanced/link-f.py is a Python script that creates hard links, forcefully overwriting the destination if it exists.


#!/usr/bin/env python3

# Creates a link to SRC with the name DST, overwriting DST if it exists.
# This is similar to the following GNU coreutils command: ln -f SRC DST

import os
import sys
from tempfile import TemporaryDirectory

def main():
    if len(sys.argv) != 3:
        print("Usage: ", sys.argv[0], "SRC DST", file=sys.stderr)
        return
    dst = sys.argv[2]
    with TemporaryDirectory(dir=os.path.dirname(dst)) as tmpdir:
        tmp = os.path.join(tmpdir, os.path.basename(dst))
        os.link(sys.argv[1], tmp)
        os.replace(tmp, dst)

if __name__ == '__main__':
    main()

Next
advanced/fft_12.cpp
Previous
advanced/meson.build
Copyright © 2023 – 2025, High Performance Kernels LLC