Minecraft Blogs / Article

Modifying texture packs with symbolic links — when to copy, link soft or link hard

  • 978 views, 2 today
  • 4
  • 3
Hebgbs's Avatar Hebgbs
Level 48 : Master Archer
45
(Source of provided image is indeterminate — Help me find the origin, if you may.)

Introduction

I like symbolic links. It's just how I do things — on a space-constrained system, links let users pack in more things on one's local filesystem, as content which would otherwise be duplicated is linked elsewhere. Hopefully, this writ will help you along your way of pack modding in this particular fashion, so you can make exactly what you want.

Needless to say this only works for unpacked resource files. This means, in .minecraft/resourcepacks tampering with resource packs in this way needs them to be decompressed.

Licensing

To first know if you can proceed to make modifications, you must first understand licensing. Some authors will consent modifications, and even encourage it, while other authors will tell you not to do it — some go as far to say you have a contractual obligation to leave their work alone.
Personally, I have a thing against this. I do not understand — imagine if Mojang told everybody that they must enjoy the game their way, and their way alone. How little content would Planet Minecraft have to offer if Mojang had that kind of attitude. Nonetheless, some authors will go to great lengths ensuring their work isn't "Misappropriated" in some way, even if it is within the interest of such authors to embrace these kinds of parasitic symbiotic relationships which eventually come from a community of peers using their work. Nonetheless, Planet Minecraft — at their discretion — will not delay in removing discovered offending works, so act with caution.
If someone doesn't want any of their work to be remixed / modified, then the easiest option is to simply not do it. If you believe otherwise, then don't bother posting it. And if you happen to do video content with such works, don't use your modifications, or distribute them through preferred platforms on request.

If the author of a work wouldn't mind remixes or modifications, most likely with a license such as Creative Commons' Attribution-ShareAlike, then you're free to do whatever you want at that point, so long license terms are exercised and go about tweaking things until your heart is content.

Filesystem links for dummies (abridged)

Links are references to files. Some disk partition formats — regardless of partition table format used — allow for these references to be made. Coincidentally these "Journaling" formats as they are called are also some of the world's most popular, namely Microsoft's New Technology Filesystem (NTFS5) and the open-source Fourth Extended Filesystem (Ext4). Using various tools, links can be made which will use a new file ID / index node for referring to another file relatively (by path) or directly (by ID / index). To be used as the actual file, links must be de-referenced for transport of the real file elsewhere
About the Extended Filesystem series used on open-source platforms — links were a thing since Ext2!

Apple does their own thing with APFS but it's mostly the same, though hard links are disallowed — soft links are all one can do with that partition format, and for good reason: On most systems, it is difficult, if not impossible to distinguish without advanced tools hard links, because hard links are the file, by virtue what you see as a end-user and what the computer knows are held mutually-exclusive — One index can represent many files, and the index isn't eligible for overwriting with new data until all files of it are destroyed.

This makes hard links dangerous, but also allows for clever use of hard links for uploading files online which need to exist in a specific directory path or creating de-referenced files for use in multiple compressed archives. While technically also possible with soft links, it is less likely software which allows for de-referencing will do such for symbolic links, such as Git management tools, which in my experience treats soft links as its own file, rather than de-referencing them. How software de-references symbolic links should be studied as how such is handled is on a case-by-case basis.
If you read the above and said to yourself "Ooooh, I like danger!" cut that crap right now. The danger lies in malicious software using hard links to constantly replicate itself with little effort, which makes removing said malware exceedingly difficult without removing the original index, the act of such being out of reach for most people. It's no joke.

About using hard links to make re-use of files easier, specifically for archival, the de-referencing must be done by the archival program. It's not magic, but it's possible and most likely the solutions available for most people will create archives using de-referenced files without you needing to do anything.

When to do what

Copying is universal for everything, though when to use what links will differ based on circumstances. Such is explained below.

Copy

If modifying a file, there is no choice and it is not a matter for discussion — If you're changing a file, it is different, as such it must be saved in the directory with your modified works. There are also some instances Minecraft just hates links — If something you used a soft or hard link for is not acting as expected, then using copies will work, just understand if this file is to exist in multiple locations and you want them to be the same everywhere then you must update all instances yourself.

Soft link

When you just want to be lazy — If there are a ton of files inside a ton of directories, there is no easier way to deal with the problem of reusing these without wasting space using duplicates than to use soft links. It's also your only option if your local filesystem has multiple partitions or disks files must be referenced from. Many references to a specific location — relative (within a specific directory) or absolute (by full path) — can be made, but the original cannot be moved or destroyed. If that ever happens, oops goes your stuff and there is no recourse for getting it back if it's a permanent deletion from disk.

Hard link

If your partition format supports this, then you can use hard links to make a bunch of files which refer to indexes of other files. What this means is you're using the real files they're just referenced from elsewhere, but (at least in my experience with the Ext4 format) they're not distinguishable, visually from the real files.
In most instances directories cannot be hard linked. I won't bother to explain this beyond turning the tree-style directory structure most users rely upon for knowing where their stuff is into a circular structure with no end.

Hard links are harder to deal with in directories with multiple other directories, each with their own set of files but are more nice in the sense that if the directory you're working in is moved, the links shouldn't break... unless the directory is moved to another partition or disk, in which case the link becomes invalid as the index no longer exists, being on a separate media or partition.

Hard links can also exist between different files in directories on the same partition which those directories can then be soft linked.

Should you bother?

If you have difficulty juggling three tasks in your head, then probably not. As neat and convenient any kind of file linking is, if you have difficulty visualizing your filesystem tree, then you'll have one hell of a time getting to grips with this. For Linux it requires the use of GNU Coreutils' ln in the terminal more times than not as GUI implementations for many desktop environments are a joke, but Windows users have it easy — Hermann Schinagl developed this neat tool called Link Shell Extension if the uninitiated using what is arguably the world's most popular desktop OS series want to dip their toes into this concept for the practical reason of not ever creating duplicates of the same files, which is especially handy for game modding.

For scripting making such scripts in Windows sucks. Either batch or powershell, I found it's complicated beyond belief to make a script which doesn't suck for other people to execute, whereas on open-source systems with GNU Coreutils' ln (or using "Ubuntu on Windows" which is literally just the Bourne Again shell — "bash" — to use GNU's ln) symbolic linking through the command line incurs less pain and feels more intuitive to make scripts with, especially when regular expressions can be used to enable asterisk as wildcard for linking multiple files within the same directory.

However you go about it, don't forget to have fun doing it. And if filesystem management isn't your idea of fun… I don't blame you! It's the most God-damn boring thing on the face of the planet for me, but it's like many other things in life which are necessary — You do the boring things as a means of getting to the good stuff.
Tags

1 Update Logs

Update #1 : by Hebgbs 01/12/2021 12:42:02 pmJan 12th, 2021

Improved de-referencing information. How the act of not using links handled by software was shoddily explained.

Create an account or sign in to comment.

Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome