From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id MAA19421; Wed, 6 Aug 2003 12:02:28 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id MAA18869 for ; Wed, 6 Aug 2003 12:02:27 +0200 (MET DST) Received: from aomori.annexia.org (annexia.force9.co.uk [212.56.101.183]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h76A2Qf21097 for ; Wed, 6 Aug 2003 12:02:26 +0200 (MET DST) Received: from rich by aomori.annexia.org with local (Exim 3.36 #1 (Debian)) id 19kL7i-0007Ds-00 for ; Wed, 06 Aug 2003 11:02:26 +0100 Date: Wed, 6 Aug 2003 11:02:25 +0100 To: caml-list@inria.fr Subject: [Caml-list] Unix.stat sometimes fails on Win32 port Message-ID: <20030806100225.GA27730@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.4i From: Richard Jones X-Loop: caml-list@inria.fr X-Spam: no; 0.00; lablgtk:01 errno:01 syscall:01 operand:01 printf:01 eprintf:01 pervasives:01 stderr:01 argv:01 failwith:01 freshmeat:01 ltd:98 flush:01 compile:02 unix:02 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Demonstration program below. Basically if you compile this and run winfiletest d c:\ winfiletest d c:\temp winfiletest d c:\temp\ <-- this one fails winfiletest d c:\temp\. This is specifically a problem with lablgtk2 which returns directory names with a trailing slash from the file selection dialog. Works OK on the Unix port, but fails under Windows. Rich. ---------------------------------------------------------------------- open Unix let perror f default = try f () with Unix_error (errno, syscall, operand) -> Printf.eprintf "%s: %s: %s\n" syscall operand (error_message errno); Pervasives.flush Pervasives.stderr; default (* Filename concatenation. *) let (//) = Filename.concat (* Check if path is a directory. *) let is_dir path = perror (fun () -> (stat path).st_kind = S_DIR) false (* Check if path is a file. *) let is_file path = perror (fun () -> (stat path).st_kind = S_REG) false let () = if Array.length Sys.argv < 3 then failwith "usage: winfiletest f|d name"; if Sys.argv.(1) = "f" then if is_file Sys.argv.(2) then Printf.printf "is_file true\n" else Printf.printf "is_file false\n" else if is_dir Sys.argv.(2) then Printf.printf "is_dir true\n" else Printf.printf "is_dir false\n"; -- Richard Jones. http://www.annexia.org/ http://freshmeat.net/users/rwmj Merjis Ltd. http://www.merjis.com/ - all your business data are belong to you. "My karma ran over your dogma" ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners