Re: [Haskell-cafe] Filesystem access
Hello Andrew, Friday, June 22, 2007, 12:19:51 AM, you wrote: 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! std library doesn't contain such function, although it is easily modeled after getModificationTime. note that on windows this will return only lower 32 bits of file size due to using lstat() internally another way around this is to look at getFileAttributes implementation and build the same wrapper around win32 getfilesize function -- Best regards, Bulatmailto:[EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Filesystem access
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! 2. Is there any way to discover Windoze-style attributes for files? (Read-only, archive, system, hidden, et al.) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Filesystem access
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 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. all the best andrea ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Filesystem access
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 Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Filesystem access
On Thu, Jun 21, 2007 at 09:38:49PM +0100, Andrew Coppin wrote: Andrea Rossato wrote: On Thu, Jun 21, 2007 at 09:19:51PM +0100, Andrew Coppin wrote: 2. Is there any way to discover Windoze-style attributes for files? The module before, if I understand correctlu. No, AFAIK the archive attribute doesn't even exist on POSIX. It's a Windoze-specific thang. is Windoze-style Windows or something that is not windows, such as POSIX? I did not understand correctly, but you were far from being clear. Which is the first step to get hep, btw. sorry for you problems. don't do windows, me. andrea ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Filesystem access
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* :: Stringhttp://www.haskell.org/ghc/docs/latest/html/libraries/base/Data-Char.html#t%3AString- IOhttp://www.haskell.org/ghc/docs/latest/html/libraries/base/System-IO.html#t%3AIO FileAttributeOrFlaghttp://www.haskell.org/ghc/docs/latest/html/libraries/Win32/System-Win32-File.html#t%3AFileAttributeOrFlag *getFileInformationByHandle* :: HANDLEhttp://www.haskell.org/ghc/docs/latest/html/libraries/Win32/System-Win32-Types.html#t%3AHANDLE- IOhttp://www.haskell.org/ghc/docs/latest/html/libraries/base/System-IO.html#t%3AIO BY_HANDLE_FILE_INFORMATIONhttp://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 Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Filesystem access
On 6/21/07, Andrew Coppin [EMAIL PROTECTED] 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! I think you must open file in Windows to get the size for it, but I am not 100% sure. (That might be the reason you see sometimes files that are just created with size 0 even as process writes to them - file is locked.) 2. Is there any way to discover Windoze-style attributes for files? (Read-only, archive, system, hidden, et al.) Fraser posted some functions to help with this. However, those attributes are mostly outdated unless you are workin on old Windows. For real file rights, more in line with traditional unix right would be file ACLs. (There's useful flags there, too.) Unfortunately Security api isn't in Win32 package. Best regards, Esa ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe