2025-10-17 19:19:40 +00:00
|
|
|
// Copyright 2025, Command Line Inc.
|
|
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
|
2025-02-19 00:25:03 +00:00
|
|
|
export const PlatformMacOS = "darwin";
|
2025-10-17 19:19:40 +00:00
|
|
|
export const PlatformWindows = "win32";
|
2025-02-19 00:25:03 +00:00
|
|
|
export let PLATFORM: NodeJS.Platform = PlatformMacOS;
|
|
|
|
|
|
|
|
|
|
export function setPlatform(platform: NodeJS.Platform) {
|
|
|
|
|
PLATFORM = platform;
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-09 23:29:09 +00:00
|
|
|
export function isMacOS(): boolean {
|
|
|
|
|
return PLATFORM == PlatformMacOS;
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-17 19:19:40 +00:00
|
|
|
export function isWindows(): boolean {
|
|
|
|
|
return PLATFORM == PlatformWindows;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-19 00:25:03 +00:00
|
|
|
export function makeNativeLabel(isDirectory: boolean) {
|
|
|
|
|
let managerName: string;
|
|
|
|
|
if (!isDirectory) {
|
|
|
|
|
managerName = "Default Application";
|
|
|
|
|
} else if (PLATFORM === PlatformMacOS) {
|
|
|
|
|
managerName = "Finder";
|
2025-10-17 19:19:40 +00:00
|
|
|
} else if (PLATFORM == PlatformWindows) {
|
2025-02-19 00:25:03 +00:00
|
|
|
managerName = "Explorer";
|
|
|
|
|
} else {
|
|
|
|
|
managerName = "File Manager";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let fileAction: string;
|
|
|
|
|
if (isDirectory) {
|
|
|
|
|
fileAction = "Reveal";
|
|
|
|
|
} else {
|
|
|
|
|
fileAction = "Open File";
|
|
|
|
|
}
|
|
|
|
|
return `${fileAction} in ${managerName}`;
|
|
|
|
|
}
|