MCPcopy Create free account
hub / github.com/TechJeeper/Printventory / createHiddenWindow

Function createHiddenWindow

main.js:472–501  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

470// Helper function to register IPC handlers and add them to the registry
471function registerIpcHandler(channel, handler) {
472 ipcMain.handle(channel, handler);
473}
474
475// UNC Path Validation Functions
476function isUncPath(path) {
477 if (!path || typeof path !== 'string') {
478 return false;
479 }
480 // UNC paths on Windows start with \\
481 // They cannot be local drive paths (C:\, D:\, etc.)
482 return path.startsWith('\\\\') && !/^[A-Za-z]:/.test(path);
483}
484
485// Check if running in Docker container
486function isDockerContainer() {
487 // Check for Docker environment indicators
488 const hasDockerenv = fs.existsSync('/.dockerenv');
489 const hasCgroup = fs.existsSync('/proc/self/cgroup');
490 const cgroupContainsDocker = hasCgroup && fs.readFileSync('/proc/self/cgroup', 'utf8').includes('docker');
491 const result = hasDockerenv || cgroupContainsDocker;
492 return result;
493}
494
495function validateUncPath(path, operation = 'operation') {
496 if (isUrlModel(path)) {
497 return; // URL-only models (from extension) have no file path to validate
498 }
499 if (isServerMode) {
500 // In Docker, allow Linux-style absolute paths (mounted shares)
501 if (isDockerContainer()) {
502 // Allow absolute paths starting with / (Linux-style)
503 if (!path.startsWith('/') && !isUncPath(path)) {
504 throw new Error(`Server mode in Docker requires absolute paths (e.g., /mnt/network-share/path/to/file.stl) or UNC paths. The path "${path}" is not valid.`);

Callers 1

main.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected