I don't use Haskell on Windows, but if you go to

http://www.haskell.org/ghc/docs/latest/html/libraries/index.html

you'll find a package called System.Win32.File, which has these functions:

*getFileAttributes* ::
String<http://www.haskell.org/ghc/docs/latest/html/libraries/base/Data-Char.html#t%3AString>->
IO<http://www.haskell.org/ghc/docs/latest/html/libraries/base/System-IO.html#t%3AIO>
FileAttributeOrFlag<http://www.haskell.org/ghc/docs/latest/html/libraries/Win32/System-Win32-File.html#t%3AFileAttributeOrFlag>

*getFileInformationByHandle* ::
HANDLE<http://www.haskell.org/ghc/docs/latest/html/libraries/Win32/System-Win32-Types.html#t%3AHANDLE>->
IO<http://www.haskell.org/ghc/docs/latest/html/libraries/base/System-IO.html#t%3AIO>
BY_HANDLE_FILE_INFORMATION<http://www.haskell.org/ghc/docs/latest/html/libraries/Win32/System-Win32-File.html#t%3ABY_HANDLE_FILE_INFORMATION>

The first has all sorts of attributes in it, the second has a field for
length.  Maybe these will do what you want.

cheers,
Fraser.

On 6/21/07, Andrew Coppin <[EMAIL PROTECTED]> wrote:

Andrea Rossato wrote:
> On Thu, Jun 21, 2007 at 09:19:51PM +0100, Andrew Coppin wrote:
>
>>  OK, a few questions...
>>
>>  1. Is there *any* way to determine how large a file is *without*
opening it?
>>  The only library function I can find to do with file sizes is
hFileSize;
>>  obviously this only works for files that you have permission to open!
>>
>
> System.Posix.Files
> fileSize
>

Does that *work* on Windoze?

Wait, hang on a sec... No, it doesn't. The module doesn't even exist.

(I was half-expecting it might work. GHC does currently run in a Unix
emulator...)

>>  2. Is there any way to discover Windoze-style "attributes" for files?
>>  (Read-only, archive, system, hidden, et al.)
>>
>
> The module before, if I understand correctlu.
>

No, AFAIK the archive attribute doesn't even exist on POSIX. It's a
Windoze-specific thang.

_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to