Re: full path to source file __FILE__

2018-05-29 Thread DigitalDesigns via Digitalmars-d-learn
On Tuesday, 29 May 2018 at 21:41:37 UTC, Ali Çehreli wrote: On 05/29/2018 02:34 PM, DigitalDesigns wrote: > auto x(string fp = __FULL_FILE_PATH__)() {    pragma(msg, fp); } ? __FILE_FULL_PATH__ https://dlang.org/spec/expression#specialkeywords Ali Lol, thanks:

Re: full path to source file __FILE__

2018-05-29 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/29/18 5:34 PM, DigitalDesigns wrote: On Wednesday, 27 July 2016 at 13:58:22 UTC, Jonathan Marler wrote: On Thursday, 21 July 2016 at 19:54:34 UTC, Jonathan Marler wrote: Is there a way to get the full path of the current source file? Something like: __FILE_FULL_PATH__ I'm asking

Re: full path to source file __FILE__

2018-05-29 Thread Ali Çehreli via Digitalmars-d-learn
On 05/29/2018 02:34 PM, DigitalDesigns wrote: > auto x(string fp = __FULL_FILE_PATH__)() {    pragma(msg, fp); } ? __FILE_FULL_PATH__ https://dlang.org/spec/expression#specialkeywords Ali

Re: full path to source file __FILE__

2018-05-29 Thread DigitalDesigns via Digitalmars-d-learn
On Wednesday, 27 July 2016 at 13:58:22 UTC, Jonathan Marler wrote: On Thursday, 21 July 2016 at 19:54:34 UTC, Jonathan Marler wrote: Is there a way to get the full path of the current source file? Something like: __FILE_FULL_PATH__ I'm asking because I'm rewriting a batch script in D, meant

Re: full path to source file __FILE__

2016-07-27 Thread Jonathan Marler via Digitalmars-d-learn
On Thursday, 21 July 2016 at 19:54:34 UTC, Jonathan Marler wrote: Is there a way to get the full path of the current source file? Something like: __FILE_FULL_PATH__ I'm asking because I'm rewriting a batch script in D, meant to be ran with rdmd. However, the script needs to know it's own

Re: full path to source file __FILE__

2016-07-23 Thread Martin Tschierschke via Digitalmars-d-learn
On Thursday, 21 July 2016 at 19:54:34 UTC, Jonathan Marler wrote: Is there a way to get the full path of the current source file? Something like: __FILE_FULL_PATH__ I'm asking because I'm rewriting a batch script in D, meant to be ran with rdmd. However, the script needs to know it's own

Re: full path to source file __FILE__

2016-07-22 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, July 22, 2016 19:28:05 Jonathan Marler via Digitalmars-d-learn wrote: > Actually I realized if __FILE__ was always absolute, then all > your exception messages would contain the full path of the file > it was thrown from on the machine it was compiled on. This would > be quite odd. In

Re: full path to source file __FILE__

2016-07-22 Thread Jonathan Marler via Digitalmars-d-learn
On Friday, 22 July 2016 at 19:23:30 UTC, Steven Schveighoffer wrote: On 7/22/16 2:43 PM, Kagamin wrote: On Friday, 22 July 2016 at 13:50:55 UTC, Jonathan Marler wrote: shell/anypath> rdmd /somedir/clean.d Removing /somedir/build... So for command rdmd /somedir/clean.d what __FILE__ contains?

Re: full path to source file __FILE__

2016-07-22 Thread Jonathan Marler via Digitalmars-d-learn
On Friday, 22 July 2016 at 19:13:31 UTC, sdhdfhed wrote: On Friday, 22 July 2016 at 14:02:03 UTC, Jonathan Marler wrote: The __FILE__ trait seems to be used most useful for error messages. Another usage is for testing parsers or string functions directly on the source. E.g in "devel" mode

Re: full path to source file __FILE__

2016-07-22 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/22/16 2:43 PM, Kagamin wrote: On Friday, 22 July 2016 at 13:50:55 UTC, Jonathan Marler wrote: shell/anypath> rdmd /somedir/clean.d Removing /somedir/build... So for command rdmd /somedir/clean.d what __FILE__ contains? LDC tells me the same path as specified on the command line, and that

Re: full path to source file __FILE__

2016-07-22 Thread sdhdfhed via Digitalmars-d-learn
On Friday, 22 July 2016 at 14:02:03 UTC, Jonathan Marler wrote: The __FILE__ trait seems to be used most useful for error messages. Another usage is for testing parsers or string functions directly on the source. E.g in "devel" mode the main function void main(string[] args) {

Re: full path to source file __FILE__

2016-07-22 Thread Kagamin via Digitalmars-d-learn
On Friday, 22 July 2016 at 13:50:55 UTC, Jonathan Marler wrote: shell/anypath> rdmd /somedir/clean.d Removing /somedir/build... So for command rdmd /somedir/clean.d what __FILE__ contains? LDC tells me the same path as specified on the command line, and that is specified relative to current

Re: full path to source file __FILE__

2016-07-22 Thread Jonathan Marler via Digitalmars-d-learn
On Friday, 22 July 2016 at 09:37:24 UTC, sdhdfhed wrote: On Friday, 22 July 2016 at 08:36:37 UTC, Jonathan Marler wrote: On Friday, 22 July 2016 at 07:57:35 UTC, sdhdfhed wrote: On Friday, 22 July 2016 at 07:47:14 UTC, Jonathan Marler wrote: On Friday, 22 July 2016 at 05:41:00 UTC, fdgdsgf

Re: full path to source file __FILE__

2016-07-22 Thread Jonathan Marler via Digitalmars-d-learn
On Friday, 22 July 2016 at 13:30:10 UTC, Steven Schveighoffer wrote: On 7/22/16 3:47 AM, Jonathan Marler wrote: What's wrong with __FILE__.dirName ? It's kinda weird, sometimes I've noticed that the __FILE__ keyword is an absolute path, and sometimes it isn't. If you combine it with

Re: full path to source file __FILE__

2016-07-22 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/22/16 3:47 AM, Jonathan Marler wrote: What's wrong with __FILE__.dirName ? It's kinda weird, sometimes I've noticed that the __FILE__ keyword is an absolute path, and sometimes it isn't. If you combine it with current working directory, this should give you the full path. Looks like

Re: full path to source file __FILE__

2016-07-22 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 22 July 2016 at 10:51:57 UTC, Kagamin wrote: Don't just ignore Adam's question :) eh he answered it. On Windows, it is somewhat common for things to be loaded or modified (especially on older versions when these were still writable...) from the program's directory. Its support

Re: full path to source file __FILE__

2016-07-22 Thread Kagamin via Digitalmars-d-learn
On Friday, 22 July 2016 at 07:53:17 UTC, Jonathan Marler wrote: It's important to remember that the clean.d script is ran with rdmd, and that it is meant to be called from any directory. Since it's ran with rdmd, the thisExePath won't give you the right directory, and since you can call it

Re: full path to source file __FILE__

2016-07-22 Thread sdhdfhed via Digitalmars-d-learn
On Friday, 22 July 2016 at 08:36:37 UTC, Jonathan Marler wrote: On Friday, 22 July 2016 at 07:57:35 UTC, sdhdfhed wrote: On Friday, 22 July 2016 at 07:47:14 UTC, Jonathan Marler wrote: On Friday, 22 July 2016 at 05:41:00 UTC, fdgdsgf wrote: What's wrong with __FILE__.dirName ? It's kinda

Re: full path to source file __FILE__

2016-07-22 Thread Jonathan Marler via Digitalmars-d-learn
On Friday, 22 July 2016 at 07:57:35 UTC, sdhdfhed wrote: On Friday, 22 July 2016 at 07:47:14 UTC, Jonathan Marler wrote: On Friday, 22 July 2016 at 05:41:00 UTC, fdgdsgf wrote: What's wrong with __FILE__.dirName ? It's kinda weird, sometimes I've noticed that the __FILE__ keyword is an

Re: full path to source file __FILE__

2016-07-22 Thread sdhdfhed via Digitalmars-d-learn
On Friday, 22 July 2016 at 07:57:35 UTC, sdhdfhed wrote: On Friday, 22 July 2016 at 07:47:14 UTC, Jonathan Marler wrote: [...] Personally I've never seen a relative __FILE__. Is this an issue that's confirmed ? I mean that it would be better to fix __FILE__ so that its result is always

Re: full path to source file __FILE__

2016-07-22 Thread sdhdfhed via Digitalmars-d-learn
On Friday, 22 July 2016 at 07:47:14 UTC, Jonathan Marler wrote: On Friday, 22 July 2016 at 05:41:00 UTC, fdgdsgf wrote: What's wrong with __FILE__.dirName ? It's kinda weird, sometimes I've noticed that the __FILE__ keyword is an absolute path, and sometimes it isn't. If it was always an

Re: full path to source file __FILE__

2016-07-22 Thread Jonathan Marler via Digitalmars-d-learn
On Friday, 22 July 2016 at 06:45:58 UTC, Jacob Carlborg wrote: On 2016-07-22 04:24, Jonathan Marler wrote: The script depends on other files relative to where it exists on the file system. I couldn't think of a better design to find these files then knowing where the script exists, can you?

Re: full path to source file __FILE__

2016-07-22 Thread Jonathan Marler via Digitalmars-d-learn
On Friday, 22 July 2016 at 05:41:00 UTC, fdgdsgf wrote: On Thursday, 21 July 2016 at 19:54:34 UTC, Jonathan Marler wrote: Is there a way to get the full path of the current source file? Something like: __FILE_FULL_PATH__ I'm asking because I'm rewriting a batch script in D, meant to be ran

Re: full path to source file __FILE__

2016-07-22 Thread Jacob Carlborg via Digitalmars-d-learn
On 2016-07-22 04:24, Jonathan Marler wrote: The script depends on other files relative to where it exists on the file system. I couldn't think of a better design to find these files then knowing where the script exists, can you? What kind of files are we talking about. Resource files, config

Re: full path to source file __FILE__

2016-07-21 Thread fdgdsgf via Digitalmars-d-learn
On Thursday, 21 July 2016 at 19:54:34 UTC, Jonathan Marler wrote: Is there a way to get the full path of the current source file? Something like: __FILE_FULL_PATH__ I'm asking because I'm rewriting a batch script in D, meant to be ran with rdmd. However, the script needs to know it's own

Re: full path to source file __FILE__

2016-07-21 Thread Jonathan Marler via Digitalmars-d-learn
On Thursday, 21 July 2016 at 22:57:06 UTC, Jonathan M Davis wrote: On Thursday, July 21, 2016 18:39:45 Steven Schveighoffer via Digitalmars-d- learn wrote: [...] It would be pretty terrible actually to put the executable in the source path, and in many cases, the user wouldn't even have the

Re: full path to source file __FILE__

2016-07-21 Thread Jonathan Marler via Digitalmars-d-learn
On Friday, 22 July 2016 at 01:52:57 UTC, Adam D. Ruppe wrote: On Thursday, 21 July 2016 at 22:47:42 UTC, Jonathan Marler wrote: I explain in the original post. Any ideas Adam? Thanks in advance. But why does the batch script use it? Since you are rewriting anyway, maybe you can find an

Re: full path to source file __FILE__

2016-07-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 21 July 2016 at 22:47:42 UTC, Jonathan Marler wrote: I explain in the original post. Any ideas Adam? Thanks in advance. But why does the batch script use it? Since you are rewriting anyway, maybe you can find an easier/better way to achieve the goal.

Re: full path to source file __FILE__

2016-07-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, July 21, 2016 19:54:34 Jonathan Marler via Digitalmars-d-learn wrote: > Is there a way to get the full path of the current source file? > Something like: > > __FILE_FULL_PATH__ > > I'm asking because I'm rewriting a batch script in D, meant to be > ran with rdmd. However, the script

Re: full path to source file __FILE__

2016-07-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, July 21, 2016 18:39:45 Steven Schveighoffer via Digitalmars-d- learn wrote: > On 7/21/16 3:54 PM, Jonathan Marler wrote: > > Is there a way to get the full path of the current source file? > > Something like: > > > > __FILE_FULL_PATH__ > > > > I'm asking because I'm rewriting a batch

Re: full path to source file __FILE__

2016-07-21 Thread Jonathan Marler via Digitalmars-d-learn
On Thursday, 21 July 2016 at 22:39:45 UTC, Steven Schveighoffer wrote: On 7/21/16 3:54 PM, Jonathan Marler wrote: Is there a way to get the full path of the current source file? Something like: __FILE_FULL_PATH__ I'm asking because I'm rewriting a batch script in D, meant to be ran with

Re: full path to source file __FILE__

2016-07-21 Thread Jonathan Marler via Digitalmars-d-learn
On Thursday, 21 July 2016 at 22:33:39 UTC, Adam D. Ruppe wrote: On Thursday, 21 July 2016 at 22:28:39 UTC, zabruk70 wrote: won't? what this means? That gives the path to the .exe but he wants the path to the .d. But why? I would think the current working directory is probably adequate and

Re: full path to source file __FILE__

2016-07-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/21/16 3:54 PM, Jonathan Marler wrote: Is there a way to get the full path of the current source file? Something like: __FILE_FULL_PATH__ I'm asking because I'm rewriting a batch script in D, meant to be ran with rdmd. However, the script needs to know it's own path. The original batch

Re: full path to source file __FILE__

2016-07-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 21 July 2016 at 22:28:39 UTC, zabruk70 wrote: won't? what this means? That gives the path to the .exe but he wants the path to the .d. But why? I would think the current working directory is probably adequate and that's easy to get...

Re: full path to source file __FILE__

2016-07-21 Thread zabruk70 via Digitalmars-d-learn
On Thursday, 21 July 2016 at 19:54:34 UTC, Jonathan Marler wrote: thisExePath won't work. won't? what this means? this work on my windows import std.file: thisExePath; import std.stdio: writeln; void main() { writeln(thisExePath()); }

full path to source file __FILE__

2016-07-21 Thread Jonathan Marler via Digitalmars-d-learn
Is there a way to get the full path of the current source file? Something like: __FILE_FULL_PATH__ I'm asking because I'm rewriting a batch script in D, meant to be ran with rdmd. However, the script needs to know it's own path. The original batch script uses the %~dp0 variable for this,