Skip to content

Conversation

kateinoigakukun
Copy link
Member

No description provided.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements the path_rename WASI function to support file and directory renaming operations. The implementation adds cross-directory rename support using the renameat system call and includes special handling for trailing slashes in paths.

  • Implements the path_rename function in WASIBridgeToHost with proper directory validation
  • Adds rename method to WASIDir protocol and DirEntry implementation with trailing slash handling
  • Extends FileDescriptor with renameat system call wrapper functions

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
Tests/WASITests/IntegrationTests.swift Removes previously failing rename tests from exclusion list
Sources/WASI/WASI.swift Implements path_rename function with directory validation
Sources/WASI/Platform/SandboxPrimitives/OpenParent.swift Adds utility functions for handling trailing slashes in paths
Sources/WASI/Platform/Directory.swift Implements rename method with cross-platform support and trailing slash handling
Sources/WASI/FileSystem.swift Adds rename method to WASIDir protocol
Sources/SystemExtras/Syscalls.swift Adds system wrapper for renameat syscall
Sources/SystemExtras/FileAtOperations.swift Adds FileDescriptor extension methods for rename operations

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +144 to +146
// Re-append a slash if the original path had one
let finalSourceBasename = oldHasTrailingSlash ? sourceBasename + "/" : sourceBasename
let finalDestBasename = newHasTrailingSlash ? destBasename + "/" : destBasename
Copy link

Copilot AI Oct 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider extracting the slash re-appending logic into a helper function to reduce code duplication and improve readability.

Copilot uses AI. Check for mistakes.

to newDirFd: FileDescriptor,
at newPath: UnsafePointer<CInterop.PlatformChar>
) -> Result<(), Errno> {
#if os(Windows)
Copy link

Copilot AI Oct 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Windows error code ERROR_NOT_SUPPORTED should be documented or explained why this specific error is chosen over other potential Windows error codes for unsupported operations.

Suggested change
#if os(Windows)
#if os(Windows)
// The Windows API does not provide a direct equivalent to `renameat`.
// ERROR_NOT_SUPPORTED is used to indicate that this operation is not supported on Windows.

Copilot uses AI. Check for mistakes.

@kateinoigakukun kateinoigakukun force-pushed the katei/implement-path-rename branch from 67dc2db to a1aa0e0 Compare October 5, 2025 07:40
@kateinoigakukun kateinoigakukun merged commit b2863bb into main Oct 5, 2025
15 checks passed
@kateinoigakukun kateinoigakukun deleted the katei/implement-path-rename branch October 5, 2025 08:06
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