14 lines
1.3 KiB
JavaScript
14 lines
1.3 KiB
JavaScript
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
import { execFileSync } from 'node:child_process';
|
|
const root = path.resolve('.qa/model-entry-k-longpath'), source = path.join(root, 'source'); fs.mkdirSync(source, { recursive: true });
|
|
const folder = path.join(source, 'owned-long-path-segment'.repeat(5), 'owned-evidence-segment'.repeat(5)); fs.mkdirSync(folder, { recursive: true });
|
|
const file = path.join(folder, 'owned.txt'); fs.writeFileSync(file, 'owned-long-path-archive\n');
|
|
const destination = path.join(root, 'probe.zip'), extended = value => '\\\\?\\' + value;
|
|
const quote = value => "'" + value.replaceAll("'", "''") + "'";
|
|
const command = "$ErrorActionPreference='Stop'; Add-Type -AssemblyName System.IO.Compression.FileSystem; [IO.Compression.ZipFile]::CreateFromDirectory(" + quote(extended(source)) + ', ' + quote(extended(destination)) + ', [IO.Compression.CompressionLevel]::Optimal, $true)';
|
|
try {
|
|
execFileSync('powershell.exe', ['-NoProfile','-NonInteractive','-Command', command], { windowsHide: true, stdio: 'pipe' });
|
|
console.log(JSON.stringify({ success: true, fileCharacters: file.length, bytes: fs.statSync(destination).size }));
|
|
} catch (error) { console.log(JSON.stringify({ success: false, fileCharacters: file.length, error: error.stderr?.toString() || error.message })); process.exitCode = 1; }
|