Skip to content

[Feature Request] Provide facility to change the current working directory #22

Description

@christianhujer

It would be great if system-lambda would also provide a facility to change the current working directory.
As far as I am aware, this requires two things at the same time:
a) setting the System property user.dir.
b) Making a native call to chdir() or fchdir()

The JRuby folks seem to have done something like this.

See also: https://stackoverflow.com/a/8204584/3554264

CAVEAT: The working directory is a process attribute, not a thread attribute. Changing it may have undesired results when running tests in parallel should these tests directly or indirectly rely on the current working directory in any way.

I would expect code to work like this:

@Test
void chDirExample() {
    withCwd(Path.of(".").parent, () -> System.out.println(Pathof(".")));
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions