comp.lang.ada
 help / color / mirror / Atom feed
* Win32 filetype problem
@ 2001-09-14  9:57 Martin Dowie
  2001-09-14 10:17 ` Martin Dowie
  0 siblings, 1 reply; 7+ messages in thread
From: Martin Dowie @ 2001-09-14  9:57 UTC (permalink / raw)


System: WIntel NT, GNAT 3.13p

I don't seem to be able to determine if a filename (specified in
an Ada string) is a directory or not using the Win32 bindings in
GNAT.

I've been through the help file but there is nothing that answer
what is happening.

Here's a code snip of what I have:

declare
   function To_LPCSTR is
      new Ada.Unchecked_Conversion (Source => System.Address,
                                    Target => Win32.LPCSTR);
   C_Filename : Chars_Ptr := New_String (Trimmed_Filename);
   Result : Win32.DWORD;
begin
   Result := Win32.Winbase.GetFileAttributesA (lpFileName => To_LPCSTR (S =>
C_Filename'Address));
   Ada.Text_IO.Put_Line ("oops? " & Boolean'Image (Result =
6#FFFF_FFFF#));  -- always displays "oops? TRUE"
   return Result /= 16#FFFF_FFFF# and then
          (Result and Win32.WinNT.FILE_ATTRIBUTE_DIRECTORY) =
Win32.WinNT.FILE_ATTRIBUTE_DIRECTORY;
end;

--
Kernighan and Ritchie : "C was designed on the assumption
                         that the programmer is someone
                         sensible who knows what he's
                         doing"
Ada Reference Manual : "Ada was designed with the
                        concern of programming as a
                        human activity"







^ permalink raw reply	[flat|nested] 7+ messages in thread
* RE: Win32 filetype problem
@ 2001-09-14 16:19 Beard, Frank
  2001-09-14 18:34 ` martin.m.dowie
  0 siblings, 1 reply; 7+ messages in thread
From: Beard, Frank @ 2001-09-14 16:19 UTC (permalink / raw)
  To: 'comp.lang.ada@ada.eu.org'

The return statement should probably be:

   return Result /= 16#FFFF_FFFF# and then
          (Result and Win32.WinNT.FILE_ATTRIBUTE_DIRECTORY) /= 0;

Get Pascal Obry's POSIX binding, which is a wrapper around the
Win32 APIs, off of AdaPower and look at POSIX_Files.Is_File and
POSIX_Files.Is_Directory.

Even if you don't use the POSIX binding directly, it's a good
source for seeing how to use the Window's API.

Frank

-----Original Message-----
From: Martin Dowie [mailto:martin.dowie@nospam.baesystems.com]
Sent: Friday, September 14, 2001 6:18 AM
To: comp.lang.ada@ada.eu.org
Subject: Re: Win32 filetype problem


Martin Dowie <martin.dowie@nospam.baesystems.com> wrote in message
news:3ba1d1b9$1@pull.gecm.com...
> System: WIntel NT, GNAT 3.13p
[snip]
> declare
>    function To_LPCSTR is
>       new Ada.Unchecked_Conversion (Source => System.Address,
                                                ^^^^^^^^^^^^^^

I'm an idiot, this should be Chars_Ptr...

>                                     Target => Win32.LPCSTR);
>    C_Filename : Chars_Ptr := New_String (Trimmed_Filename);
>    Result : Win32.DWORD;
> begin
>   Result := Win32.Winbase.GetFileAttributesA (lpFileName => To_LPCSTR (S
=>
>      C_Filename'Address));
                 ^^^^^^^^
...and then remove this!





_______________________________________________
comp.lang.ada mailing list
comp.lang.ada@ada.eu.org
http://ada.eu.org/mailman/listinfo/comp.lang.ada



^ permalink raw reply	[flat|nested] 7+ messages in thread
[parent not found: <B6A1A9B09E52D31183ED00A0C9E0888C469C65@nctswashxchg.nctswash.navy.mil>]

end of thread, other threads:[~2001-09-16  7:44 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-09-14  9:57 Win32 filetype problem Martin Dowie
2001-09-14 10:17 ` Martin Dowie
  -- strict thread matches above, loose matches on Subject: below --
2001-09-14 16:19 Beard, Frank
2001-09-14 18:34 ` martin.m.dowie
2001-09-15  9:16   ` Pascal Obry
     [not found] <B6A1A9B09E52D31183ED00A0C9E0888C469C65@nctswashxchg.nctswash.navy.mil>
2001-09-16  4:11 ` David Botton
2001-09-16  7:44   ` Pascal Obry

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox