caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Pierrick Couderc <pierrickcouderc@gmail.com>
To: Gabriel Scherer <gabriel.scherer@gmail.com>
Cc: Gustave Nimant <gustave.nimant@free.fr>,
	"caml-list@inria.fr" <caml-list@inria.fr>
Subject: Re: [Caml-list] How to get the path of Filename.current_dir_name
Date: Wed, 5 Oct 2016 16:34:51 +0200	[thread overview]
Message-ID: <CA+gYG2tjPQN+oOT5=EUo9xh5svaW60hb9Ex888K3emHFzN-y6g@mail.gmail.com> (raw)
In-Reply-To: <CAPFanBEz4BQGA1hzisMNLSF3bYF=P_uU2mOp=_U=+RMicyDYqg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1957 bytes --]

>
> You are probably looking for



   Sys.getcwd : unit -> string


If I understood correctly, it is more about the directory of the module at
compile time.

One (hackish) way to do it is with the value __FILE__  in Pervasives (see
http://caml.inria.fr/pub/docs/manual-ocaml/libref/Pervasives.html#6_Debugging
for some compile time constant used for debugging).
It simply returns the path of the .ml given to the compiler, not an
absolute path (except if you called the compiler on an absolute path, of
course).

I do not think there is any way to get the current directory of an
implementation at compile time otherwise.

2016-10-05 16:22 GMT+02:00 Gabriel Scherer <gabriel.scherer@gmail.com>:

> Filename.current_dir_name is likely to be just ".", it indicates the
> (location-agnosti) way to refer to the current directory on your system, to
> make it easier to write code that is portable on other operating systems
> with different path conventions.
>
> You are probably looking for
>
>     Sys.getcwd : unit -> string
>
> which when called returns the current working directory (as the `pwd`
> command would do). It may of course change over the time of your program
> execution, for example if you called Sys.chdir. There is also
>
>   Sys.executable_name : string
>
> (or Sys.argv.(0)) which contains the path of the executable, but it may be
> a relative path -- it depends on how the program was invoked.
>
> On Wed, Oct 5, 2016 at 10:11 AM, Gustave Nimant <gustave.nimant@free.fr>
> wrote:
>
>> Dear list,
>>
>> I would like to get the path of the current directory where the current
>> executed module is implemented.
>> Is there any builtin constant ?
>> I could not find.
>>
>> Thanks,
>> Gustave
>>
>> --
>> Caml-list mailing list.  Subscription management and archives:
>> https://sympa.inria.fr/sympa/arc/caml-list
>> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
>> Bug reports: http://caml.inria.fr/bin/caml-bugs
>>
>
>

[-- Attachment #2: Type: text/html, Size: 3623 bytes --]

  reply	other threads:[~2016-10-05 14:35 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-27 15:04 [Caml-list] [ANN] BAP 1.0.0 Ivan Gotovchits
2016-10-04 13:30 ` Anil Madhavapeddy
2016-10-05 14:11 ` [Caml-list] How to get the path of Filename.current_dir_name Gustave Nimant
2016-10-05 14:22   ` Gabriel Scherer
2016-10-05 14:34     ` Pierrick Couderc [this message]
2016-10-10  8:47       ` Gustave Nimant
2016-10-10  9:01         ` Pierrick Couderc
2016-10-10 10:26           ` Gustave Nimant
2016-10-05 14:35   ` Daniel Bünzli

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='CA+gYG2tjPQN+oOT5=EUo9xh5svaW60hb9Ex888K3emHFzN-y6g@mail.gmail.com' \
    --to=pierrickcouderc@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=gabriel.scherer@gmail.com \
    --cc=gustave.nimant@free.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).