caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Richard Jones <rich@annexia.org>
To: caml-list@inria.fr
Subject: [Caml-list] Unix.stat sometimes fails on Win32 port
Date: Wed, 6 Aug 2003 11:02:25 +0100	[thread overview]
Message-ID: <20030806100225.GA27730@redhat.com> (raw)

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


             reply	other threads:[~2003-08-06 10:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-08-06 10:02 Richard Jones [this message]
2003-08-06 14:39 ` David Brown
2003-08-06 14:49   ` Richard Jones
2003-08-06 16:21     ` David Brown
2003-08-06 17:01       ` John Carr

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030806100225.GA27730@redhat.com \
    --to=rich@annexia.org \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).