@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
35 lines • 1.79 kB
JavaScript
// ========= Copyright 2026 @ Strukto.AI All Rights Reserved. =========
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ========= Copyright 2026 @ Strukto.AI All Rights Reserved. =========
import { missingOperandError } from "../../../../commands/spec/usage.js";
import { fail, parseLine } from "../shared.js";
import { changeOwner, parseOwner } from "./metadata.js";
// chown OWNER[:GROUP] FILE...: set ownership via setattr. Ownership is
// stored, not enforced (mirage has no user model); names are kept
// verbatim, numeric ids become numbers.
export async function handleChown(namespace, dispatch, session, args) {
const [parsed, fl, refused] = parseLine('chown', args, session.cwd);
if (refused !== null)
return refused;
const ownerText = parsed.texts[0];
if (ownerText === undefined || parsed.paths.length === 0) {
const error = missingOperandError('chown', ownerText ?? null);
return fail('chown', `${error.message}\n`, error.exitCode);
}
const [uid, gid] = parseOwner(ownerText);
if (uid === null && gid === null) {
return fail('chown', `chown: invalid spec: '${ownerText}'\n`, 1);
}
return changeOwner(namespace, dispatch, session, 'chown', fl, parsed.paths, uid, gid);
}
//# sourceMappingURL=chown.js.map