import { type ByteSource } from '../../io/types.ts';
import type { FileDescription } from '../../shell/descriptors.ts';
import type { DispatchFn } from '../../runtime/types.ts';
import { PathSpec } from '../../types.ts';
import type { SessionState } from '../session/session.ts';
/**
 * Write or append, giving a newly created file the umask's mode.
 *
 * Every shell path that opens a file for writing goes through here, so
 * `echo x > f` and `exec > f` agree about the mode a fresh file gets:
 * 0666 masked by the session's umask, which is what `open(2)` with
 * `O_CREAT` does. Living in one place is the point; the two callers had
 * drifted while it was private to one of them.
 *
 * The existence probe runs only under a non-default umask, because that
 * is the one case the answer changes anything: a fresh file already
 * renders as 644, which is 0666 under bash's default mask. A mode that
 * cannot be written is swallowed and not fatal, since the bytes are
 * already there and the write is what the caller asked for.
 *
 * Returns the live pipe the open reached, directly or through a link, which
 * a descriptor goes on writing to whatever becomes of the name it was opened
 * by; null for anything else. Mirrors Python's create_file.
 */
export declare function createFile(dispatch: DispatchFn, session: SessionState, scope: PathSpec, data: ByteSource, append?: boolean): Promise<PathSpec | null>;
/**
 * Write through a shared open description and advance its offset.
 *
 * A write-only description lands at its offset with one `pwrite`, so it
 * needs no read of the file, as a write to a write-only descriptor needs none
 * (`exec 3>f; echo a >&3`). Its first write into a file still empty lands as
 * one stream instead (`firstWrite`). A read-write one (`<>`) still reads it:
 * that description was opened to read, and its own reader resumes over what
 * the write left. Writes through one description take turns, the first one
 * (which opens the file) included, as the kernel orders writes to an open
 * file: a background job writing alongside the shell neither reopens the
 * file nor lands on an offset another write has not advanced yet. A writer
 * killed while it waits for its turn writes nothing: a promise cannot be
 * cancelled, so the turn checks the writer's execution frame, as
 * Python's cancelled task leaves the queue. What a killed command wrote
 * before it stopped (`kept`) still lands, as Python's task writes on once
 * it has taken its cancel.
 */
export declare function writeDescription(dispatch: DispatchFn, session: SessionState, file: FileDescription, data: ByteSource, replace?: boolean, kept?: boolean): Promise<void>;
//# sourceMappingURL=create.d.ts.map