Skip to content

Carbon: move the File Manager to Swift over Graphite - #462

Merged
colemancda merged 10 commits into
masterfrom
feature/carbon-files
Nov 26, 2026
Merged

colemancda merged 10 commits into
masterfrom
feature/carbon-files

Conversation

@colemancda

Copy link
Copy Markdown
Member

Phase 2 of Documentation/Plans/graphite.md, first of three PRs, against master: files.c moves to Swift over GraphiteFiles (PureSwift/Graphite#12).

Carbon

  • Sources/PerryCarbon/Files.swift exports everything files.c did except the six below:
    • FSSpecs and colon paths;
    • files by reference number and parameter block, PBReadAsync included;
    • forks and their iteration, creating, moving, renaming and deleting;
    • folders' items and the default folder;
    • volume information with the mounted discs;
    • PBGetCatInfo, the desktop database stubs and Launch Services.
  • What changes for programs:
    • Resource forks open for real, from the ._name AppleDouble file beside a file, or name.rsrc, and are written back there. files.c opened them empty.
    • Finder info (type, creator, flags) is kept in that AppleDouble file. It's written by FSpCreate, by FSCreateFileUnicode and FSCreateDirectoryUnicode with catalog information, and by FSSetCatalogInfo. PBGetCatInfo reports it, with the resource fork's sizes.
    • Names are found in any case, as HFS+ programs assume, and FSSpec names longer than 63 bytes are mangled with # and their ID.
    • ppc: FSAllocateFork, FSReadFork, FSWriteFork, FSSetForkSize and FSSetForkPosition are @DarwinC, so their 64-bit offsets arrive where Darwin passes them. FSAllocateFork's were in the wrong registers.
  • files.c stays for the C build (Scripts/build-i386-carbon.sh, build-ppc-carbon.sh), fenced out of SwiftPM with PERRY_CARBON_SWIFT as phase 1's files are. Its packed structures move to PerryCarbon.h, and its bundle, disc and startup-volume lookups to places.c, which both builds share.

The six duplicates

  • FSNewAlias, FSNewAliasMinimal, FSResolveAlias, FSResolveAliasWithMountFlags, GetAliasSize and FSGetCatalogInfo were in both files.c and CoreServices' FileManager.swift. They are now CoreServices' alone, in the C build too, and leave exports.txt (572 → 566).
  • FileManager.swift's versions move onto GraphiteFiles:
    • Catalog information gives the folder IDs Carbon's FSSpecs use (the root 2, its parent 1) rather than raw inodes. Carbon's FSGetCatalogInfo existed to make up for that. It also gives Finder info and the resource fork's sizes.
    • Aliases keep their record (user type, size, 'PRRY', path) and add the item's device and inode, so they find an item that moved. Records saved by the old code still resolve by path.

Checks

  • Built natively on Debian arm64 with Swift 6.4.2: PerryCarbon and PerryUniformTypeIdentifiers, no warnings in the new code.
  • Scripts/check-carbon-exports.sh passes on both the SwiftPM library and the C-only one: 566 exports, as listed.
  • The check now skips swift-system's _system_get_ST_* C helpers, which GraphiteFiles links and no program binds to.
  • Not run: i386 and ppc builds, which need the perry-dev image, and the Carbon fixtures. CI covers those.

@colemancda
colemancda merged commit ab365cf into master Nov 26, 2026
7 of 8 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