openAt

abstract fun openAt(path: String, openFlags: OpenFlags = OpenFlags(), flags: DescriptorFlags = DescriptorFlags(read = true), pathFlags: PathFlags = PathFlags(true), descriptor: Descriptor = StandardDescriptor.FIRST_PREOPEN): Descriptor

Open a file or directory.

The returned descriptor is not guaranteed to be the lowest-numbered descriptor not currently open/ it is randomized to prevent applications from depending on making assumptions about indexes, since this is error-prone in multi-threaded contexts. The returned descriptor is guaranteed to be less than 2**31.

If flags contains DescriptorFlags.mutateDirectory, and the base descriptor doesn't have DescriptorFlags.mutateDirectory set, openAt fails with ErrorCode.READ_ONLY.

If flags contains DescriptorFlags.write, or openFlags contains OpenFlags.truncate or OpenFlags.create, and the base descriptor doesn't have DescriptorFlags.mutateDirectory set, openAt fails with ErrorCode.READ_ONLY.

Note: This is similar to openat in POSIX.

TODO Support modes

Parameters

path

The relative path of the object to open.

descriptor

Reference to the parent directory where the new one should be created.

openFlags

The method by which to open the file.

flags

Flags to use for the resulting descriptor.

pathFlags

Flags determining the method of how the path is resolved.