BP7 / Long Filenames LFN 
Author Message
 BP7 / Long Filenames LFN

Hi NG!

I'm using BP7 and have to open and read a file.
The filename is given via cmdline to my programm.
The given file has a long filename!

Only I need is a routine which converts a long filename
to a short one. I tried <lfn110.zip> to convert long to
short, but this unit does not work under NT4.

Who can help me with my problem?

Thanks to all users
Joerg



Mon, 25 Aug 2003 00:26:45 GMT  
 BP7 / Long Filenames LFN

Quote:
> Only I need is a routine which converts a long filename
> to a short one. I tried <lfn110.zip> to convert long to
> short, but this unit does not work under NT4.

> Who can help me with my problem?

Nobody can help you under NT because the useless NT4 DOS box does not provide
the LFN API.

--
Jay

Jason Burgon - Author of Graphic Vision
New version 2.12 now available from:
http://www.jayman.demon.co.uk



Mon, 25 Aug 2003 01:28:28 GMT  
 BP7 / Long Filenames LFN

Quote:



>> Only I need is a routine which converts a long filename
>> to a short one. I tried <lfn110.zip> to convert long to
>> short, but this unit does not work under NT4.

>> Who can help me with my problem?

>Nobody can help you under NT because the useless NT4 DOS box does not provide
>the LFN API.

There seem to be dirty tricks to access the windows api from a dosprogram.

A different workaround was to make a small Win32 program (Delphi 2.0+ console
mode, or Free Pascal/Win32) and call it.

I don't know if you can edit a parents environment from a win32 program, but
otherwise, try piping or as last resort writing to file.

The FPC (www.freepascal.org) program would look something like this:

Uses Dos;

VAR S : String;

begin
 If ParamCount >0 THEN
  begin
   S:=ParamStr(1);
   IF GenShortName(S) Then {Returns true on success}
    Writeln(S);
  end;
end.

The Delphi program would be similar, except the function is called
ExtractShortParhName, returns a string (instead of having a VAR parameter)
, and is in sysutils.



Mon, 25 Aug 2003 06:04:04 GMT  
 BP7 / Long Filenames LFN
Marco van de Voort schrieb:

Quote:





> >> Only I need is a routine which converts a long filename
> >> to a short one. I tried <lfn110.zip> to convert long to
> >> short, but this unit does not work under NT4.

> >> Who can help me with my problem?

> >Nobody can help you under NT because the useless NT4 DOS box does not provide
> >the LFN API.

> There seem to be dirty tricks to access the windows api from a dosprogram.

> A different workaround was to make a small Win32 program (Delphi 2.0+ console
> mode, or Free Pascal/Win32) and call it.

> I don't know if you can edit a parents environment from a win32 program, but
> otherwise, try piping or as last resort writing to file.

> The FPC (www.freepascal.org) program would look something like this:

> Uses Dos;

> VAR S : String;

> begin
>  If ParamCount >0 THEN
>   begin
>    S:=ParamStr(1);
>    IF GenShortName(S) Then {Returns true on success}
>     Writeln(S);
>   end;
> end.

> The Delphi program would be similar, except the function is called
> ExtractShortParhName, returns a string (instead of having a VAR parameter)
> , and is in sysutils.

Hi Jason and Marco, thanks for your fast answers!

I did not explain jet, that my program is not a DOS-program but a
W31/W95-Program, running under NT4.

I am thinking about a DLL-call or so, which will solve my problem.

Joerg



Mon, 25 Aug 2003 14:42:32 GMT  
 BP7 / Long Filenames LFN

Quote:

>Marco van de Voort schrieb:

>Hi Jason and Marco, thanks for your fast answers!

>I did not explain jet, that my program is not a DOS-program but a
>W31/W95-Program, running under NT4.

If you are using BP, it is w31, but it might run under W95 too :-)

Quote:
>I am thinking about a DLL-call or so, which will solve my problem.

I never did 16-bits windows programming. but the call you want is in
kernel32.dll , and the name is GetShortPathNameA


Mon, 25 Aug 2003 19:44:20 GMT  
 BP7 / Long Filenames LFN

Quote:

>If you are using BP, it is w31, but it might run under W95 too :-)

>>I am thinking about a DLL-call or so, which will solve my problem.

>I never did 16-bits windows programming. but the call you want is in
>kernel32.dll , and the name is GetShortPathNameA

Whoops, forgot to mention the problem; This DLL is 32-bit, and I don't if it
is possible to call it from a 16-bits windows program.
Probably not direct, but maybe there is a workaround, but as I said, I never
did any 16-bits windows programming.


Mon, 25 Aug 2003 19:48:26 GMT  
 BP7 / Long Filenames LFN
On Wed, 07 Mar 2001 17:26:45 +0100, =?iso-8859-1?Q?J=F6rg?= Lindemeier

Quote:

>Hi NG!

>I'm using BP7 and have to open and read a file.
>The filename is given via cmdline to my programm.
>The given file has a long filename!

>Only I need is a routine which converts a long filename
>to a short one. I tried <lfn110.zip> to convert long to
>short, but this unit does not work under NT4.

>Who can help me with my problem?

http://www.*-*-*.com/ ~african_chief/tpw32_20.zip

Best regards, The Chief
-----------------------
Prof. A{*filter*}la Olowofoyeku (The African Chief)
(Author of Chief's Installer Pro for Win32)

  Web: http://www.*-*-*.com/ ~african_chief/



Wed, 03 Sep 2003 00:44:47 GMT  
 BP7 / Long Filenames LFN

Quote:
> I'm using BP7 and have to open and read a file.
> The filename is given via cmdline to my programm.
> The given file has a long filename!

> Only I need is a routine which converts a long filename
> to a short one. I tried <lfn110.zip> to convert long to
> short, but this unit does not work under NT4.

--

Steve



Wed, 03 Sep 2003 17:04:19 GMT  
 BP7 / Long Filenames LFN

Quote:
> I'm using BP7 and have to open and read a file.
> The filename is given via cmdline to my programm.
> The given file has a long filename!

> Only I need is a routine which converts a long filename
> to a short one. I tried <lfn110.zip> to convert long to
> short, but this unit does not work under NT4.

    I found a unit called LFNUnit.pas by Eyal Doron that was written for
TP 6.0 and TPW 1.5 (I am using it with BP 7.01).  The other ones I tried
returned garbage filenames under Windows NT/2000.  This one returns the
Windows-generated short names, but it doesn't get garbage.  In DOS
(under Win98) it works fine, after I fixed it to better handle relative
paths (with ".."s).

http://www.prog.cz/rozdel.shtml?http://www.prog.cz/prog/swag/swag/files/
0107.htm

My fix is in the LFNFExpand function (my section starts with {BEGIN
ADDITION}, the rest is his):

function LFNFExpand(Path: string): string;
{ Drop-in replacement for the TP6 FExpand, which supports LFN. }
{ Personally, I prefer it to the later FileExpand.             }
var
  D,N,E,P: PString;
  i,j,ndots: integer;
begin
  for i:=1 to length(Path) do if Path[i]='/' then Path[i]:='\';
  LFNFExpand:='';
  GetMem(P,270);
{$IFDEF WINDOWS}
  FileExpand(PChar(P)+1,'.'); P^[0]:=chr(StrLen(PChar(P)+1));
{$ELSE}
  P^:=FExpand('.');
{$ENDIF}
  if (P^<>'') and (P^[length(P^)]<>'\') then P^:=P^+'\';
  P^:=LFNLongName(P^);
  ndots:=0;
  while (ndots<length(Path)) and (Path[Ndots+1]='.') do inc(ndots);
  {BEGIN ADDITION}
  i := pos('..',Path);                      { find '..\' }
  while i > 0 do
    begin
      j := i-2;
      while ((j > 1) and (Path[j]<>'\')) do { find the preceding '\' }
        dec(j);
      Delete (Path, j, i+2-j);              { remove preceding dir and
dots }
      i := pos('..',Path);                  { search again }
    end;
  {END ADDITION}
  if (length(Path)>1) and (UpCase(Path[1]) in ['A'..'Z']) and
(Path[2]=':') then
    P^:=Path         { Fully qualified }
  else if Path[1]='\' then        { Only drive missing }
    P^:=Copy(P^,1,2)+Path
  else begin
    for i:=1 to ndots-1 do    { relative filenames, multiple dots }
    begin
      if length(P^)>3 then
      begin
        j:=length(P^)-1;
        while (j>3) and (P^[j]<>'\') do dec(j);
        P^[0]:=Chr(j);
      end;
      delete(Path,1,1);
    end;
    if Pos('.\',Path)=1 then Delete(Path,1,2)
    else if Pos('.',Path)=1 then Delete(Path,1,1);
    P^:=P^+Path;
  end;
  LFNFExpand:=P^;
  FreeMem(P,270);
end;                     { LFNFExpand }

--

Steve



Wed, 03 Sep 2003 17:17:29 GMT  
 BP7 / Long Filenames LFN

Quote:
>     I found a unit called LFNUnit.pas by Eyal Doron that was written
for
> TP 6.0 and TPW 1.5 (I am using it with BP 7.01).

    I forgot to mention that in DOS, you should remember that a list of
long file names takes up quite a bit more memory, at 256 chars/file
rather than 12...

--

Steve



Wed, 03 Sep 2003 17:27:11 GMT  
 BP7 / Long Filenames LFN

Quote:



>> I'm using BP7 and have to open and read a file.
>> The filename is given via cmdline to my programm.
>> The given file has a long filename!

>> Only I need is a routine which converts a long filename
>> to a short one. I tried <lfn110.zip> to convert long to
>> short, but this unit does not work under NT4.

>    I found a unit called LFNUnit.pas by Eyal Doron that was written for
>TP 6.0 and TPW 1.5 (I am using it with BP 7.01).  The other ones I tried
>returned garbage filenames under Windows NT/2000.  

It should work in 2000!??!


Wed, 03 Sep 2003 20:35:36 GMT  
 BP7 / Long Filenames LFN


Quote:
> It should work in 2000!??!

    Are you saying the LFNUnit should?  Well, it doesn't seem to unless
I'm missing something.  The same .EXE works fine under Windows 98SE.

    I have discovered some other oddities, however, and may have to give
up on it too.  In DOS mode (FAT32 drive) it breaks down.  I've tracked
it to the asm code in the routine to get the file times (returns a
DosError, which causes FindFirst to fail), but not being
assembly-literate that's as far as I got.  :(  Also in protected mode it
doesn't return the file times under Windows 2000.  Sigh...why couldn't
Microsoft stick with OS/2?  :)

Steve



Thu, 04 Sep 2003 05:23:22 GMT  
 BP7 / Long Filenames LFN

Quote:



>> It should work in 2000!??!

>    Are you saying the LFNUnit should?  Well, it doesn't seem to unless
>I'm missing something.  The same .EXE works fine under Windows 98SE.

I don't know lfnunit, but LFN INT calls under Dos in general. There are a
few deviations though.

Quote:
>    I have discovered some other oddities, however, and may have to give
>up on it too.  In DOS mode (FAT32 drive) it breaks down.  I've tracked
>it to the asm code in the routine to get the file times (returns a
>DosError, which causes FindFirst to fail), but not being
>assembly-literate that's as far as I got.

It could be that some FExpand is used somewhere internally, and that that
calls DiskSize.(or -free). Those are broken for large volumes, and need to
be updated too.
(
Sometimes in RTLs (I don't know how much lfnunit replaces), disksize is used
to check drive letter existance
)

Quote:
> :(  Also in protected mode it
>doesn't return the file times under Windows 2000.  Sigh...why couldn't
>Microsoft stick with OS/2?  :)

Could you mail me the example testing program? I'll try to test it with
FPC's routines under Win2000 this week.

If it works there, you'll know it is possible, and even try to adapt the FPC
routines. If an independant implementation has the same problems, it
probably will be Win2000



Thu, 04 Sep 2003 06:43:16 GMT  
 BP7 / Long Filenames LFN

Quote:


> > I'm using BP7 and have to open and read a file.
> > The filename is given via cmdline to my programm.
> > The given file has a long filename!

> > Only I need is a routine which converts a long filename
> > to a short one. I tried <lfn110.zip> to convert long to
> > short, but this unit does not work under NT4.

>     I found a unit called LFNUnit.pas by Eyal Doron that was written for
> TP 6.0 and TPW 1.5 (I am using it with BP 7.01).  The other ones I tried
> returned garbage filenames under Windows NT/2000.

You didn't try my GDos unit then. GDos does not return garbage under NT4. It
doesn't return long names either, but that's because the NT4/2000 DOS emulator
does not provide the int21 LFN  API, so nothing will get you long names under
NT/2000 except a replacement for its (deliberately) totally {*filter*}DOS emulator.

--
Jay

Jason Burgon - Author of "Graphic Vision"  GUI for DOS/DPMI
=== Free LFN capable Dos/WinDos replacement and ===
=== New Graphic Vision  version 2.12 available from:  ===
http://www.*-*-*.com/



Wed, 03 Sep 2003 19:27:01 GMT  
 BP7 / Long Filenames LFN


Quote:


>> I'm using BP7 and have to open and read a file.
>> The filename is given via cmdline to my programm.
>> The given file has a long filename!

>> Only I need is a routine which converts a long filename
>> to a short one. I tried <lfn110.zip> to convert long to
>> short, but this unit does not work under NT4.

>    I found a unit called LFNUnit.pas by Eyal Doron that was written for
>TP 6.0 and TPW 1.5 (I am using it with BP 7.01).  The other ones I tried
>returned garbage filenames under Windows NT/2000.  

My TPW32 package does not. It uses Windows APIs and works
the same under W9x as under NT/W2K. Check it - the full source
code is there, and it is absolutely free.

Best regards, The Chief
-----------------------
Prof. A{*filter*}la Olowofoyeku (The African Chief)
(Author of Chief's Installer Pro for Win32)

  Web: http://www.*-*-*.com/ ~african_chief/



Mon, 08 Sep 2003 01:05:32 GMT  
 
 [ 16 post ]  Go to page: [1] [2]

 Relevant Pages 

1. Release LFN v1.10 - Long filename unit for Win9x and TP6 up to BP7

2. Release LFN v1.10 - Long filename unit for Win9x and TP6 up to BP7

3. Release LFN v1.09 - Long filename unit for Win9x and TP6 up to BP7

4. Release LFN v1.09 - Long filename unit for Win9x and TP6 up to BP7

5. Release LFN v1.08 - Long filename unit for Win9x and TP6 up to BP7

6. Release LFN v1.08 - Long filename unit for Win9x and TP6 up to BP7

7. Another problem with long filenames (LFN)

8. reading FAT32 (for Long Filenames [LFN])

9. Long Filenames (LFN) under Windows NT using Borland Pascal

10. Unit LFN for easy Long Filename Support

11. Long Filenames (LFN) in Native DOS

12. long filenames under BP7.0 ?

 

 
Powered by phpBB® Forum Software