@@ -27,7 +27,7 @@ protected function getInstallPath()
2727 $ currentUser = $ this ->system ->getCurrentUser ();
2828
2929 if ('Administrator ' === $ currentUser ) {
30- return ' C:\ProgramData \jupyter-php ' ;
30+ return $ this -> getProgramDataPath () . ' \jupyter-php ' ;
3131 } else {
3232 return $ this ->system ->getCurrentUserHome () . '\.jupyter-php ' ;
3333 }
@@ -48,8 +48,8 @@ protected function installKernel()
4848 $ currentUser = $ this ->system ->getCurrentUser ();
4949
5050 $ kernelSpecPath = ('Administrator ' === $ currentUser ) ?
51- ' C:\ProgramData \jupyter\kernels\jupyter-php ' :
52- $ this ->system -> getCurrentUserHome () . '\AppData\Roaming \jupyter\kernels\jupyter-php ' ;
51+ $ this -> getProgramDataPath () . ' \jupyter\kernels\jupyter-php ' :
52+ $ this ->getAppDataPath () . '\jupyter\kernels\jupyter-php ' ;
5353
5454 $ this ->system ->ensurePath ($ kernelSpecPath );
5555 file_put_contents ($ kernelSpecPath . '\kernel.json ' , $ kernelDef );
@@ -73,4 +73,22 @@ protected function executeSilentComposerCommand($installPath)
7373
7474 return $ composerStatus ;
7575 }
76+
77+ private function getProgramDataPath ()
78+ {
79+ if (function_exists ('getenv ' ) && false !== getenv ('PROGRAMDATA ' )) {
80+ return getenv ('PROGRAMDATA ' );
81+ } else {
82+ throw new \RuntimeException ('Unable to obtain the program data directory. ' );
83+ }
84+ }
85+
86+ private function getAppDataPath ()
87+ {
88+ if (function_exists ('getenv ' ) && false !== getenv ('APPDATA ' )) {
89+ return getenv ('APPDATA ' );
90+ } else {
91+ throw new \RuntimeException ('Unable to obtain the app data directory. ' );
92+ }
93+ }
7694}
0 commit comments