# Class FileSystem

#### Hierarchy

- FileSystem

#### Implements

- API

- Defined in fs/filesystem.ts:89

#####
Index

### Constructors

constructor

### Properties

_publishWhenOnline
_publishing
account
dependencies
localOnly
proofs
publishHooks
root

### Methods

_beforeLeaving
_whenOnline
acceptShare
add
addPublicExchangeKey
cat
checkMutationPermissionAndAddProof
deactivate
exists
get
hasPublicExchangeKey
historyStep
loadShare
ls
mkdir
mv
publish
read
resolveSymlink
rm
runMutationOnNode
runOnChildTree
runOnNode
sharePrivate
symlink
write
empty
fromCID

## Constructors

### constructor

- new FileSystem(__namedParameters: ConstructorParams): FileSystem

- #### Parameters

  - ##### __namedParameters: ConstructorParams

  #### Returns FileSystem

  - Defined in fs/filesystem.ts:104

## Properties

### _publishWhenOnline

_publishWhenOnline: [CID<unknown, number, number, Version>, Ucan][]

- Defined in fs/filesystem.ts:100

### _publishing

_publishing: false | [CID<unknown, number, number, Version>, true]

- Defined in fs/filesystem.ts:101

### account

account: AssociatedIdentity

Implementation of API.account

- Defined in fs/filesystem.ts:91

### dependencies

dependencies: Dependencies

- Defined in fs/filesystem.ts:92

### `Readonly` localOnly

localOnly: boolean

- Defined in fs/filesystem.ts:95

### proofs

proofs: {
[_: string]: Ucan;
}

#### Type declaration

- ##### [_: string]: Ucan

- Defined in fs/filesystem.ts:97

### publishHooks

publishHooks: PublishHook[]

- Defined in fs/filesystem.ts:98

### root

root: default

- Defined in fs/filesystem.ts:94

## Methods

### _beforeLeaving

- _beforeLeaving(e: Event): string | void
- `Internal`

  #### Parameters

  - ##### e: Event

  #### Returns string | void

  - Defined in fs/filesystem.ts:874

### _whenOnline

- _whenOnline(): void
- `Internal`

  #### Returns void

  - Defined in fs/filesystem.ts:864

### acceptShare

- acceptShare(__namedParameters: {
  shareId: string;
  sharedBy: string;
  }): Promise<FileSystem>

- Accept a share. Copies the links to the items into your 'Shared with me' directory. eg. `private/Shared with me/Sharer/`

  #### Parameters

  - ##### __namedParameters: {
    shareId: string;
    sharedBy: string;
    }

    - ##### shareId: string

    - ##### sharedBy: string

  #### Returns Promise<FileSystem>

  Implementation of API.acceptShare

  - Defined in fs/filesystem.ts:588

### add

- add(path: DistinctivePath, content: Uint8Array | SoftLink | Record<string, SoftLink> | SoftLink[], options?: MutationOptions): Promise<FileSystem>

- #### Parameters

  - ##### path: DistinctivePath

  - ##### content: Uint8Array | SoftLink | Record<string, SoftLink> | SoftLink[]

  - ##### options: MutationOptions = {}

  #### Returns Promise<FileSystem>

  Implementation of API.add

  - Defined in fs/filesystem.ts:257

### addPublicExchangeKey

- addPublicExchangeKey(): Promise<void>

- Stores the public part of the exchange key in the DID format, in the `/public/.well-known/exchange/DID_GOES_HERE/` directory.

  #### Returns Promise<void>

  - Defined in fs/filesystem.ts:724

### cat

- cat(path: FilePath): Promise<Uint8Array>

- #### Parameters

  - ##### path: FilePath

  #### Returns Promise<Uint8Array>

  - Defined in fs/filesystem.ts:338

### checkMutationPermissionAndAddProof

- checkMutationPermissionAndAddProof(path: DistinctivePath, isMutation: boolean): Promise<void>
- `Internal`

  #### Parameters

  - ##### path: DistinctivePath

  - ##### isMutation: boolean

  #### Returns Promise<void>

  - Defined in fs/filesystem.ts:749

### deactivate

- deactivate(): void

- Deactivate a file system.

  Use this when a user signs out. The only function of this is to stop listing to online/offline events.

  #### Returns void

  - Defined in fs/filesystem.ts:206

### exists

- exists(path: DistinctivePath): Promise<boolean>

- #### Parameters

  - ##### path: DistinctivePath

  #### Returns Promise<boolean>

  Implementation of API.exists

  - Defined in fs/filesystem.ts:366

### get

- get(path: DistinctivePath): Promise<null | PuttableUnixTree | File>

- #### Parameters

  - ##### path: DistinctivePath

  #### Returns Promise<null | PuttableUnixTree | File>

  Implementation of API.get

  - Defined in fs/filesystem.ts:378

### hasPublicExchangeKey

- hasPublicExchangeKey(): Promise<boolean>

- Checks if the public exchange key was added in the well-known location. See `addPublicExchangeKey()` for the exact details.

  #### Returns Promise<boolean>

  - Defined in fs/filesystem.ts:736

### historyStep

- historyStep(): Promise<void>

- Ensures the current version of your file system is "committed" and stepped forward, so the current version will always be persisted as an "step" in the history of the file system.

  This function is implicitly called every time your file system changes are synced, so in most cases calling this is handled for you.

  #### Returns Promise<void>

  Implementation of API.historyStep

  - Defined in fs/filesystem.ts:571

### loadShare

- loadShare(__namedParameters: {
  shareId: string;
  sharedBy: string;
  }): Promise<UnixTree>

- Loads a share. Returns a "entry index", in other words, a private tree with symlinks (soft links) to the shared items.

  #### Parameters

  - ##### __namedParameters: {
    shareId: string;
    sharedBy: string;
    }

    - ##### shareId: string

    - ##### sharedBy: string

  #### Returns Promise<UnixTree>

  Implementation of API.loadShare

  - Defined in fs/filesystem.ts:602

### ls

- ls(path: DirectoryPath): Promise<Links>

- #### Parameters

  - ##### path: DirectoryPath

  #### Returns Promise<Links>

  Implementation of API.ls

  - Defined in fs/filesystem.ts:216

### mkdir

- mkdir(path: DirectoryPath, options?: MutationOptions): Promise<FileSystem>

- #### Parameters

  - ##### path: DirectoryPath

  - ##### options: MutationOptions = {}

  #### Returns Promise<FileSystem>

  Implementation of API.mkdir

  - Defined in fs/filesystem.ts:232

### mv

- mv(from: DistinctivePath, to: DistinctivePath): Promise<FileSystem>

- #### Parameters

  - ##### from: DistinctivePath

  - ##### to: DistinctivePath

  #### Returns Promise<FileSystem>

  Implementation of API.mv

  - Defined in fs/filesystem.ts:392

### publish

- publish(): Promise<CID<unknown, number, number, Version>>

- Ensures the latest version of the file system is added to IPFS, updates your data root, and returns the root CID.

  #### Returns Promise<CID<unknown, number, number, Version>>

  Implementation of API.publish

  - Defined in fs/filesystem.ts:546

### read

- read(path: FilePath): Promise<null | Uint8Array>

- #### Parameters

  - ##### path: FilePath

  #### Returns Promise<null | Uint8Array>

  Implementation of API.read

  - Defined in fs/filesystem.ts:352

### resolveSymlink

- resolveSymlink(link: SoftLink): Promise<null | File | Tree>

- Resolve a symlink directly. The `get` and `cat` methods will automatically resolve symlinks, but sometimes when working with symlinks directly you might want to use this method instead.

  #### Parameters

  - ##### link: SoftLink

  #### Returns Promise<null | File | Tree>

  Implementation of API.resolveSymlink

  - Defined in fs/filesystem.ts:434

### rm

- rm(path: DistinctivePath): Promise<FileSystem>

- #### Parameters

  - ##### path: DistinctivePath

  #### Returns Promise<FileSystem>

  Implementation of API.rm

  - Defined in fs/filesystem.ts:442

### runMutationOnNode

- runMutationOnNode(path: DistinctivePath, handlers: {
  private(node: PrivateFile | default, relPath: Path): Promise<void>;
  public(root: UnixTree, relPath: Path): Promise<void>;
  }): Promise<void>
- `Internal`

  #### Parameters

  - ##### path: DistinctivePath

  - ##### handlers: {
    private(node: PrivateFile | default, relPath: Path): Promise<void>;
    public(root: UnixTree, relPath: Path): Promise<void>;
    }

    - ##### private:function

      - private(node: PrivateFile | default, relPath: Path): Promise<void>

      - #### Parameters

        - ##### node: PrivateFile | default

        - ##### relPath: Path

        #### Returns Promise<void>

        - Defined in fs/filesystem.ts:768

    - ##### public:function

      - public(root: UnixTree, relPath: Path): Promise<void>

      - #### Parameters

        - ##### root: UnixTree

        - ##### relPath: Path

        #### Returns Promise<void>

        - Defined in fs/filesystem.ts:767

  #### Returns Promise<void>

  - Defined in fs/filesystem.ts:764

### runOnChildTree

- runOnChildTree(node: Tree, relPath: Path, fn: ((tree: Tree) => Promise<Tree>)): Promise<Tree>
- `Internal`

  `put` should be called on the node returned from the function. Normally this is handled by `runOnNode`.

  #### Parameters

  - ##### node: Tree

  - ##### relPath: Path

  - ##### fn: ((tree: Tree) => Promise<Tree>)

    - - (tree: Tree): Promise<Tree>

      - #### Parameters

        - ##### tree: Tree

        #### Returns Promise<Tree>

  - Defined in fs/filesystem.ts:847

### runOnNode

- runOnNode<A>(path: DistinctivePath, handlers: {
  private(node: File | Tree, relPath: Path): Promise<A>;
  public(root: UnixTree, relPath: Path): Promise<A>;
  }): Promise<A>
- `Internal`

  #### Type Parameters

  - #### A

  #### Parameters

  - ##### path: DistinctivePath

  - ##### handlers: {
    private(node: File | Tree, relPath: Path): Promise<A>;
    public(root: UnixTree, relPath: Path): Promise<A>;
    }

    - ##### private:function

      - private(node: File | Tree, relPath: Path): Promise<A>

      - #### Parameters

        - ##### node: File | Tree

        - ##### relPath: Path

        #### Returns Promise<A>

        - Defined in fs/filesystem.ts:813

    - ##### public:function

      - public(root: UnixTree, relPath: Path): Promise<A>

      - #### Parameters

        - ##### root: UnixTree

        - ##### relPath: Path

        #### Returns Promise<A>

        - Defined in fs/filesystem.ts:812

  #### Returns Promise<A>

  - Defined in fs/filesystem.ts:809

### sharePrivate

- sharePrivate(paths: DistinctivePath[], __namedParameters: {
  shareWith: string | string[];
  sharedBy?: SharedBy;
  }): Promise<ShareDetails>

- Share a private file with a user.

  #### Parameters

  - ##### paths: DistinctivePath[]

  - ##### __namedParameters: {
    shareWith: string | string[];
    sharedBy?: SharedBy;
    }

    - ##### shareWith: string | string[]

    - ##### `Optional` sharedBy?: SharedBy

  #### Returns Promise<ShareDetails>

  Implementation of API.sharePrivate

  - Defined in fs/filesystem.ts:670

### symlink

- symlink(args: {
  at: DirectoryPath;
  name: string;
  referringTo: DistinctivePath;
  }): Promise<FileSystem>

- Make an internal symbolic link at a path.

  #### Parameters

  - ##### args: {
    at: DirectoryPath;
    name: string;
    referringTo: DistinctivePath;
    }

    - ##### at: DirectoryPath

    - ##### name: string

    - ##### referringTo: DistinctivePath

  #### Returns Promise<FileSystem>

  Implementation of API.symlink

  - Defined in fs/filesystem.ts:462

### write

- write(path: FilePath, content: Uint8Array, options?: MutationOptions): Promise<FileSystem>

- #### Parameters

  - ##### path: FilePath

  - ##### content: Uint8Array

  - ##### options: MutationOptions = {}

  #### Returns Promise<FileSystem>

  Implementation of API.write

  - Defined in fs/filesystem.ts:357

### `Static` empty

- empty(opts: NewFileSystemOptions): Promise<FileSystem>

- Creates a file system with an empty public tree & an empty private tree at the root.

  #### Parameters

  - ##### opts: NewFileSystemOptions

  #### Returns Promise<FileSystem>

  - Defined in fs/filesystem.ts:159

### `Static` fromCID

- fromCID(cid: CID<unknown, number, number, Version>, opts: FileSystemOptions): Promise<FileSystem>

- Loads an existing file system from a CID.

  #### Parameters

  - ##### cid: CID<unknown, number, number, Version>

  - ##### opts: FileSystemOptions

  #### Returns Promise<FileSystem>

  - Defined in fs/filesystem.ts:183

Generated using TypeDoc