MCPcopy Index your code
hub / github.com/codeaashu/claude-code / getDesktopPath

Function getDesktopPath

src/utils/file.ts:480–537  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers 1

performHeapDumpFunction · 0.85

Calls 3

getPlatformFunction · 0.85
getFsImplementationFunction · 0.85
logErrorFunction · 0.70

Tested by

no test coverage detected