[Haskell-cafe] Filesystem questions

Brandon S. Allbery KF8NH allbery at ece.cmu.edu
Fri Oct 12 13:39:38 EDT 2007


All these questions are actually Windows-centric; the answers are  
different on Unix.

On Oct 12, 2007, at 13:21 , Andrew Coppin wrote:

> I notice that getDirectoryContents appears to return its results in  
> alphabetical order. Is this behaviour actually guaranteed?

There is no guarantee, however on Windows this is done by invoking  
Win32 directory globbing routines which happen to return things in  
alpha order.  (On Unix it might be alpha order if the underlying  
filesystem is a btree, but there are no guarantees at all except  
perhaps that '.' and '..' come first.)

> Related: Is there a way to get rid of "." and ".." in the results?  
> (Obviously this causes directory recusion to malfunction.) I can of  
> course manually filter them out, but it's annoying.

Manual filtering is always required, whether C, Perl, Haskell, etc.   
I dunno, maybe python filters them for you or something.  Every  
language I've ever used makes you deal.

>  doesDirectoryExist "C:"
>  doesDirectoryExist "C:\"
>
> both yield False? (This frequently trips up programs that try to  
> check that a destination folder exists.)

Ask Microsoft.  Drive top level handling has been weird since MS-DOS  
2.0.

-- 
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery at kf8nh.com
system administrator [openafs,heimdal,too many hats] allbery at ece.cmu.edu
electrical and computer engineering, carnegie mellon university    KF8NH




More information about the Haskell-Cafe mailing list