import { AppInfo } from "../appInfo.js";
import { Maybe } from "../common/types.js";
export declare enum RootBranch {
Public = "public",
Pretty = "p",
Private = "private",
PrivateLog = "privateLog",
Shared = "shared",
SharedCounter = "sharedCounter",
Version = "version"
}
export declare enum Kind {
Directory = "directory",
File = "file"
}
export declare type Segment = string;
export declare type Segments = Segment[];
export declare type SegmentsNonEmpty = [Segment, ...Segments];
export declare type Partitioned
= [P, ...Segments];
export declare type PartitionedNonEmpty
= [P, Segment, ...Segments];
/**
* Private partition
*/
export declare type Private = "private" | RootBranch.Private;
/**
* Public partition
*/
export declare type Public = "public" | RootBranch.Public;
/**
* `RootBranch`es that are accessible through the POSIX file system interface.
*/
export declare type Partition = Private | Public;
/**
* A directory path.
*/
export declare type DirectoryPath
= {
directory: P;
};
/**
* A file path.
*/
export declare type FilePath
= {
file: P;
};
/**
* A file or directory path.
*/
export declare type DistinctivePath
= DirectoryPath
| FilePath
;
/**
* Alias for `DirectoryPath`
*/
export declare type Directory
= DirectoryPath
;
/**
* Alias for `FilePath`
*/
export declare type File
= FilePath
;
/**
* Alias for `DistinctivePath`
*/
export declare type Distinctive
= DistinctivePath
;
/**
* Utility function to create a `DirectoryPath`
*/
export declare function directory
(...args: PartitionedNonEmpty
): DirectoryPath>;
export declare function directory(...args: Partitioned
): DirectoryPath>;
export declare function directory(...args: SegmentsNonEmpty): DirectoryPath;
export declare function directory(...args: Segments): DirectoryPath;
/**
* Utility function to create a `FilePath`
*/
export declare function file(...args: PartitionedNonEmpty
): FilePath>;
export declare function file(...args: SegmentsNonEmpty): FilePath;
export declare function file(...args: Segments): FilePath;
/**
* Utility function to create a root `DirectoryPath`
*/
export declare function root(): DirectoryPath;
/**
* Utility function create an app data path.
*/
export declare function appData(app: AppInfo): DirectoryPath>;
export declare function appData(app: AppInfo, suffix: FilePath): FilePath>;
export declare function appData(app: AppInfo, suffix: DirectoryPath): DirectoryPath>;
export declare function appData(app: AppInfo, suffix: DistinctivePath): DistinctivePath>;
/**
* Transform a string into a `DistinctivePath`.
*
* Directories should have the format `path/to/dir/` and
* files should have the format `path/to/file`.
*
* Leading forward slashes are removed too, so you can pass absolute paths.
*/
export declare function fromPosix(path: string): DistinctivePath;
/**
* Transform a `DistinctivePath` into a string.
*
* Directories will have the format `path/to/dir/` and
* files will have the format `path/to/file`.
*/
export declare function toPosix(path: DistinctivePath, { absolute }?: {
absolute: boolean;
}): string;
/**
* Combine two `DistinctivePath`s.
*/
export declare function combine(a: DirectoryPath>, b: FilePath): FilePath>;
export declare function combine(a: DirectoryPath>, b: FilePath): FilePath>;
export declare function combine(a: DirectoryPath>, b: FilePath): FilePath>;
export declare function combine(a: DirectoryPath, b: FilePath): FilePath;
export declare function combine(a: DirectoryPath>, b: DirectoryPath): DirectoryPath>;
export declare function combine(a: DirectoryPath>, b: DirectoryPath): DirectoryPath>;
export declare function combine(a: DirectoryPath>, b: DirectoryPath): DirectoryPath>;
export declare function combine(a: DirectoryPath, b: DirectoryPath): DirectoryPath;
export declare function combine(a: DirectoryPath>, b: DistinctivePath): DistinctivePath>;
export declare function combine(a: DirectoryPath>, b: DistinctivePath): DistinctivePath>;
export declare function combine(a: DirectoryPath>, b: DistinctivePath): DistinctivePath>;
export declare function combine(a: DirectoryPath, b: DistinctivePath): DistinctivePath;
/**
* Is this `DistinctivePath` a directory?
*/
export declare function isDirectory(path: DistinctivePath
): path is DirectoryPath
;
/**
* Is this `DistinctivePath` a file?
*/
export declare function isFile
(path: DistinctivePath
): path is FilePath
;
/**
* Is this `DistinctivePath` of the given `Partition`?
*/
export declare function isPartition(partition: Partition, path: DistinctivePath): boolean;
/**
* Is this `DistinctivePath` on the given `RootBranch`?
*/
export declare function isOnRootBranch(rootBranch: RootBranch, path: DistinctivePath): boolean;
/**
* Is this `DirectoryPath` a root directory?
*/
export declare function isRootDirectory(path: DirectoryPath): boolean;
/**
* Check if two `DistinctivePath` have the same `Partition`.
*/
export declare function isSamePartition(a: DistinctivePath, b: DistinctivePath): boolean;
/**
* Check if two `DistinctivePath` are of the same kind.
*/
export declare function isSameKind(a: DistinctivePath, b: DistinctivePath): boolean;
/**
* What `Kind` of path are we dealing with?
*/
export declare function kind(path: DistinctivePath): Kind;
/**
* Map a `DistinctivePath`.
*/
export declare function map(fn: (p: A) => B, path: DistinctivePath): DistinctivePath;
/**
* Get the parent directory of a `DistinctivePath`.
*/
export declare function parent(path: DistinctivePath<[Partition, Segment, Segment, ...Segments]>): DirectoryPath>;
export declare function parent(path: DistinctivePath<[Segment, Segment, Segment, ...Segments]>): DirectoryPath;
export declare function parent(path: DistinctivePath>): DirectoryPath>;
export declare function parent(path: DistinctivePath<[Partition, Segment]>): DirectoryPath>;
export declare function parent(path: DistinctivePath>): DirectoryPath;
export declare function parent(path: DistinctivePath): DirectoryPath;
export declare function parent(path: DistinctivePath<[Segment]>): DirectoryPath<[]>;
export declare function parent(path: DistinctivePath<[]>): null;
export declare function parent(path: DistinctivePath): Maybe>;
/**
* Remove the `Partition` of a `DistinctivePath` (ie. the top-level directory)
*/
export declare function removePartition(path: DistinctivePath): DistinctivePath;
/**
* Get the last part of the path.
*/
export declare function terminus(path: DistinctivePath): Maybe;
/**
* Unwrap a `DistinctivePath`.
*/
export declare function unwrap(path: DistinctivePath
): P;
/**
* Utility function to prefix a path with a `Partition`.
*/
export declare function withPartition
(partition: P, path: DirectoryPath): DirectoryPath>;
export declare function withPartition(partition: P, path: DirectoryPath): DirectoryPath>;
export declare function withPartition(partition: P, path: FilePath): FilePath>;
export declare function withPartition(partition: P, path: FilePath): FilePath>;
export declare function withPartition(partition: P, path: DistinctivePath): DistinctivePath>;
export declare function withPartition(partition: P, path: DistinctivePath): DistinctivePath>;
/**
* Render a raw `Path` to a string for logging purposes.
*/
export declare function log(path: Segments): string;