WerWolv / WerWolv/PatternLanguage

File inclusion and import from current directory

Open
#200 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
275
Forks
75
Avg merge
1d 22h
Merged PRs (30d)
10

Description

Hi,

First of all, thanks for imHex. I'm using imHex to reverse-engineer savegame data formats, but the in-app pattern editor isn't really geared towards writing a lot of code. So far, I solved this by having the pattern editor just contain #include "/Users/red/MyProject/base.hexpat", and doing my editing in my editor of choice.

When even that file began to get too large, I started splitting it into sub-modules, so base.hexpat now also contains #include "/users/red/MyProject/items.hexpat" and I guess I'll do the same soon for other parts of the savegame. However, it's not suited for future sharing of those files, especially if users all need to rewrite the path.

I was hoping I could use C-like #include "./player.hexpat" but to no avail. I checked into the source, and from what I see, the resolver doesn't have a concept of __FILE__ from where to check, and I'd guess that since the pattern language is mostly ran from inside the imHex pattern editor, that notion doesn't really exist.

Therefore, I'm not entirely sure of the breadth of changes this would require, I was hoping a quick "check if path starts with a dot" (or even just "add current directory to include paths") would suffice, but I guess this goes beyond a quick one-liner.

Totally understandable if that’s out of scope for now, just felt this would be useful to point out.

And again, thanks for imHex, it's awesome!

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in lib/source/pl/core/resolvers.cpp, which the issue identifies as the include resolver, and trace how an included file is located when code is loaded from the pattern editor. Define how relative paths such as "./player.hexpat" should resolve from the including file, then verify that split pattern files can be shared without user-specific absolute paths.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.