RunMat
GitHub

fullfile — Build a platform-correct file path from multiple path segments.

fullfile joins path segments using the platform-specific file separator, producing a single path string that matches MATLAB semantics. It accepts any number of path segments and returns a character row vector (1xN).

How fullfile works in RunMat

  • fullfile(part1, part2, ...) joins the inputs with the platform file separator (/ on macOS and Linux, \ on Windows).
  • Absolute path segments reset the accumulated path, mirroring MATLAB and OS path rules.
  • Empty segments are ignored, so fullfile("", "data") returns data.
  • Inputs must be character vectors or string scalars. Single-element string arrays are accepted. Other input types raise fullfile: arguments must be character vectors or string scalars.
  • The output is a character vector. Wrap the result with string(...) if you prefer string scalars.

How fullfile runs on the GPU

fullfile performs string manipulation on the CPU only. Any GPU-resident inputs are gathered to the host before path assembly so the resulting character vector is always in CPU memory.

GPU memory and residency

No. fullfile is a host-side path builder. GPU-resident text inputs are gathered automatically, so there is no benefit to keeping path strings on the GPU.

Examples

Join Relative Path Segments

p = fullfile("data", "raw", "sample.dat")

Expected output:

p =
    data/raw/sample.dat

Use fullfile With pwd

root = pwd;
config = fullfile(root, "config", "settings.json")

Expected output:

% Returns a full path rooted at the current working folder

Build A Subfolder Path

logDir = fullfile("logs", "2026");
status = mkdir(logDir)

Expected output:

status =
     1

Create A File In A Nested Folder

mkdir(fullfile("data", "raw"));
fid = fopen(fullfile("data", "raw", "sample.dat"), "w");
fclose(fid)

Expected output:

% Creates data/raw/sample.dat

FAQ

Why does fullfile return a character vector instead of a string?

MATLAB returns character vectors for fullfile. RunMat mirrors that behavior for compatibility; use string(fullfile(...)) if you prefer string scalars.

Does fullfile expand ~ to the home directory?

No. fullfile performs string assembly only. Use cd or filesystem APIs that expand ~ when you need home expansion.

What happens if a segment is absolute?

Absolute segments reset the accumulated path, matching MATLAB and OS path rules.

Can I pass numeric character codes?

Yes. Numeric arrays that represent character codes are accepted as long as they form a row vector, just like other RunMat text inputs.

Does fullfile run on the GPU?

No. It is a host-only utility and gathers GPU-resident inputs before processing.

These functions work well alongside fullfile. Each page has runnable examples you can try in the browser.

mkdir, pwd, tempdir, dir, addpath, cd, copyfile, delete, exist, genpath, getenv, ls, movefile, path, rmdir, rmpath, savepath, setenv, tempname

Open-source implementation

Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how fullfile works, line by line, in Rust.

About RunMat

RunMat is an open-source runtime that executes MATLAB-syntax code — faster, on any GPU, with no license required.

  • Simulations that took hours now take minutes. RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed.
  • Start running code in seconds. Open the browser sandbox or download a single binary. No license server, no IT ticket, no setup.
  • A full development environment. GPU-accelerated 2D and 3D plotting, automatic versioning on every save, and a browser IDE you can share with a link.

Getting started · Benchmarks · Pricing

Try RunMat — free, no sign-up

Start running MATLAB code immediately in your browser.