The updates don't help any. The question I asked in my original post remains. How can you tell where a file name ends? What you ask is not possible, unless you impose extra restrictions. Let's say the file contains the line:
C:\Program Files\Application Name\bin\app.exe > C:\Program Files\Appli +cation Name\log\app.log do_it 2> C:\Program Files\Foo Bar\log\app.log
Should the above return:
C:\Progra~1\Applic~1\bin\app.exe > C:\Progra~1\Applic~1\log\applog~1 2 +> C:\Progra~1\FooBar~1\log\app.log
Probably not. You probably wanted:
C:\Progra~1\Applic~1\bin\app.exe > C:\Progra~1\Applic~1\log\app.log do +_it 2> C:\Progra~1\FooBar~1\log\app.log
ok, so you might say you'll never place arguments between redirects (although it would be a exception to what you said you allow). What if the file contained the line:
C:\Program Files\Application Name\bin\app.exe ola c:\file1 ole c:\file +2
Should the above return:
C:\Progra~1\Applic~1\bin\appexe~1 c:\file1o~1 c:\file2
or
C:\Progra~1\Applic~1\bin\app.exe ola c:\file1o~1 c:\file2
or
C:\Progra~1\Applic~1\bin\app.exe ola c:\file1 ole c:\file2
Probably not the first, but there's no way to know between the bottom two. It depends on what app.exe expects.
That's why I recommended you quote your paths:
sub quote { local $_=$_[0]; s/(["\\])/\\$1/g; qq{"$_"} } sub unquote { local $_=$_[0]; s/^"(.*)"$/$1/ or return $_; s/\\(.)/$1/ +g; $_ } while (<IN>) { @items = /("(?:[^"\\]|\\.)+"|[^"\s]+)/g; foreach (@items) { $_ = unquote($_); print(Win32::GetShortPathName($_) || quote($_), ' '); } print("\n"); }
But that's not all! What the file doesn't exist? It's impossible to get the short file name of a file that doesn't yet exist!
In reply to Re: Parsing a list or Win32 filenames
by ikegami
in thread Parsing a list or Win32 filenames
by astroboy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |