* 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
* Re: Win32 filetype problem
2001-09-14 16:19 Win32 filetype problem Beard, Frank
@ 2001-09-14 18:34 ` martin.m.dowie
2001-09-15 9:16 ` Pascal Obry
0 siblings, 1 reply; 7+ messages in thread
From: martin.m.dowie @ 2001-09-14 18:34 UTC (permalink / raw)
"Beard, Frank" <beardf@spawar.navy.mil> wrote in message
news:mailman.1000484414.2704.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.
comes to the same thing doesn't it?
anyway, thanks for the tip - I assume this is the one in adapower?..
^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <B6A1A9B09E52D31183ED00A0C9E0888C469C65@nctswashxchg.nctswash.navy.mil>]
* Re: Win32 filetype problem
[not found] <B6A1A9B09E52D31183ED00A0C9E0888C469C65@nctswashxchg.nctswash.navy.mil>
@ 2001-09-16 4:11 ` David Botton
2001-09-16 7:44 ` Pascal Obry
0 siblings, 1 reply; 7+ messages in thread
From: David Botton @ 2001-09-16 4:11 UTC (permalink / raw)
To: comp.lang.ada
> Even if you don't use the POSIX binding directly, it's a good
> source for seeing how to use the Window's API.
I would also suggest looking at the body of GWindows packages
(http://www.adapower.com/gwindows) for an alternative style to using the
Win32 bindings. It is easier to roll your own and take advantage of Ada's
superior ability to interface with C over a raw translated binding. Although
GWindows does not include support for most file related functions since GNAT
has very good packages for handling that already:
I _HIGHLY_ recommend looking at
GNAT.OS_Lib (take a look at
/GNAT/lib/gcc-lib/pentium-mingw32msv/2.8.1/adainclude/g-os_lib.ads)
and
GNAT.Directory_Operations
(/GNAT/lib/gcc-lib/pentium-mingw32msv/2.8.1/adainclude/g-dirope.ads)
I highly recommend spending time looking through the directory above at all
the g-* files for a lot of "goodies". Also, look at
http://www.adapower.com/lang there is a section of examples on using some of
the GNAT packages there.
David Botton
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Win32 filetype problem
2001-09-16 4:11 ` David Botton
@ 2001-09-16 7:44 ` Pascal Obry
0 siblings, 0 replies; 7+ messages in thread
From: Pascal Obry @ 2001-09-16 7:44 UTC (permalink / raw)
"David Botton" <David@Botton.com> writes:
> I highly recommend spending time looking through the directory above at all
> the g-* files for a lot of "goodies". Also, look at
And all of them are described in the GNAT Reference Manual.
Pascal.
--
--|------------------------------------------------------
--| Pascal Obry Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--| http://perso.wanadoo.fr/pascal.obry
--|
--| "The best way to travel is by means of imagination"
^ permalink raw reply [flat|nested] 7+ messages in thread
* 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 9:57 Martin Dowie
@ 2001-09-14 10:17 ` Martin Dowie
0 siblings, 0 replies; 7+ messages in thread
From: Martin Dowie @ 2001-09-14 10:17 UTC (permalink / raw)
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!
^ permalink raw reply [flat|nested] 7+ messages in thread
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 16:19 Win32 filetype problem 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
-- strict thread matches above, loose matches on Subject: below --
2001-09-14 9:57 Martin Dowie
2001-09-14 10:17 ` Martin Dowie
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox