Handling Linux directory paths in Win32

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I'm trying to get a site written for a linux server running
on my windows PC to do some development work on it. One of
the problems I've encountered is some hard coded directory
paths like '/var/vhost/sitename/',
'/var/vhost/sitename/Modules/', '/var/vhost/sitename/Pics'
etc...

My idea for dealing with this is to set a basedir var and
then build up the relative paths like so:
$BaseDir = '/var/vhost/sitename/';
$ModuleDir = $BaseDir . 'Modules/';
$PicsDir = $BaseDir . 'Pics/';
So for a windows server I could just change $BaseDir to
'D:\www\site\'

But what I'm concerned about is that php on windows does
not seem to be able to handle '/' in a path like Apache
1.3.* for windows can. Is there any workarounds for this
other than some sort of macro like function to convert the
'/' to a '\' on windows based PCs? 

Is there any way to do something like the C/C++
preprocessor definitions & switches to only run code when
something is defined:
#define WIN32 // only if on windows platform?
// set base dir to windows path
#ifdef WIN32
$BaseDir = 'd:\www\site\'
#endif
// convert '/' to '\'
#ifdef WIN32
$ModuleDir = 'Modules\';
#endif

etc...

As that would mean the macro code would not slow the linux
machine down at all when running the php script if it did
not even have to evaluate to see if it did need to run the
macro function, although I know php is a scripted language
and not compiled like C/C++ so I don't think its possible
but I thought I'd ask just in case!

I suppose if there was a way to detect the server platform
type then you could switch on that too, so you only convert
the '/' on a windows platform and not *nix.

cheers,

Daniel

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux