Author Topic: Excluding symbolic links  (Read 1410 times)

joecar

  • Senior Community Member
  • Posts: 437
  • Hero Points: 9
  • engineer/gearhead
Excluding symbolic links
« on: June 05, 2024, 08:24:00 PM »
Project Properties : Files : Add Tree

is there a way to exclude symbolic links (i.e. to avoid duplicating files/tags)...?


SlickEdit Pro 2023 (v28.0.2.0 64-bit Qt5)
« Last Edit: August 17, 2024, 11:34:49 PM by joecar »

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6934
  • Hero Points: 531
Re: Excluding symbolic links
« Reply #1 on: June 05, 2024, 08:42:32 PM »
Try excluding specific directories. Hopefully you don’t have a ton of symbolic link directories.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6934
  • Hero Points: 531
Re: Excluding symbolic links
« Reply #2 on: June 05, 2024, 10:05:40 PM »
Easiest way to specify a directory to exclude is to include a trailing slash like this:

Code: [Select]
**/symlinkdir/

joecar

  • Senior Community Member
  • Posts: 437
  • Hero Points: 9
  • engineer/gearhead
Re: Excluding symbolic links
« Reply #3 on: June 05, 2024, 11:49:54 PM »
Thanks.

Unfortunately, the tree (on Windows filesystem) is riddled with symlinks (to files and directories) with no pattern that I can see.


joecar

  • Senior Community Member
  • Posts: 437
  • Hero Points: 9
  • engineer/gearhead
Re: Excluding symbolic links
« Reply #4 on: June 28, 2024, 06:16:19 PM »

This is what my directory looks like (using Windows dir command):

C:\Users\Joe\GitLab\syntiant-dsp-firmware.git\ndp250\src\hal>dir
 Volume in drive C has no label.
 Volume Serial Number is 5CDE-80AE

 Directory of C:\Users\Joe\GitLab\syntiant-dsp-firmware.git\ndp250\src\hal

06/28/2024  10:03 AM    <DIR>          .
06/28/2024  10:03 AM    <DIR>          ..
05/22/2024  06:51 PM    <SYMLINK>      algo_config.h [..\..\..\ndp120\src\hal\algo_config.h]
05/22/2024  06:51 PM    <SYMLINK>      algo_function_list.c [..\..\..\ndp120\src\hal\algo_function_list.c]
05/22/2024  06:51 PM    <SYMLINK>      algo_function_list.h [..\..\..\ndp120\src\hal\algo_function_list.h]
05/22/2024  06:51 PM    <SYMLINK>      algo_interface.c [..\..\..\ndp120\src\hal\algo_interface.c]
05/22/2024  06:51 PM    <SYMLINK>      algo_interface.h [..\..\..\ndp120\src\hal\algo_interface.h]
05/22/2024  06:51 PM            26,646 audio_sync.c
05/22/2024  06:51 PM    <SYMLINK>      audio_sync.h [..\..\..\ndp120\src\hal\audio_sync.h]
05/22/2024  06:51 PM    <SYMLINK>      aud_out.c [..\..\..\ndp120\src\hal\aud_out.c]
05/22/2024  06:51 PM    <SYMLINK>      aud_out.h [..\..\..\ndp120\src\hal\aud_out.h]
05/22/2024  06:51 PM    <SYMLINK>      circular_buffer.c [..\..\..\ndp120\src\hal\circular_buffer.c]
05/22/2024  06:51 PM    <SYMLINK>      circular_buffer.h [..\..\..\ndp120\src\hal\circular_buffer.h]
05/22/2024  06:51 PM    <SYMLINK>      common.c [..\..\..\ndp120\src\hal\common.c]
05/22/2024  06:51 PM    <SYMLINK>      common.h [..\..\..\ndp120\src\hal\common.h]
06/06/2024  09:31 AM            13,322 config.c
05/22/2024  06:51 PM    <SYMLINK>      config.h [..\..\..\ndp120\src\hal\config.h]
05/22/2024  06:51 PM    <SYMLINK>      crc8.c [..\..\..\ndp120\src\hal\crc8.c]
05/22/2024  06:51 PM    <SYMLINK>      crc8.h [..\..\..\ndp120\src\hal\crc8.h]
05/22/2024  06:51 PM    <SYMLINK>      debug.c [..\..\..\ndp120\src\hal\debug.c]
05/22/2024  06:51 PM    <SYMLINK>      debug.h [..\..\..\ndp120\src\hal\debug.h]
05/22/2024  06:51 PM    <SYMLINK>      delay.c [..\..\..\ndp120\src\hal\delay.c]
05/22/2024  06:51 PM    <SYMLINK>      delay.h [..\..\..\ndp120\src\hal\delay.h]
05/22/2024  06:51 PM    <SYMLINK>      dma.c [..\..\..\ndp120\src\hal\dma.c]
05/22/2024  06:51 PM    <SYMLINK>      dma.h [..\..\..\ndp120\src\hal\dma.h]
06/28/2024  11:00 AM            42,472 dnn.c
05/22/2024  06:51 PM    <SYMLINK>      dnn.h [..\..\..\ndp120\src\hal\dnn.h]
05/22/2024  06:51 PM    <SYMLINK>      errors.h [..\..\..\ndp120\src\hal\errors.h]
05/22/2024  06:51 PM    <SYMLINK>      fe_spl.c [..\..\..\ndp120\src\hal\fe_spl.c]
06/11/2024  12:22 AM            23,807 fifo.c
05/22/2024  06:51 PM    <SYMLINK>      fifo.h [..\..\..\ndp120\src\hal\fifo.h]
05/22/2024  06:51 PM    <SYMLINK>      flow.c [..\..\..\ndp120\src\hal\flow.c]
05/22/2024  06:51 PM    <SYMLINK>      flow.h [..\..\..\ndp120\src\hal\flow.h]
05/22/2024  06:51 PM    <SYMLINK>      fw_state.c [..\..\..\ndp120\src\hal\fw_state.c]
05/22/2024  06:51 PM    <SYMLINK>      fw_state.h [..\..\..\ndp120\src\hal\fw_state.h]
05/22/2024  06:51 PM            12,722 gpio.c
05/22/2024  06:51 PM    <SYMLINK>      gpio.h [..\..\..\ndp120\src\hal\gpio.h]
05/22/2024  06:51 PM    <DIR>          hal-public-interface
05/22/2024  06:51 PM    <SYMLINK>      interrupts.c [..\..\..\ndp120\src\hal\interrupts.c]
05/22/2024  06:51 PM    <SYMLINK>      interrupts.h [..\..\..\ndp120\src\hal\interrupts.h]
06/06/2024  09:31 AM            38,664 jpeg.c
06/06/2024  09:31 AM             3,535 jpeg.h
05/22/2024  06:51 PM    <SYMLINK>      mailbox.c [..\..\..\ndp120\src\hal\mailbox.c]
05/22/2024  06:51 PM    <SYMLINK>      mailbox.h [..\..\..\ndp120\src\hal\mailbox.h]
05/22/2024  06:51 PM             4,095 mem.c
05/22/2024  06:51 PM             1,381 mem.h
05/22/2024  06:51 PM    <SYMLINK>      mic.c [..\..\..\ndp120\src\hal\mic.c]
05/22/2024  06:51 PM    <SYMLINK>      mic.h [..\..\..\ndp120\src\hal\mic.h]
05/22/2024  06:51 PM    <SYMLINK>      ndp115_dnn_regs.h [..\..\..\ndp120\src\hal\ndp115_dnn_regs.h]
05/22/2024  06:51 PM    <SYMLINK>      ndp115_regs.h [..\..\..\ndp120\src\hal\ndp115_regs.h]
05/22/2024  06:51 PM    <SYMLINK>      ndp115_spi_regs.h [..\..\..\ndp120\src\hal\ndp115_spi_regs.h]
05/22/2024  06:51 PM    <SYMLINK>      ndp120_dnn_regs.h [..\..\..\ndp120\src\hal\ndp120_dnn_regs.h]
05/22/2024  06:51 PM           534,106 ndp120_regs.h
05/22/2024  06:51 PM    <SYMLINK>      ndp120_spi_regs.h [..\..\..\ndp120\src\hal\ndp120_spi_regs.h]
05/22/2024  06:51 PM            29,847 ndp250a0_dnn_regs.h
05/22/2024  06:51 PM           579,097 ndp250a0_regs.h
05/22/2024  06:51 PM            27,311 ndp250a0_spi_regs.h
05/22/2024  06:51 PM    <SYMLINK>      ndp_regs.h [..\..\..\ndp120\src\hal\ndp_regs.h]
05/22/2024  06:51 PM    <SYMLINK>      notify.c [..\..\..\ndp120\src\hal\notify.c]
05/22/2024  06:51 PM    <SYMLINK>      notify.h [..\..\..\ndp120\src\hal\notify.h]
05/22/2024  06:51 PM    <SYMLINK>      pdm.c [..\..\..\ndp120\src\hal\pdm.c]
05/22/2024  06:51 PM    <SYMLINK>      pdm.h [..\..\..\ndp120\src\hal\pdm.h]
05/22/2024  06:51 PM    <SYMLINK>      pwr.c [..\..\..\ndp120\src\hal\pwr.c]
05/22/2024  06:51 PM    <SYMLINK>      pwr.h [..\..\..\ndp120\src\hal\pwr.h]
05/22/2024  06:51 PM    <SYMLINK>      ringbuf.c [..\..\..\ndp120\src\hal\ringbuf.c]
05/22/2024  06:51 PM    <SYMLINK>      ringbuf.h [..\..\..\ndp120\src\hal\ringbuf.h]
05/22/2024  06:51 PM    <SYMLINK>      sample.c [..\..\..\ndp120\src\hal\sample.c]
05/22/2024  06:51 PM    <SYMLINK>      sample.h [..\..\..\ndp120\src\hal\sample.h]
05/22/2024  06:51 PM    <SYMLINK>      sc_reg_alias.h [..\..\..\ndp120\src\hal\sc_reg_alias.h]
05/22/2024  06:51 PM    <SYMLINK>      sensor.c [..\..\..\ndp120\src\hal\sensor.c]
05/22/2024  06:51 PM    <SYMLINK>      sensor.h [..\..\..\ndp120\src\hal\sensor.h]
05/22/2024  06:51 PM    <SYMLINK>      sensor_function_list.c [..\..\..\ndp120\src\hal\sensor_function_list.c]
05/22/2024  06:51 PM    <SYMLINK>      sensor_function_list.h [..\..\..\ndp120\src\hal\sensor_function_list.h]
05/22/2024  06:51 PM            10,129 serial.c
05/22/2024  06:51 PM             1,142 serial.h
05/22/2024  06:51 PM    <SYMLINK>      softmax.c [..\..\..\ndp120\src\hal\softmax.c]
05/22/2024  06:51 PM    <SYMLINK>      softmax.h [..\..\..\ndp120\src\hal\softmax.h]
05/22/2024  06:51 PM    <SYMLINK>      spi.c [..\..\..\ndp120\src\hal\spi.c]
05/22/2024  06:51 PM    <SYMLINK>      spi.h [..\..\..\ndp120\src\hal\spi.h]
05/22/2024  06:51 PM    <SYMLINK>      spl.c [..\..\..\ndp120\src\hal\spl.c]
05/22/2024  06:51 PM    <SYMLINK>      spl.h [..\..\..\ndp120\src\hal\spl.h]
05/22/2024  06:51 PM    <SYMLINK>      test.c [..\..\..\ndp120\src\hal\test.c]
05/22/2024  06:51 PM    <SYMLINK>      test.h [..\..\..\ndp120\src\hal\test.h]
05/22/2024  06:51 PM    <SYMLINK>      timer.c [..\..\..\ndp120\src\hal\timer.c]
05/22/2024  06:51 PM    <SYMLINK>      timer.h [..\..\..\ndp120\src\hal\timer.h]
05/22/2024  06:51 PM    <SYMLINK>      varring.c [..\..\..\ndp120\src\hal\varring.c]
05/22/2024  06:51 PM    <SYMLINK>      varring.h [..\..\..\ndp120\src\hal\varring.h]
06/06/2024  09:31 AM            16,488 video.c
06/06/2024  09:31 AM               934 video.h
              86 File(s)      1,365,698 bytes
               3 Dir(s)  917,827,252,224 bytes free

C:\Users\Joe\GitLab\syntiant-dsp-firmware.git\ndp250\src\hal>

« Last Edit: September 04, 2024, 09:21:49 PM by joecar »

joecar

  • Senior Community Member
  • Posts: 437
  • Hero Points: 9
  • engineer/gearhead
Re: Excluding symbolic links
« Reply #5 on: June 28, 2024, 06:17:39 PM »
( it appears Windows dir command figures out that a filename is a symlink )

joecar

  • Senior Community Member
  • Posts: 437
  • Hero Points: 9
  • engineer/gearhead
Re: Excluding symbolic links
« Reply #6 on: August 19, 2024, 05:49:50 PM »
BTW: found another app that recognizes symlinks in Windows...


Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6934
  • Hero Points: 531
Re: Excluding symbolic links
« Reply #7 on: August 19, 2024, 07:17:03 PM »
SlickEdit does have some support for symlinks on Windows. By default, symbolic link support is off. Specify the +ssymlinkdirs invocation option if you want SlickEdit to recognize symbolic links directories. Specify the +ssymlink invocation option if you want SlickEdit to recognize symbolic links in files and directories. Checking for symbolic links on Windows is expensive even with caching optimizations. On Windows, SlickEdit doesn't have features for excluding symbolic links in various ways.
« Last Edit: August 20, 2024, 02:26:25 PM by Clark »

joecar

  • Senior Community Member
  • Posts: 437
  • Hero Points: 9
  • engineer/gearhead
Re: Excluding symbolic links
« Reply #8 on: August 19, 2024, 11:43:04 PM »
More specifically, I was looking for being able to exclude following symlinks in the Add Tree project dialog

( i.e. Project Properties -> Files -> Add Tree )


Graeme

  • Senior Community Member
  • Posts: 2812
  • Hero Points: 347
Re: Excluding symbolic links
« Reply #9 on: August 20, 2024, 07:30:07 AM »
You can use the "import" button in the project properties dialog to import the list of files and folders from a text file.

Theoretically you should be able to create a file list for importing, using the windows dir command
dir /s /b /a-L

/s recurse
/b bare format
/a-L   files that do not have the L attribute  - this is for "reparse points" i.e. symlinks and junctions

However the /a-L switch is not working for me.  /a-L gets me nothing,  /aL gets me everything.
Maybe it will work better for you.
Also you can exclude folders with /A-D.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6934
  • Hero Points: 531
Re: Excluding symbolic links
« Reply #10 on: August 20, 2024, 02:27:41 PM »
I was incorrect. By default, SlickEdit has symbolic link support disabled. I have corrected my previous post. An invocation option must be used to enable some level of symbolic link support.

joecar

  • Senior Community Member
  • Posts: 437
  • Hero Points: 9
  • engineer/gearhead
Re: Excluding symbolic links
« Reply #11 on: August 20, 2024, 04:39:42 PM »
Graeme, thanks, I'll try that.

joecar

  • Senior Community Member
  • Posts: 437
  • Hero Points: 9
  • engineer/gearhead
Re: Excluding symbolic links
« Reply #12 on: August 21, 2024, 04:12:09 PM »
I appear to be getting correct display for dir /al and dir /a-l.

Graeme

  • Senior Community Member
  • Posts: 2812
  • Hero Points: 347
Re: Excluding symbolic links
« Reply #13 on: August 22, 2024, 02:52:34 AM »
ok, good.  I've discovered that all the files in the folder I was testing with have the "L" attribute - most likely because it's within my OneDrive folder.  You could probably ask Gemini or Github copilot to write you a windows app that can output a list of "non-symbolic" files and folders!  The dir command knows which files in my onedrive folder are real symbolic links.

Graeme

  • Senior Community Member
  • Posts: 2812
  • Hero Points: 347
Re: Excluding symbolic links
« Reply #14 on: August 22, 2024, 02:57:32 AM »
From Gemini

Code: [Select]
using System;
using System.IO;

namespace ListFilesExcludingSymbolicLinks
{
    class Program
    {
        static void Main(string[] args)
        {
            string folderPath = @"C:\Your\Folder\Path"; // Replace with the actual folder path

            try
            {
                foreach (string filePath in Directory.EnumerateFiles(folderPath))
                {
                    FileAttributes fileAttributes = File.GetAttributes(filePath);

                    // Check if the file is a symbolic link
                    if ((fileAttributes & FileAttributes.ReparsePoint) == FileAttributes.ReparsePoint)
                    {
                        Console.WriteLine($"Skipping symbolic link: {filePath}");
                        continue;
                    }

                    Console.WriteLine(filePath);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Error: {ex.Message}");
            }
        }
    }
}


1. Create a new C# console application project.
2. Paste the code into the Program.cs file.
3. Replace the placeholder folder path with the actual path you want to scan.
4. Run the application.