Table of Contents

File Explorer Source Code

Where the File Explorer is built: its components, the REST routes it calls and the server code behind them. What the page shows and how it behaves is File Explorer Page.

Source Code Path

See HiNC App Anatomy for git repository links.

HiNC-2025-webservice (Quasar CLI SPA):

  • wwwroot-src/src/components/FileExplorer.vue — the browser itself: toolbar, sort control, breadcrumb + filter, the lazy tree with its hover actions, the editor slave panel with Auto Save, the STL preview slot, and the view prefs.
  • wwwroot-src/src/pages/FileExplorerPage.vue — routed page at /util/file-explorer; mirrors the selection and the panel's file in the URL and reads them back, gives the tree's rows their link addresses, and guards the route leave.
  • wwwroot-src/src/components/widgets/FileExplorerDialog.vue — modal wrapper: apply bar, save mode, "{rootName}:{relativePath}" picks.
  • wwwroot-src/src/components/explorerSort.ts — sort keys, comparators, DEFAULT_SORT and coerceSortSpec behind the Sort dropdown.
  • wwwroot-src/src/components/widgets/fileFilter.ts — the FileFilter shape driving the file-type select.
  • wwwroot-src/src/utils/collapsibleSplit.ts — collapses the editor divider while the panel is hidden.
  • wwwroot-src/src/components/StlPreviewPane.vue — the 3D preview that takes over the panel for .stl files, over Disp/StlPreviewController.cs.
  • wwwroot-src/src/components/CsvStripPane.vue — the CSV strip viewer that takes over the panel for .csv files: the bar with its Series / X / Y / Lines dropdowns, Save and mode select, the band chart over the embedded text, the sidecar config, and the banner of a refused Save, a line it names numbered as the gutter numbers it after Save.
  • wwwroot-src/src/components/PagedTextViewer.vue — the read-only paged viewer for files over the editor cap, and the strip viewer's editable text half (cells, row insert / delete, the pending-edit overlay).
  • wwwroot-src/src/utils/lineOverlay.ts — the replaced / deleted / inserted-line overlay the text half keeps until Save.
  • wwwroot-src/src/utils/csvLine.ts — splits a CSV line into cells for the text half.
  • wwwroot-src/src/api/csvStrip.ts — typed wrapper over /api/csv-strip/*.
  • wwwroot-src/src/components/widgets/TextEditor.vue — CodeMirror 6 wrapper; line wrapping for Markdown, and the scroll API Split mode follows.
  • wwwroot-src/src/components/widgets/TextEditorPane.vue — the editor panel's body: the editor for every language, the Markdown viewer beside or instead of it, Split's scroll sync and divider.
  • wwwroot-src/src/components/markdown/markdownRender.ts, MarkdownViewer.vue, markdown.scss, markdownView.ts — the Markdown renderer and sanitizer, the drawn page, its styles, and the mode types the page and the explorer share.
  • wwwroot-src/src/utils/mermaidRuntime.ts — the one mermaid render queue; every caller's configuration is re-applied before its render.
  • wwwroot-src/src/components/widgets/editorLanguage.ts — extension → EditorLanguage mapping.
  • wwwroot-src/src/components/widgets/missionScriptLanguage.ts — the in-repo mission-script mode.
  • wwwroot-src/src/api/fileExplorer.ts — typed wrapper over /api/file-explorer/*, and projectRootQuery, the ifProjectDirectory every by-root call of the src/api modules adds under the Project root: the folder of the project path the store holds as the request is built.
  • wwwroot-src/src/api/namedRoots.ts — ROOT_TITLE_KEYS, each root's name onto its title's bundle key; shared by FileExplorer.vue‘s rootTitle and the coded refusals’ args.root.
  • wwwroot-src/src/api/http.ts — API_ERROR_KEYS, the File Explorer codes onto their apiErrors.fileExplorer* keys and ProjectDirectoryMoved onto apiErrors.projectDirectoryMoved; EN_FROM_BUNDLE, which renders their English from the bundle too; onProjectDirectoryMoved, which has the project store read the status on that refusal.
  • wwwroot-src/src/i18n/en/explorer.ts, and the same file of the other four locales — explorer.roots.*, the three roots' titles on screen.
  • wwwroot-src/src/i18n/en/apiErrors.ts, and the same file of the other four locales — the fileExplorer* sentences the refusal banner shows.
  • wwwroot-src/src/router/routes.ts — /util/file-explorer entry (route name util-file-explorer).
  • wwwroot-src/src/components/AppMenuBar.vue — the File Explorer page switch, the fourth, after the three workflow pages; lit on the bare route and on every deep path.
  • .ai/file-explorer-root-titles-e2e.mjs — the browser acceptance of the root titles: in each of the five languages the selector, its items, the breadcrumb, the tree's top row and the editor's path label read the bundles' titles, while the page's URL, a deep link and the row links keep the English displayName; a language switch retitles them in place.
  • .ai/file-explorer-refusals-i18n-e2e.mjs — the acceptance of the page's own coded refusals (ProjectDirectoryMoved's is .ai/project-root-precondition-e2e.mjs, on File Explorer Refusals): over the API, every site's status, code, args, English and scrub, and the refusals left plain; in the browser, in each of the five languages, the banner reading the bundle's sentence; the CSV strip routes and pane, and the STL preview's show, whose checks skip on a host with no usable OpenGL; and, in its section F, the second batch: over the API, a read-only CSV, a line in Big5, a CSV another program holds open, one under an ACL denying writes and a folder that denies creating the temp file, saved through write-lines and write-text; names with ?, *, <, >, |, ", :, a Tab and leading separators; a path on a drive the host does not have; in the browser, in Traditional Chinese and in English, the banner of a new folder named a?b and of the strip viewer's Save of a read-only CSV, of a Big5 line with a row inserted above it (the line as the gutter numbers it) and of a CSV held open.
  • Common/NamedRootResolver.cs — resolves AdminDirectory / ProjectDirectory / ResourceDir, and holds the Project root to the folder a request states (ifProjectDirectory, answered with ProjectRootMoved, HTTP 412); IsUnderRoot, which also refuses a path into a git directory (NamesGitDirectory, HasGitDirectoryName, IsGitDirectoryName); shared with every other controller that reads or writes under a named root.
  • Common/FileRefusals.cs — the coded refusal bodies of this page's three controllers, and the plain one, every message and path argument scrubbed.
  • Common/TextLineIndexService.cs — the background line index behind read-lines: one checkpoint per 64 KiB, extended as the file grows and rebuilt under a new generation when it is rewritten.
  • Common/TextLinePatch.cs — the line patch behind write-lines: the oldText / length checks, then the write — in place when it only replaces lines and each keeps its byte count, otherwise through a temp file and a replace; LinePatchRefusal marks the refusals a user meets, which write-lines answers with a code.
  • Common/CsvStripController.cs — REST endpoints under /api/csv-strip, over Common/CsvStripService.cs (the background parse cache and the bucketing) and Common/CsvStrip.cs (the CSV reader and schema sampling):
Method Path Notes
GET /schema?rootName=&relativePath=&headerLine=&skipLines= Delimiter, the columns with a kind sampled from the first 64 data rows, the suggested x column, and the file's first lines for the header / skip pickers.
GET /strip?…&xColumn=&xFormat=&columns=&begin=&end=&buckets= Min/max buckets of up to 32 columns over the data-row window [begin, end) (end=-1 for every row parsed so far), about 800 buckets by default. The first call starts a background parse; the answer covers the rows parsed so far, and complete says when to stop polling.
GET /locate?…&line= or &row= Maps a physical line to its data row, or a row to its line — the chart ↔ text link. 404 when the file has no data row.
GET /config?rootName=&relativePath= Reads the sidecar <name>.csv.strip.json, kept by the server as opaque JSON.
PUT /config Writes the sidecar as indented JSON beside the CSV, which must exist.
DELETE /config?… Removes the sidecar; succeeds when there is none.
  • Common/FileExplorerController.cs — REST endpoints under /api/file-explorer:
Method Path Notes
GET /roots List available roots; Project is omitted when no project is loaded. Returns each root's name and English displayName only, never a path.
GET /list?rootName=&relativePath= Directories-first, name-ascending listing; the client re-sorts it per the toolbar's sort control.
GET /read-text?… UTF-8 text; when the file is detected as binary returns content=null, isBinary=true. A text file over 128 MiB returns content=null, tooLarge=true, length (its size in bytes) and maxLength (the cap).
GET /read-lines?rootName=&relativePath=&offset=&count= A page of lines from a text file of any size: count lines from the 0-based offset, default 256 and at most 1000 (0 only reports the index state). A line over 16 KiB is served cut to that length and listed in clipped with its omittedBytes. lineCount covers only the bytes indexed so far and grows on later calls; a greater generation means the index was rebuilt and earlier pages are stale.
POST /write-text Body {rootName, relativePath, content}; creates parents as needed. 400 with a code when the file is read-only, the write is denied or another program holds the file, as /write-lines answers for the same file; 412 when the Project root names another folder than ifProjectDirectory (below).
POST /write-lines Body {rootName, relativePath, expectedLength, edits, deletes, inserts} — lines replaced (line, text, oldText), removed (line, oldText) and inserted after a line (after, texts, oldText; -1 for the start of the file), every number naming the file as it is on disk before the write. 409 when the file's length is no longer expectedLength, or a line no longer reads as its oldText; 400 with a code when the file is a link or read-only, a replaced line is not UTF-8, or the write is denied or another program holds the file; 412, before the file is read, when the Project root names another folder than ifProjectDirectory (below); untouched bytes are copied as they are. Answers length, edited, deleted, inserted and inPlace.
POST /create-file Fails if target exists.
POST /create-directory Recursive create; no-op if already a directory.
POST /rename Body {rootName, relativePath, newRelativePath}; refuses cross-root moves.
POST /copy {name}-Copy-00..-Copy-19; uses Hi.Common.FileLines.FileUtil.CopyDirectory for directories.
DELETE /delete?… Files → delete, directories → recursive; refuses to delete the root itself.
GET /download?… Streams a file as application/octet-stream.
GET /download-zip?… Zips a directory in-memory and streams application/zip. An empty file that is not a link is entered without being opened; anything named .git, and what lies in a git directory, is left out.
POST /upload?rootName=&relativePath= Multipart single-file upload in the form field file; creates missing parent folders and overwrites the target.
POST /extract-zip Body {rootName, relativePath}; extracts next to the archive into <name>/. Extracts nothing when <name>/ would be a git directory, or an entry of the archive is named .git or lies in a git directory (File Explorer Page); the archive is opened once, so the entries checked are the ones extracted.

Every route of the two tables but /roots takes one more query parameter, whatever its verb and whether or not it has a body: ifProjectDirectory, optional, the folder the client takes the Project root to name, looked at only under ProjectDirectory. A request whose Project root names another folder is answered 412 ProjectDirectoryMoved before anything is read or written, unless a check of the request itself answers first (a missing body or file name, locate's line and row); one without the parameter is served as the root resolves when it arrives. The value and its comparison are on Holding a Request to the Open Project.

A root, a path, a name or a file these routes and the CSV strip routes refuse is answered with a coded body: the codes, their statuses, args and routes are on File Explorer Refusals.

See Also