MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / getDesktopPath

Function getDesktopPath

source code/utils/file.ts:482–539  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

480}
481
482export function getDesktopPath(): string {
483 const platform = getPlatform()
484 const homeDir = homedir()
485
486 if (platform === 'macos') {
487 return join(homeDir, 'Desktop')
488 }
489
490 if (platform === 'windows') {
491 // For WSL, try to access Windows desktop
492 const windowsHome = process.env.USERPROFILE
493 ? process.env.USERPROFILE.replace(/\\/g, '/')
494 : null
495
496 if (windowsHome) {
497 const wslPath = windowsHome.replace(/^[A-Z]:/, '')
498 const desktopPath = `/mnt/c${wslPath}/Desktop`
499
500 if (getFsImplementation().existsSync(desktopPath)) {
501 return desktopPath
502 }
503 }
504
505 // Fallback: try to find desktop in typical Windows user location
506 try {
507 const usersDir = '/mnt/c/Users'
508 const userDirs = getFsImplementation().readdirSync(usersDir)
509
510 for (const user of userDirs) {
511 if (
512 user.name === 'Public' ||
513 user.name === 'Default' ||
514 user.name === 'Default User' ||
515 user.name === 'All Users'
516 ) {
517 continue
518 }
519
520 const potentialDesktopPath = join(usersDir, user.name, 'Desktop')
521
522 if (getFsImplementation().existsSync(potentialDesktopPath)) {
523 return potentialDesktopPath
524 }
525 }
526 } catch (error) {
527 logError(error)
528 }
529 }
530
531 // Linux/unknown platform fallback
532 const desktopPath = join(homeDir, 'Desktop')
533 if (getFsImplementation().existsSync(desktopPath)) {
534 return desktopPath
535 }
536
537 // If Desktop folder doesn't exist, fallback to home directory
538 return homeDir
539}

Callers 1

performHeapDumpFunction · 0.85

Calls 3

getPlatformFunction · 0.85
getFsImplementationFunction · 0.85
logErrorFunction · 0.70

Tested by

no test coverage detected