[TYPO3-core] RFC: Bug / Feature #5838: Get cli_dispatch.phpsh to work on windows platforms

Christian Trabold christian.trabold at dkd.de
Thu Nov 22 17:04:22 CET 2007


Hi Ingmar,

> this was a long discussion but didn't have a result.
> 
> Can somebody involved please write a final patch?

I can not test Masis code right now, because I don't have a
Windows-Box for *testing* at the moment. :-/


>> This code works on Windows even with relative paths. Note that
>> $_SERVER['PWD'] is used because of getcwd() issues on some *nix systems.

Idea: Would it make sense to get a new method in t3lib_div for this to 
"solve" this *nix-Issues for TYPO3? I mean something like this:

t3lib_div {
   getcwd() {
     return $_SERVER['PWD'] ? $_SERVER['PWD'] : getcwd();
   }
}


So this value could be resolved via calling "t3lib_div::getcwd()".


>> $relativePath = FALSE;
>> if (stristr(PHP_OS,'win')&&!stristr(PHP_OS,'darwin')) {
>>   if (!preg_match('/^([A-Z]:)?\\/', $temp_PATH_thisScript)) {
>>     $relativePath = TRUE;
>>   }
>> } else {
>>   if ($temp_PATH_thisScript{0} != '/') {
>>     $relativePath = TRUE;
>>   }
>> }
>>
>> if ($relativePath) {
>>   $wd = $_SERVER['PWD'] ? $_SERVER['PWD'] : getcwd();
>>   if ($wd) {
>>     $temp_PATH_thisScript =
>>       $wd.'/'.ereg_replace('\.\/','',$temp_PATH_thisScript);
>>     if (!@is_file($temp_PATH_thisScript)) {
>>       die ('relative path found and an error occured during resolving of
>> the absolute path. $temp_PATH_thisScript');
>>     }
>>   } else {
>>     die ('relative path found, but resolving absolute path is not
>> supported on this platform.');
>>   }
>> }
>> define('PATH_thisScript',$temp_PATH_thisScript);
>>
>> Masi
>>
>> PS: It's not that complicated ;-)

Well, it's not complicated but blows up the code quite a bit.

Is this really necessary?


Questions I ask myself right now:

- Could this code be reused in other contexts?

- Would it make sense to encapsulate this into a function?

- @if (!preg_match('/^([A-Z]:)?\\/', $temp_PATH_thisScript)) {

Is it possible to use existing functions for this? Like:

   t3lib_div::isAbsPath($path)



Greetings

Christian


More information about the TYPO3-team-core mailing list