islink
by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - File handling
Introduced first in SolidGeometry 5.1, Creation date: 2021-03-19, Last change: 2025-09-15
returns wether a file is just a link
Description
implemented at the moment only for mac osx 10.15.7.
This function is important to avoid copying a link over the original document when using copyfile or movefile and thus losing the content. Links/aliases should not be copied
See Also:
Example Illustration
Syntax
islink=islink(fname)
Input Parameter
Output Parameter
islink: | | yes if the fname is a link |
Examples
islink('/Users/lueth/Desktop/LUETH-WIN Alias')
Copyright 2021-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth
Algorithm (Workflow)
This function, islink, determines if a given file is a link (alias) on macOS 10.15.7. It is part of the SolidGeometry library and is specifically designed to prevent copying links instead of the original files.
Input Parameters
- fname: The name of the file to be checked.
Output Results
- islink: Returns true if the file is a link, otherwise false.
Algorithm Steps
- Check if the operating system is macOS using
ismac. If not, display a warning that the function is not tested on other systems.
- Define a byte sequence
maclnk that represents the header of a macOS alias file.
- Check if the file specified by
fname exists using isfile.
- If the file exists, open it in read mode using
fopen. If the file cannot be opened, display an error message.
- Read the first few bytes of the file using
fgets to match the length of maclnk.
- Compare the read bytes with
maclnk using isequal. If they match, set islink to true, indicating the file is a link.
- If the file does not exist, set
islink to false.
- If no output argument is specified, print the read bytes using
dbprintf.
Algorithm explaination created using ChatGPT on 2025-08-19 01:01. (Please note: No guarantee for the correctness of this explanation)
Last html export of this page out of FM database by TL: 2025-09-21