Skip to content

Write the output file name into the header of IFC files from tdbio - #49

Merged
mahach666 merged 2 commits into
mainfrom
fix/ifc-header-file-name
Nov 28, 2026
Merged

mahach666 merged 2 commits into
mainfrom
fix/ifc-header-file-name

Conversation

@mahach666

@mahach666 mahach666 commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

What changes and why

tdbio export model.db1 out.ifc wrote the name of its temporary file into the header: FILE_NAME('.out.ifc.<32 hex digits>.tmp',...). WriteIfc(path) takes that name from the path it is given, and the command line gave it the temporary path. The library overload that takes the name separately is internal.

  • The temporary file now has the name of the output file and is in a temporary folder .<32 hex digits>.tmp next to it. It is moved into place as before, and the folder is removed. No public API changes.
  • On Linux and macOS the new folder follows the umask. When its owner lacks the read, write or execute right on it, tdbio adds all three. Without this, a umask such as 177 would leave the owner unable to create the output file in the folder, although a file next to the output could still be created.
  • Creating that folder would also create missing folders above it, so a missing output folder is checked first. It is still exit code 2 with nothing created.
  • Two error messages change. For a missing output folder, the message now names that folder. For an existing folder given as the output with a trailing separator, the access denied message now names the temporary folder. The exit code stays 2.

Known limit: writing a file now needs the right to create folders in the output folder. Windows permissions that allow creating files but not folders are expected to make the export fail; this case was not tried.

The CHANGELOG is not changed, because the IFC output is not released yet.

How it was checked

  • dotnet build TdbIO.slnx -c Release has no warnings
  • dotnet test TdbIO.slnx -c Release passes: on net8.0 and net10.0, TdbIO.Tests 497 passed and 38 skipped (private inputs), TdbIO.Scene.Tests 13 passed
  • Output of tdbio info, tdbio tables and tdbio text on the same files is identical before and after: 18 of 18 runs, with and without --json, on three synthetic models
  • No Tekla models, customer data or vendor files are added

New tests: the header of an exported IFC file holds the output name and nothing else is left next to the file (fails without the change); an export into a missing folder is an input error and creates nothing (passes with and without the change, and guards the new temporary folder). An export that cannot replace its output, because a folder stands there, leaves nothing behind; this test fails when the cleanup is moved out of finally. An export under umask 177 writes the file. It calls umask from libc and Cli.Run in the test process, so it is in a collection that does not run beside other tests.

The umask test returns at once on Windows, and the code it covers runs only on Linux and macOS. Neither has run locally: CI is their first run, and the test has not been run against the code without the added rights. On Windows, the rest of the test passes with the early return and the umask calls removed in a scratch copy.

The native engine build of TdbIO.Scene (-p:BuildNativeCoreOnly=true), dotnet pack with the package validation against 0.1.0 forced to run, and git diff --check pass.

Export comparison

tdbio on net8.0, before and after, on a synthetic model with one part.

  • JSON: identical byte for byte.
  • Scene JSON, also written to a name ending in .gz, and HTML: identical except for the time of the run.
  • IFC: apart from the export times and random identifiers, only the FILE_NAME line differs. Output to stdout still has model.ifc.
  • An existing destination file is replaced, and no temporary folder remains, also after the failing cases above.
  • A file name with Cyrillic letters, a space and an apostrophe: ifcopenshell 0.8.4 reads the same name from the header, and its schema validation reports nothing.

#48 is merged. This branch merges with main at 2f304b0 without conflicts, and a local copy of that merge builds and passes the tests (TdbIO.Tests 503 passed and 38 skipped, TdbIO.Scene.Tests 13 passed, on net8.0 and net10.0).

Not run: private test files and real models, and local runs on Linux or macOS.

WriteIfc puts the name of the path it is given into FILE_NAME, and tdbio
gave it a temporary path. The temporary file now has the name of the output
and is in a temporary folder next to it. A missing output folder is still an
input error: it is checked first, so that creating the temporary folder does
not create it.
The new folder follows the umask, which can leave its owner unable to create
a file in it, as umask 177 does on Linux and macOS, although a file next to
the output can still be created. When the owner lacks the read, write or
execute right on the folder, tdbio now adds all three.

Add a test of an export under that umask, which does nothing on Windows, and
a test that an export which cannot replace its output leaves nothing behind.
@mahach666
mahach666 merged commit 31eebf4 into main Nov 28, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant