Fichîes Locales

Visão geral

storage.files → LocalFiles

I files di un archivio informatico, let e scrit onde si. Sei metodi, senza chiamata di rete, senza credito — questo è un sistema de files, raggiunse attraverso lo stesso oggetto di ogni altro archivio.

Node onlyno networkfree
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

Nunca se construe uno. È ciò che storage.files retorna a un storage cui type è filesystem, e per alcanzarlo a ningun altro geta anziché retornar una lista vuota — vedi files.

I sei metodi

ChamadaFunçãoRedae
lista(dir, opzions)Lee un dossier.Un arriba de items.
mkdir(dir)Crea un dossier, i genitori incluso.Il item del dossier.
scrivi(file, contenzion)Scrive un file, i genitori incluso.Il item del dossier.
leg(file)Lee un dossier.Il punto, plus content.
mut(de, a)Mutès o renominas.Il item a su novù via.
removi(alvo)Elimina un file, o un dosari e il suo conteniu.{ ok: true }.

Fine a fin

const pc = await api.storage.get();        // the computer this process is on

await pc.files.mkdir("Launch plan");
await pc.files.write("Launch plan/brief.md", "# Brief\n\nShip in March.");

const brief = await pc.files.read("Launch plan/brief.md");
console.log(brief.content);                 // a string: it is text

for (const item of await pc.files.list("Launch plan")) {
  console.log(item.type, item.path, item.size);
}
pc = api.storage.get()        # the computer this process is on

pc.files.mkdir("Launch plan")
pc.files.write("Launch plan/brief.md", "# Brief\n\nShip in March.")

brief = pc.files.read("Launch plan/brief.md")
print(brief["content"])        # a str: it is text

for item in pc.files.list("Launch plan"):
    print(item["type"], item["path"], item["size"])

L'espazion de lavoro

Tutto accade sotto un dosari nel directory home del utente: ~/.iagenify/files. È creat in prima usi, leggibile solo da suo proprietario, e condivisa da ogni applicazione in quella macchina che usa il pacchetto — quindi un file scritto da script è il file che un agent lee.

I percorsi sono relativi al spazio di lavoro, sempre

Non c'è directori corrente a cambiare e non c'è modo di nominare un folder sopra di esso. Un path è una posizion dentro l'espazio di lavoro, che è ciò che rende un path safe da accettare da un model o de un form.

Que un sentiero puè ser

EscritoRisultat
notes.mdIl file in cima del l'espazio de lavoro.
Launch plan/brief.mdNisted. slashs avançàs in ogni sistema.
Launch\\plan/brief.mdLe retroschive sono normalizzate a slashs inavans.
"" (vuoto)L'espazio di lavoro in si. Acceptat da listsolo.
/etc/passwd · C:/WindowsRefusi: invalid_path.
../../secretsRefusi: invalid_path, dopo la risoluzione.

La verifica è fatta sul percorso resoluted, non sul testo: un sentiero che sale e torna è ok, e un sentiero che pare pur inofensiv, ma terras fora è rifiutat.

La forma di ogni metodo restitue

// A file
{
  name: "brief.md",
  path: "Launch plan/brief.md",      // relative to the workspace, forward slashes
  type: "file",
  size: 1284,                         // bytes
  mimeType: "text/markdown",          // from the extension
  modifiedAt: "2026-10-07T09:12:44.000Z"
}

// A folder — size and mimeType are null
{ name: "Launch plan", path: "Launch plan", type: "folder", size: null, mimeType: null, modifiedAt: "…" }
# A file
{
    "name": "brief.md",
    "path": "Launch plan/brief.md",   # relative to the workspace, forward slashes
    "type": "file",
    "size": 1284,                     # bytes
}

# A folder — size is 0
{"name": "Launch plan", "path": "Launch plan", "type": "folder", "size": 0}

Inscripzion nascoste non sono oltra

Qualquer cosa cujo nome compie con un punto è omissido de list(). Issò lo que mantiene i due folders un agente scrie in basil — le versiòn mantenute sotto .versions/ e la cuve de reciclare sotto .trash/ — fora d'un listing, mentre leggati per nome se lo desidera.

// Not in list(), but readable
const previous = await pc.files.list(".versions/notes.md");
const bin = await pc.files.list(".trash");
# Python's list() hides dot folders; read them from the workspace root directly
previous = sorted((pc.files.root / ".versions" / "notes.md").glob("*"))
trash = sorted((pc.files.root / ".trash").glob("*"))

Necessita un disco, e il disco deretto

Due guardis correu prima che un metodo tocchi il sistema de ficheri, e ambos lanceu invec di degradare.

  • local_files_require_node — il tempo di esecuzione non ha sistema de ficheri. Un browser e un operai alcanzò il loro storage di una forma diversa.
  • storage_not_on_this_machine — il storage che detiene appartene a un altro computer, e i suoi files sono nel.
Mantenendo l'oggetto non è tener la máquina

api.storage.list() restituisce ogni computer del conto, compresi quelli a cui non sei seduto. Il secondo guardia è lo che transforma in un rifiuto chiaro in lugar di una lezione del disco sbagliato.

import { IaGenifyError } from "iagenify";

const computers = (await api.storage.list()).filter((s) => s.type === "filesystem");

for (const computer of computers) {
  try {
    await computer.files.list();
  } catch (err) {
    if (err instanceof IaGenifyError && err.code === "storage_not_on_this_machine") {
      console.log(`${computer.label} is elsewhere — skipping.`);
      continue;
    }
    throw err;
  }
}
# A computer that is not this one has files = None in Python
computers = [s for s in api.storage.list() if s.type == "filesystem"]

for computer in computers:
    if computer.files is None:
        print(f"{computer.label} is elsewhere — skipping.")
        continue
    computer.files.list()

Nada lascia la máquina

Nessun metodo qui fa una richiesta. Nada è caricato per essere let, niente è indexat, e nessun credito è spendet. Il conto sa che questo computer è registrato come un storage; non sa ce che è in esso.