Re: [PHP] Dos Paths

2002-07-10 Thread Chris Earle

By Winblows does that mean you think Windows blows or that you guys don't
have a compiler for Windows?

Borland gives out a free C++ compiler for Win...

If you're running Linux, then get gcc/g++, it's free.

"Bb" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> It doesn't matter how fast it does it.  It matters what language it does
it.
> C and C++ are a big no no as our company doesn't have a compiler
(winblows).
>
> Thanks for the pointer
>
> "David Otton" <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > On Wed, 10 Jul 2002 13:14:44 +0100, you wrote:
> >
> > >I've got an application that requires dos folder names (8.3 standard)
as
> > >input.
> > >
> > >I also have PHP, which quite happily can cope with both.
> > >
> > >Can someone help me write a function to translate full paths to dos
paths
> >
> > You may have to drop down to C/C++ and ask the OS to lookup the short
> > version of the path for you (GetShortPathName and GetShortPathNameW).
> > But if you want to do it "by hand", Knowledge Base article Q142982
> > might be a place to start.
> >
>
>



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




Re: [PHP] Dos Paths

2002-07-10 Thread Neil Freeman

FYI - Works in Windows NT 4 SP 6a as well.

[EMAIL PROTECTED] wrote:
> **
> This Message Was Virus Checked With : SAVI 3.59 May 2002 
> Last Updated 8th July 2002
> **
> 
> Hi all,
> 
> It's actually rather easy.
> 
>  $str_test = passthru("dir /x c:\\myfolder\\");
> 
>>?
> 
> 
> After this it's just a matter of parsing the dirlist and extracting the
> right string...
> 
> Regards
> Joakim Andersson
> 
> PS. dir /x works in Windows 2000, not sure about the others... DS.
> 
> 
> 
>>-Original Message-
>>From: BB [mailto:[EMAIL PROTECTED]]
>>Sent: Wednesday, July 10, 2002 2:15 PM
>>To: [EMAIL PROTECTED]
>>Subject: [PHP] Dos Paths
>>
>>
>>I've got an application that requires dos folder names (8.3 
>>standard) as
>>input.
>>
>>I also have PHP, which quite happily can cope with both.
>>
>>Can someone help me write a function to translate full paths 
>>to dos paths
>>
>>Thanks
>>
>>
>>
>>-- 
>>PHP General Mailing List (http://www.php.net/)
>>To unsubscribe, visit: http://www.php.net/unsub.php
>>
> 
> 


-- 

Work: [EMAIL PROTECTED]
Home: [EMAIL PROTECTED]

Web:  www.curvedvision.com



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




Re: [PHP] Dos Paths

2002-07-10 Thread Shane Wright

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi 

I have a problem that's somewhat related to this - I can get short filenames 
from the OS but I really need long filenames.  Does anyone know how to do 
this?

Thanks

Shane


On Wednesday 10 July 2002 1:14 pm, BB wrote:
> I've got an application that requires dos folder names (8.3 standard) as
> input.
>
> I also have PHP, which quite happily can cope with both.
>
> Can someone help me write a function to translate full paths to dos paths
>
> Thanks

- -- 
Shane
http://www.shanewright.co.uk/
Public key: http://www.shanewright.co.uk/files/public_key.asc
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE9LEBu5DXg6dCMBrQRAk7bAKCS10F8NjFrStSaha0Dkno0uwGE0QCgjdFi
gNzKf3kaWjP5h2rWtImS6Xw=
=I22O
-END PGP SIGNATURE-


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




RE: [PHP] Dos Paths

2002-07-10 Thread joakim . andersson

Hi all,

It's actually rather easy.

?

After this it's just a matter of parsing the dirlist and extracting the
right string...

Regards
Joakim Andersson

PS. dir /x works in Windows 2000, not sure about the others... DS.


> -Original Message-
> From: BB [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, July 10, 2002 2:15 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Dos Paths
> 
> 
> I've got an application that requires dos folder names (8.3 
> standard) as
> input.
> 
> I also have PHP, which quite happily can cope with both.
> 
> Can someone help me write a function to translate full paths 
> to dos paths
> 
> Thanks
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

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




Re: [PHP] Dos Paths

2002-07-10 Thread Danny Shepherd

Ah, that'll teach me to actually read the post next time, not just the code
:)

Danny.


- Original Message -
From: "Michael Sims" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, July 10, 2002 2:02 PM
Subject: Re: [PHP] Dos Paths


On Wed, 10 Jul 2002 13:56:39 +0100, you wrote:

Yeah, I mentioned that in my original post (see below).  I left that
particular issue as an exercise for the reader. :-)

>- Original Message -
>From: "Michael Sims" <[EMAIL PROTECTED]>
>To: <[EMAIL PROTECTED]>
>Sent: Wednesday, July 10, 2002 1:48 PM
>Subject: Re: [PHP] Dos Paths
[...]
>One last thing.  You can't really create a function like this without
>accessing the filesystem that these files are going to be stored on.
>For example, let's say you have a file called "my resume.doc"  The DOS
>equivalent to this would be "myresu~1.doc" UNLESS there was already
>another file in the same directory that had that DOS name.  So, let's
>say there was already another file by the name of "my results.doc" in
>the directory.  Then your "my resume.doc" would be called
>"myresu~2.doc"  The function below does not account for this.
[...]


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




Re: [PHP] Dos Paths

2002-07-10 Thread Chris Hewitt

I don't know of a conversion routine that will do exactly what DOS does, 
but if you need to use 8.3 filenames and receive them as vfat32 
filenames then you could do a conversion yourself before using the name. 
As long as the conversion is 8.3 compliant it does not matter that your 
conversion routine ends up with a different name.

Having converted it, then use the name and you write out the 8.3 
filename, never the long one. Note the translation between the two in an 
array or db table.

HTH
Chris

BB wrote:

>I've got an application that requires dos folder names (8.3 standard) as
>input.
>
>I also have PHP, which quite happily can cope with both.
>
>Can someone help me write a function to translate full paths to dos paths
>
>Thanks
>
>
>



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




Re: [PHP] Dos Paths

2002-07-10 Thread Michael Sims

On Wed, 10 Jul 2002 13:56:39 +0100, you wrote:

>The problem with this method is assuming the ~1 part. What if I have:
>
>'My Directory'-> MYDIRE~1
>'My DirectoryForPics'  -> MYDIRE~2
>
>Now if your path has 'My DirectoryForPics' it's going to translate that into
>MYDIRE~1 which won't work.
>
>HTH
>
>Danny.

Yeah, I mentioned that in my original post (see below).  I left that
particular issue as an exercise for the reader. :-)

>- Original Message -
>From: "Michael Sims" <[EMAIL PROTECTED]>
>To: <[EMAIL PROTECTED]>
>Sent: Wednesday, July 10, 2002 1:48 PM
>Subject: Re: [PHP] Dos Paths
[...]
>One last thing.  You can't really create a function like this without
>accessing the filesystem that these files are going to be stored on.
>For example, let's say you have a file called "my resume.doc"  The DOS
>equivalent to this would be "myresu~1.doc" UNLESS there was already
>another file in the same directory that had that DOS name.  So, let's
>say there was already another file by the name of "my results.doc" in
>the directory.  Then your "my resume.doc" would be called
>"myresu~2.doc"  The function below does not account for this.
[...]

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




Re: [PHP] Dos Paths

2002-07-10 Thread David Otton

On Wed, 10 Jul 2002 13:35:50 +0100, you wrote:

>"David Otton" <[EMAIL PROTECTED]> wrote in message
>[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
>> On Wed, 10 Jul 2002 13:14:44 +0100, you wrote:
>>
>> >I've got an application that requires dos folder names (8.3 standard) as
>> >input.
>> >
>> >I also have PHP, which quite happily can cope with both.
>> >
>> >Can someone help me write a function to translate full paths to dos paths

>> You may have to drop down to C/C++ and ask the OS to lookup the short
>> version of the path for you (GetShortPathName and GetShortPathNameW).
>> But if you want to do it "by hand", Knowledge Base article Q142982
>> might be a place to start.

>It doesn't matter how fast it does it.  It matters what language it does it.

It's nothing to do with speed... Windows uses (used?) a hack to
introduce long filename support while not breaking 8.3 filenames, and
it stores both on the disc. If you had three files named :

LongFilenameA.dat
LongFilenameB.dat
LongFilenameC.dat

they would be converted to

LongFi~1.dat
LongFi~2.dat
LongFi~3.dat

but you can't guarantee which long name maps to which short name. You
really have to ask the OS to do the lookup for you if you want correct
results.

AFAIK your choices to get at Windows stuff from PHP are the COM
functions, or writing a new function for PHP itself and recompiling.
(Someone'll be along in a minute to correct me if I'm wrong).

>C and C++ are a big no no as our company doesn't have a compiler (winblows).

*boggle*

Different worlds :)

Hmm. How about Java? The API there might be rich enough to do what you
want.

>Thanks for the pointer

Good luck.


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




Re: [PHP] Dos Paths

2002-07-10 Thread Danny Shepherd

The problem with this method is assuming the ~1 part. What if I have:

'My Directory'-> MYDIRE~1
'My DirectoryForPics'  -> MYDIRE~2

Now if your path has 'My DirectoryForPics' it's going to translate that into
MYDIRE~1 which won't work.

HTH

Danny.


- Original Message -
From: "Michael Sims" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, July 10, 2002 1:48 PM
Subject: Re: [PHP] Dos Paths


On Wed, 10 Jul 2002 13:14:44 +0100, you wrote:

>I've got an application that requires dos folder names (8.3 standard) as
>input.
>
>I also have PHP, which quite happily can cope with both.
>
>Can someone help me write a function to translate full paths to dos paths
>
>Thanks

Maybe this can get you started.  I don't have access to a PHP parser
right now so this is completely off the top of my head, but maybe it
will help a  bit.

The function below assumes that the path contains backslashes (not
forward slashes).  It also does not verify that the path is legal in
the first place (i.e. that it doesn't contain illegal characters).
Additionally, it doesn't deal with filenames, just directory names.
Maybe you can extend to handle filenames. :)

One last thing.  You can't really create a function like this without
accessing the filesystem that these files are going to be stored on.
For example, let's say you have a file called "my resume.doc"  The DOS
equivalent to this would be "myresu~1.doc" UNLESS there was already
another file in the same directory that had that DOS name.  So, let's
say there was already another file by the name of "my results.doc" in
the directory.  Then your "my resume.doc" would be called
"myresu~2.doc"  The function below does not account for this.

Come to think of it, maybe this isn't all that helpful. :-P

function fullpath2dospath ($fullpath) {

  if(preg_match("/^([A-Za-z]:)(.*)$/",$fullpath)) {
$driveletter = $matches[1];
$fullpath = $matches[2];
  }

  $dirs = explode("\",$fullpath);

  foreach($dirs as $index => $dir) {

/*
Directory only needs to be modified if it
contains spaces or is longer than 8
characters
*/
if(strlen($dir) > 8 || strpos($dir," ")) {
  $dir = strtr($dir," ","");
  $dir = substr($dir,0,6);
  $dirs[$index] = $dir."~1";
}
  }

  $dospath = $driveletter.implode("\",$dirs);
  return $dospath;

}

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



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




Re: [PHP] Dos Paths

2002-07-10 Thread Michael Sims

On Wed, 10 Jul 2002 13:14:44 +0100, you wrote:

>I've got an application that requires dos folder names (8.3 standard) as
>input.
>
>I also have PHP, which quite happily can cope with both.
>
>Can someone help me write a function to translate full paths to dos paths

Also, go to groups.google.com and plug "convert long 8.3 filenames"
into the search box.  Most of the discussions involve VB, VBScript,
Perl, etc. but maybe they can give you some ideas.

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




Re: [PHP] Dos Paths

2002-07-10 Thread Michael Sims

On Wed, 10 Jul 2002 13:14:44 +0100, you wrote:

>I've got an application that requires dos folder names (8.3 standard) as
>input.
>
>I also have PHP, which quite happily can cope with both.
>
>Can someone help me write a function to translate full paths to dos paths
>
>Thanks

Maybe this can get you started.  I don't have access to a PHP parser
right now so this is completely off the top of my head, but maybe it
will help a  bit.

The function below assumes that the path contains backslashes (not
forward slashes).  It also does not verify that the path is legal in
the first place (i.e. that it doesn't contain illegal characters).
Additionally, it doesn't deal with filenames, just directory names.
Maybe you can extend to handle filenames. :)

One last thing.  You can't really create a function like this without
accessing the filesystem that these files are going to be stored on.
For example, let's say you have a file called "my resume.doc"  The DOS
equivalent to this would be "myresu~1.doc" UNLESS there was already
another file in the same directory that had that DOS name.  So, let's
say there was already another file by the name of "my results.doc" in
the directory.  Then your "my resume.doc" would be called
"myresu~2.doc"  The function below does not account for this.

Come to think of it, maybe this isn't all that helpful. :-P

function fullpath2dospath ($fullpath) {

  if(preg_match("/^([A-Za-z]:)(.*)$/",$fullpath)) {
$driveletter = $matches[1];
$fullpath = $matches[2];
  }

  $dirs = explode("\",$fullpath);

  foreach($dirs as $index => $dir) {  

/* 
Directory only needs to be modified if it
contains spaces or is longer than 8
characters
*/
if(strlen($dir) > 8 || strpos($dir," ")) {
  $dir = strtr($dir," ","");
  $dir = substr($dir,0,6);
  $dirs[$index] = $dir."~1";
}
  }

  $dospath = $driveletter.implode("\",$dirs);
  return $dospath;

}

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




Re: [PHP] Dos Paths

2002-07-10 Thread BB

It doesn't matter how fast it does it.  It matters what language it does it.
C and C++ are a big no no as our company doesn't have a compiler (winblows).

Thanks for the pointer

"David Otton" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> On Wed, 10 Jul 2002 13:14:44 +0100, you wrote:
>
> >I've got an application that requires dos folder names (8.3 standard) as
> >input.
> >
> >I also have PHP, which quite happily can cope with both.
> >
> >Can someone help me write a function to translate full paths to dos paths
>
> You may have to drop down to C/C++ and ask the OS to lookup the short
> version of the path for you (GetShortPathName and GetShortPathNameW).
> But if you want to do it "by hand", Knowledge Base article Q142982
> might be a place to start.
>



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




Re: [PHP] Dos Paths

2002-07-10 Thread David Otton

On Wed, 10 Jul 2002 13:14:44 +0100, you wrote:

>I've got an application that requires dos folder names (8.3 standard) as
>input.
>
>I also have PHP, which quite happily can cope with both.
>
>Can someone help me write a function to translate full paths to dos paths

You may have to drop down to C/C++ and ask the OS to lookup the short
version of the path for you (GetShortPathName and GetShortPathNameW).
But if you want to do it "by hand", Knowledge Base article Q142982
might be a place to start.


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




[PHP] Dos Paths

2002-07-10 Thread BB

I've got an application that requires dos folder names (8.3 standard) as
input.

I also have PHP, which quite happily can cope with both.

Can someone help me write a function to translate full paths to dos paths

Thanks



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