From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id C1A6C7F02A for ; Mon, 10 Oct 2016 11:01:35 +0200 (CEST) Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=pierrickcouderc@gmail.com; spf=Pass smtp.mailfrom=pierrickcouderc@gmail.com; spf=None smtp.helo=postmaster@mail-qk0-f177.google.com Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of pierrickcouderc@gmail.com) identity=pra; client-ip=209.85.220.177; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="pierrickcouderc@gmail.com"; x-sender="pierrickcouderc@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of pierrickcouderc@gmail.com designates 209.85.220.177 as permitted sender) identity=mailfrom; client-ip=209.85.220.177; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="pierrickcouderc@gmail.com"; x-sender="pierrickcouderc@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-qk0-f177.google.com) identity=helo; client-ip=209.85.220.177; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="pierrickcouderc@gmail.com"; x-sender="postmaster@mail-qk0-f177.google.com"; x-conformance=sidf_compatible IronPort-PHdr: =?us-ascii?q?9a23=3AV7j5fx+rR8nrAv9uRHKM819IXTAuvvDOBiVQ1KB9?= =?us-ascii?q?0e4cTK2v8tzYMVDF4r011RmSDN+dsKIP07Ge8/i5HzdfsdDZ6DFKWacPfiFGoP?= =?us-ascii?q?1epxYnDs+BBB+zB9/RRAt+Iv5/UkR49WqwK0lfFZW2TVTTpnqv8WxaQU2nZkJd?= =?us-ascii?q?b974EY/Kjsmxy/v6u9iKO10J13KBZuZdMQ6qpBvc/u8XhIJkNu5lxQbSvnJWdq?= =?us-ascii?q?JQxGZhI067kQzx64G+5sgw3T5XvqcZ9sNaS6TxfOwTSqFUAS4tezQt5cDxrxjI?= =?us-ascii?q?TgCI+3cRSG4+nR9BAgyD5xb/CMSi+hDmv/ZwjXHJdfb9Sqo5DHH7t/9m?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0AOBACtV/tXhrHcVdFbHAEBBAEBCgEBF?= =?us-ascii?q?wEBBAEBCgEBglw1AQEBAQF0fAekL4hGhyuGSyiCcoEsSoEQAoF5BzwQAQEBAQE?= =?us-ascii?q?BAQEBAQESAQEBCAsLCRkvgjIEARUBBIIQAQEBAwESER0BGx0BAwELBgUEBw0qA?= =?us-ascii?q?gIiAREBBQEcBhMiiBMBAwYJCA6maIEyPjKLQoFrgl8Fg18KGScMAVODEQEBAQE?= =?us-ascii?q?BBQEBAQEBGgMGEIYthFWHS4I+HQWOOotFhieJVoFuToQZiR9JiD+Db4I9Ex6BE?= =?us-ascii?q?Q8mXoI8LCCBYDw0AYYNgUEBAQE?= X-IPAS-Result: =?us-ascii?q?A0AOBACtV/tXhrHcVdFbHAEBBAEBCgEBFwEBBAEBCgEBglw?= =?us-ascii?q?1AQEBAQF0fAekL4hGhyuGSyiCcoEsSoEQAoF5BzwQAQEBAQEBAQEBAQESAQEBC?= =?us-ascii?q?AsLCRkvgjIEARUBBIIQAQEBAwESER0BGx0BAwELBgUEBw0qAgIiAREBBQEcBhM?= =?us-ascii?q?iiBMBAwYJCA6maIEyPjKLQoFrgl8Fg18KGScMAVODEQEBAQEBBQEBAQEBGgMGE?= =?us-ascii?q?IYthFWHS4I+HQWOOotFhieJVoFuToQZiR9JiD+Db4I9Ex6BEQ8mXoI8LCCBYDw?= =?us-ascii?q?0AYYNgUEBAQE?= X-IronPort-AV: E=Sophos;i="5.31,471,1473112800"; d="scan'208,217";a="240081069" Received: from mail-qk0-f177.google.com ([209.85.220.177]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 10 Oct 2016 11:01:34 +0200 Received: by mail-qk0-f177.google.com with SMTP id f128so78401184qkb.1 for ; Mon, 10 Oct 2016 02:01:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=ts9rEWGQmlFEDvR4GaISdZOGxOBciszmgjN0UMdt64U=; b=ceQeeYgQCHyIUBoM7ISZhUt8d0J9t6l5yt4t47WjS85INBdSupHBtPBAtSF5mo76nt QLN37BHQtJdDiupjWUu1ifurNHpfAdY0QNnHEz0qk7o1e7m4RBbDc1XfEvNxLlCWKzIP V1f3ubrvBLB2l/GRn/dr/tetTnOcboE8wgetDI919Rb8lgk+0Jga0S282duzPuzWCLW+ mzunNva07p1SZ9GNsQGwn7QtRIlg8Na1QmVgqMW3MDwHttZ/AFa9wFKqici+AHPr9nLE rMJO2h87rooy7KeI4LktSPiUh6QlUGq1zmHqwT0qfJa/bqCFOBgp1WxJfa5wIP8Mqbmr IjxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=ts9rEWGQmlFEDvR4GaISdZOGxOBciszmgjN0UMdt64U=; b=b2KsmDtSvoFiY7XHBtwFIFwLMIsunuyM7tDxemtKxGHd9TztpGfQpo+CIGg6Bl+mz8 m4hizt7zPPDSU1cxxW01tMwSH3V0rMJe5Qx0NJkHTrV03wQz0KP23Nz4XLSGBQSzlhyo qbGaprJeAMhwuOs+poBDsW/btAGVAyun1w6mDzxm0RvVfMpeW1vViDzBLcNXA3pgYR6t P2sLRC/eF6MnIlWjIVjvQzjlgJdEScTh8HACaXkmOG84DnI/vfrKW1iTVBIXs4WLwTmj 3TEwjgnzGj8b8R7ps3zsv8kZdVOoP8r+X0trW+3ylyNuWpOVNeueo8jIHOCdbKPMT9DA DAxA== X-Gm-Message-State: AA6/9RkC2oSy7snfLrpAoqLS75rz7I9NG5guHApFOI+yxleROIf+e6UPdrI/uB5DrzL0y5HM7kc2EgM1l+zcOw== X-Received: by 10.194.176.69 with SMTP id cg5mr28000932wjc.52.1476090093901; Mon, 10 Oct 2016 02:01:33 -0700 (PDT) MIME-Version: 1.0 Received: by 10.194.147.4 with HTTP; Mon, 10 Oct 2016 02:01:13 -0700 (PDT) In-Reply-To: <57FB559A.1070302@free.fr> References: <57F50A2E.5020900@free.fr> <57FB559A.1070302@free.fr> From: Pierrick Couderc Date: Mon, 10 Oct 2016 11:01:13 +0200 Message-ID: To: Gustave Nimant Cc: "caml-list@inria.fr" Content-Type: multipart/alternative; boundary=089e013d0b4eb41ef5053e7f0107 Subject: Re: [Caml-list] How to get the path of Filename.current_dir_name --089e013d0b4eb41ef5053e7f0107 Content-Type: text/plain; charset=UTF-8 > > __FILE__ returns the name of the module, not the name and absolute path. Actually, it returns the exact path given to the compiler. For example : $ cd /tmp $ echo 'Printf.printf \"File path: %s\n%!" __FILE__;;' > t.ml Then compiled and executed: $ ocamlc t.ml && ./a.out > File path: t.ml $ ocamlc /tmp/t.ml && ./a.out > File path: /tmp/t.ml $ ocamlc ../tmp/../tmp/t.ml && ./a.out > File path: ../tmp/../tmp/t.ml 2016-10-10 10:47 GMT+02:00 Gustave Nimant : > On 05/10/2016 16:34, Pierrick Couderc wrote: > > > If I understood correctly, it is more about the directory of the module at > compile time. > > the absolute path 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). > > __FILE__ returns the name of the module, not the name and absolute path. > I do not understand what do you mean by "except if you called the compiler > on an absolute path, of course" > could you please give me more details about calling the compiler on an > absolute path ? > > Thanks > Gustave > --089e013d0b4eb41ef5053e7f0107 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
=C2=A0__FILE__ returns the name of the module, not= the name and absolute path.=C2=A0

A= ctually, it returns the exact path given to the compiler. For example :
=C2=A0 $ cd /tmp
=C2=A0 $ echo 'Printf.printf \"F= ile path: %s\n%!" __FILE__;;' > t.ml

=C2=A0 = > File path: t.ml

= =C2=A0 $ ocamlc /tmp/t.ml && ./a.out
=C2=A0 > File path: /tmp/t.ml
<= div>
=C2=A0 $ ocamlc ../tmp/../tmp/t.= ml && ./a.out
=C2=A0 > File path: ../tmp/../tmp/t.ml

2016-10-10 10:47 GMT+02:00 Gustave Nimant <g= ustave.nimant@free.fr>:
=20=20 =20=20=20=20 =20=20
On 05/10/2016 16:3= 4, Pierrick Couderc wrote:
=20=20=20=20=20=20
If I understood correctly, it is more about the directory of the module at compile time.=C2=A0

the absolute path of the module at compile time.
One (hackish) way to do it is with the value __FILE__ =C2=A0in Pervasives (see=C2=A0http://caml= .inria.fr/pub/docs/manual-ocaml/libref/Pervasives.html#6_Debuggin= g for some compile time constant used for debugging).=C2=A0
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).=C2=A0

=C2=A0__FILE__ returns the name of the module, not the name and absolute path.
I do not understand what do you mean by "except if you called the compiler on an absolute path, of course"
could you please give me more details about calling the compiler on an absolute path ?

Thanks
Gustave

--089e013d0b4eb41ef5053e7f0107--