caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [WISH] Unix.fstat and symlinks for win32
@ 2005-02-01 10:07 Christophe TROESTLER
  2005-02-01 11:39 ` [Caml-list] " Marcin 'Qrczak' Kowalczyk
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Christophe TROESTLER @ 2005-02-01 10:07 UTC (permalink / raw)
  To: O'Caml Mailing List

Hi,

Just a small note to tell that I think it would be nice to have
support for Unix.*stat on win32.  Not all characteristics may make
sense but [file_kind], [st_size], [st_perm], [st_*time] do.

Also, why not treat *.lnk as symbolic links under win32?  IMHO it
would be more an asset than an hindrance.

Cheers,
ChriS


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Caml-list] [WISH] Unix.fstat and symlinks for win32
  2005-02-01 10:07 [WISH] Unix.fstat and symlinks for win32 Christophe TROESTLER
@ 2005-02-01 11:39 ` Marcin 'Qrczak' Kowalczyk
  2005-02-01 12:38   ` Christophe TROESTLER
  2005-02-01 14:19 ` Igor Pechtchanski
  2005-02-02  9:54 ` Xavier Leroy
  2 siblings, 1 reply; 8+ messages in thread
From: Marcin 'Qrczak' Kowalczyk @ 2005-02-01 11:39 UTC (permalink / raw)
  To: caml-list

Christophe TROESTLER <Christophe.Troestler@umh.ac.be> writes:

> Also, why not treat *.lnk as symbolic links under win32?

What do you mean? It's the OS which treats symlinks on Unix, and
Windows doesn't. For example you can't put a "link" to a directory
in the middle of a path. And you *can* edit its contents (which is
meaningless for a Unix symlink). It makes no sense to pretend that
they are the same when they are not.

-- 
   __("<         Marcin Kowalczyk
   \__/       qrczak@knm.org.pl
    ^^     http://qrnik.knm.org.pl/~qrczak/


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Caml-list] [WISH] Unix.fstat and symlinks for win32
  2005-02-01 11:39 ` [Caml-list] " Marcin 'Qrczak' Kowalczyk
@ 2005-02-01 12:38   ` Christophe TROESTLER
  0 siblings, 0 replies; 8+ messages in thread
From: Christophe TROESTLER @ 2005-02-01 12:38 UTC (permalink / raw)
  To: qrczak; +Cc: caml-list

On Tue, 01 Feb 2005, "Marcin 'Qrczak' Kowalczyk" <qrczak@knm.org.pl> wrote:
> 
> Christophe TROESTLER <Christophe.Troestler@umh.ac.be> writes:
> 
> > Also, why not treat *.lnk as symbolic links under win32?
> 
> What do you mean? It's the OS which treats symlinks on Unix, and
> Windows doesn't. For example you can't put a "link" to a directory
> in the middle of a path. And you *can* edit its contents (which is
> meaningless for a Unix symlink). It makes no sense to pretend that
> they are the same when they are not.

I did not pretend that *.lnk are equivalent to Unix symlinks -- I know
they are not.  What I was proposing is that, since the symlinks
functions of the Unix module are "not implemented" for win32, it may
be a good use of them to make them create/manipulate *.lnk files.  The
open_* functions need not to follow *.lnk's but the functionality
would be there if so one wishes.  Some infos about the format on
http://www.wotsit.org/search.asp?page=2&s=windows

ChriS


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Caml-list] [WISH] Unix.fstat and symlinks for win32
  2005-02-01 10:07 [WISH] Unix.fstat and symlinks for win32 Christophe TROESTLER
  2005-02-01 11:39 ` [Caml-list] " Marcin 'Qrczak' Kowalczyk
@ 2005-02-01 14:19 ` Igor Pechtchanski
  2005-02-02  9:54 ` Xavier Leroy
  2 siblings, 0 replies; 8+ messages in thread
From: Igor Pechtchanski @ 2005-02-01 14:19 UTC (permalink / raw)
  To: Christophe TROESTLER; +Cc: O'Caml Mailing List

On Tue, 1 Feb 2005, Christophe TROESTLER wrote:

> Hi,
>
> Just a small note to tell that I think it would be nice to have
> support for Unix.*stat on win32.  Not all characteristics may make
> sense but [file_kind], [st_size], [st_perm], [st_*time] do.
>
> Also, why not treat *.lnk as symbolic links under win32?  IMHO it
> would be more an asset than an hindrance.

FWIW, the Cygwin version of O'Caml has Unix.*stat, *and* treats (certain
kinds of) shortcuts as symlinks.

Igor Pechtchanski, volunteer O'Caml maintainer for Cygwin
-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_		pechtcha@cs.nyu.edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor@watson.ibm.com
     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski, Ph.D.
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"The Sun will pass between the Earth and the Moon tonight for a total
Lunar eclipse..." -- WCBS Radio Newsbrief, Oct 27 2004, 12:01 pm EDT


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Caml-list] [WISH] Unix.fstat and symlinks for win32
  2005-02-01 10:07 [WISH] Unix.fstat and symlinks for win32 Christophe TROESTLER
  2005-02-01 11:39 ` [Caml-list] " Marcin 'Qrczak' Kowalczyk
  2005-02-01 14:19 ` Igor Pechtchanski
@ 2005-02-02  9:54 ` Xavier Leroy
  2005-02-02 12:52   ` Christophe TROESTLER
  2005-02-02 22:08   ` Robert Roessler
  2 siblings, 2 replies; 8+ messages in thread
From: Xavier Leroy @ 2005-02-02  9:54 UTC (permalink / raw)
  To: Christophe TROESTLER; +Cc: O'Caml Mailing List

> Just a small note to tell that I think it would be nice to have
> support for Unix.*stat on win32.  Not all characteristics may make
> sense but [file_kind], [st_size], [st_perm], [st_*time] do.

I don't quite understand your question: Unix.stat is implemented under
Windows (building on the _stati64() function provided by the MS C library)
and sets the fields you mention to reasonable values.

Still under Windows (native Windows, not Cygwin), Unix.lstat behaves
like Unix.stat and Unix.fstat is not implemented.  (I'm not even sure
the latter is implementable at all with the Win32 API.)

> Also, why not treat *.lnk as symbolic links under win32?  IMHO it
> would be more an asset than an hindrance.

The Cygwin emulation layer does this, so the Cygwin version of Caml
inherits that behavior.  For the native Windows ports, I think this
wouldn't fit the "spirit" of these ports, which is to remain
relatively close to the semantics of the underlying OS (Windows) and
provide Unix-like wrappers that are quite thin.  

Note that you could implement in Caml a library that sits on top of
Unix and provides *.lnk-aware versions of Unix.openfile and other
file-related calls.

- Xavier Leroy


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Caml-list] [WISH] Unix.fstat and symlinks for win32
  2005-02-02  9:54 ` Xavier Leroy
@ 2005-02-02 12:52   ` Christophe TROESTLER
  2005-02-02 15:08     ` Christopher A. Watford
  2005-02-02 22:08   ` Robert Roessler
  1 sibling, 1 reply; 8+ messages in thread
From: Christophe TROESTLER @ 2005-02-02 12:52 UTC (permalink / raw)
  To: Xavier.Leroy; +Cc: caml-list

On Wed, 2 Feb 2005, Xavier Leroy <Xavier.Leroy@inria.fr> wrote:
> 
> > Just a small note to tell that I think it would be nice to have
> > support for Unix.*stat on win32.  Not all characteristics may make
> > sense but [file_kind], [st_size], [st_perm], [st_*time] do.
> 
> Unix.stat is implemented under Windows (building on the _stati64()
> function provided by the MS C library) and sets the fields you
> mention to reasonable values.

Sorry for the confusion: I was interested in Unix.fstat and when
somebody told me it does not work on win32 (I do not use win32 myself
but try to write portable code whenever possible), I had a (too) quick
look at the manual which says that [lstat], [fstat] are not
implemented -- should not have put a star.

> Still under Windows (native Windows, not Cygwin), Unix.lstat behaves
> like Unix.stat and Unix.fstat is not implemented.

Maybe the manual could be updated to reflect that?  [IMHO, it would be
  nice if the windows peculiarities were in the ocamldoc comments -- I
  usually use ocamlbrowser...]

> (I'm not even sure the latter is implementable at all with the
> Win32 API.)

Windows gurus here?  (My goal with fstat was to know whether stdin was
connected to a socket or a pipe.)

> > Also, why not treat *.lnk as symbolic links under win32?
> 
> For the native Windows ports, I think this wouldn't fit the "spirit"
> of these ports, which is to remain relatively close to the semantics
> of the underlying OS (Windows) and provide Unix-like wrappers that
> are quite thin.

Thanks for the explanation.  (Still there is
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/ifaces/ishelllink/ishelllink.asp
but I do not know whether it fits the bill or whether it is worth the
trouble.)

Regards,
ChriS


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Caml-list] [WISH] Unix.fstat and symlinks for win32
  2005-02-02 12:52   ` Christophe TROESTLER
@ 2005-02-02 15:08     ` Christopher A. Watford
  0 siblings, 0 replies; 8+ messages in thread
From: Christopher A. Watford @ 2005-02-02 15:08 UTC (permalink / raw)
  To: Christophe TROESTLER; +Cc: Xavier.Leroy, caml-list

On Wed, 02 Feb 2005 13:52:08 +0100 (CET), Christophe TROESTLER
<Christophe.Troestler@umh.ac.be> wrote:
> Maybe the manual could be updated to reflect that?  [IMHO, it would be
>  nice if the windows peculiarities were in the ocamldoc comments -- I
>  usually use ocamlbrowser...]
> 
> > (I'm not even sure the latter is implementable at all with the
> > Win32 API.)
> 
> Windows gurus here?  (My goal with fstat was to know whether stdin was
> connected to a socket or a pipe.)

HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE);
BOOL isPipe = ((hStdin != NULL && hStdin != INVALID_HANDLE_VALUE) ?
   GetNamedPipeInfo(hStdin, NULL, NULL, NULL, NULL) :
   FALSE);

> Regards,
> ChriS

There is some dirty code to check if the handle for stdin is using
named pipe functions or if it is using read/write file functions. Yep,
horrible.

-- 
Christopher A. Watford
christopher.watford@gmail.com
http://dorm.tunkeymicket.com


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Caml-list] [WISH] Unix.fstat and symlinks for win32
  2005-02-02  9:54 ` Xavier Leroy
  2005-02-02 12:52   ` Christophe TROESTLER
@ 2005-02-02 22:08   ` Robert Roessler
  1 sibling, 0 replies; 8+ messages in thread
From: Robert Roessler @ 2005-02-02 22:08 UTC (permalink / raw)
  To: Xavier Leroy; +Cc: Christophe TROESTLER, O'Caml Mailing List

Xavier Leroy wrote:

>>Just a small note to tell that I think it would be nice to have
>>support for Unix.*stat on win32.  Not all characteristics may make
>>sense but [file_kind], [st_size], [st_perm], [st_*time] do.
> 
> 
> I don't quite understand your question: Unix.stat is implemented under
> Windows (building on the _stati64() function provided by the MS C library)
> and sets the fields you mention to reasonable values.
> 
> Still under Windows (native Windows, not Cygwin), Unix.lstat behaves
> like Unix.stat and Unix.fstat is not implemented.  (I'm not even sure
> the latter is implementable at all with the Win32 API.)

Actually, not only is [LargeFile.]fstat implementable under Win32, but 
so are [LargeFile.]ftruncate... not to mention that pause and alarm 
*could* be done also, but possibly not as cleanly as the former four.

Details on the above:

ftruncate and LargeFile.ftruncate would work on ALL Win32 platforms, 
using ::SetFilePointer and ::SetEndOfFile (the "::" is what I use to 
distinguish API calls from app or C runtime calls).

fstat and LargeFile.fstat would (according the .NET 2003 C Run-Time 
Library Reference) work on all Win32 platforms EXCEPT Windows 95, 
using _fstati64.  Note that one needs to examine the actual sys/stat.h 
file to see that "_S_IFIFO" is used to denote pipes.

alarm could be done with ::SetTimer, and even be made to work in 
concert with pause, which could use (pick your favorite variant) some 
form of ::[Msg]WaitFor{Single,Multiple}Object[s]... but you would need 
to take some care WRT Windows event processing. :)

As for the ".lnk" files, they don't really correspond with *nix 
notions of either "hard" or "symbolic" links, so attempts at mapping 
them are bound to disappoint some (if not all).

My USD 0.02.

Robert Roessler
robertr@rftp.com
http://www.rftp.com


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2005-02-02 22:06 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-02-01 10:07 [WISH] Unix.fstat and symlinks for win32 Christophe TROESTLER
2005-02-01 11:39 ` [Caml-list] " Marcin 'Qrczak' Kowalczyk
2005-02-01 12:38   ` Christophe TROESTLER
2005-02-01 14:19 ` Igor Pechtchanski
2005-02-02  9:54 ` Xavier Leroy
2005-02-02 12:52   ` Christophe TROESTLER
2005-02-02 15:08     ` Christopher A. Watford
2005-02-02 22:08   ` Robert Roessler

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).