Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2013-04

GetCurrentDir

8 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Mattias Gaertner

Hi,

On one of my Linux machines GetCurrentDir returns '', when the working directory is a samba share.
Is this a feature or a bug?

Mattias

Michael Van Canneyt
to Mattias Gaertner
Mattias Gaertner wrote 5 lines
Hi, On one of my Linux machines GetCurrentDir returns '', when the working directory is a samba share. Is this a feature or a bug?

It can happen. The linux kernel returns an empty cwd in some cases. The FPC code tries to work its way up from '.' in such a case.

I just tried, but it gives a correct result in my case.

Michael.

Mattias Gaertner
to Michael Van Canneyt
Show quoted text 14 lines
On Sun, 21 Apr 2013, Mattias Gaertner wrote: > Hi, > > On one of my Linux machines GetCurrentDir returns '', when the working > directory is a samba share. > Is this a feature or a bug? It can happen. The linux kernel returns an empty cwd in some cases. The FPC code tries to work its way up from '.' in such a case. I just tried, but it gives a correct result in my case.

Maybe as fallback it can use the environment variable PWD?

Mattias

Marco van de Voort
to Mattias Gaertner

In our previous episode, Mattias Gaertner said:

Show quoted text 5 lines
> The FPC code tries to work its way up from '.' in such a case. > > I just tried, but it gives a correct result in my case. Maybe as fallback it can use the environment variable PWD?

No. That would only be valid right after startup, and doesn't change when you chdir in the program.

Michael Van Canneyt
to Marco van de Voort
Marco van de Voort wrote 9 lines
In our previous episode, Mattias Gaertner said: >> The FPC code tries to work its way up from '.' in such a case. >> >> I just tried, but it gives a correct result in my case. > > Maybe as fallback it can use the environment variable PWD? No. That would only be valid right after startup, and doesn't change when you chdir in the program.

+1

Michael.

Henry Vermaak
to Michael Van Canneyt
Michael Van Canneyt wrote 12 lines
On Mon, 22 Apr 2013, Marco van de Voort wrote: >In our previous episode, Mattias Gaertner said: >>>The FPC code tries to work its way up from '.' in such a case. >>> >>>I just tried, but it gives a correct result in my case. >> >>Maybe as fallback it can use the environment variable PWD? > >No. That would only be valid right after startup, and doesn't change >when you chdir in the program. +1

I think that readlink on /proc/self/cwd should work?

Henry

Michael Van Canneyt
to Henry Vermaak
Henry Vermaak wrote 15 lines
On Mon, Apr 22, 2013 at 09:57:06AM +0200, Michael Van Canneyt wrote: > On Mon, 22 Apr 2013, Marco van de Voort wrote: >> In our previous episode, Mattias Gaertner said: >>>> The FPC code tries to work its way up from '.' in such a case. >>>> >>>> I just tried, but it gives a correct result in my case. >>> >>> Maybe as fallback it can use the environment variable PWD? >> >> No. That would only be valid right after startup, and doesn't change >> when you chdir in the program. > > +1 I think that readlink on /proc/self/cwd should work?

That is what the kernel getcwd returns.
Sometimes this is empty.

Michael.

Mark Morgan Lloyd
to Henry Vermaak: I think that readlink on /proc/self/cwd should work? Henry
Henry Vermaak wrote 12 lines
On Mon, Apr 22, 2013 at 09:57:06AM +0200, Michael Van Canneyt wrote: > On Mon, 22 Apr 2013, Marco van de Voort wrote: >> In our previous episode, Mattias Gaertner said: >>>> The FPC code tries to work its way up from '.' in such a case. >>>> >>>> I just tried, but it gives a correct result in my case. >>> Maybe as fallback it can use the environment variable PWD? >> No. That would only be valid right after startup, and doesn't change >> when you chdir in the program. > +1 I think that readlink on /proc/self/cwd should work?

Could be problematic if the share is in a form that the kernel can't parse.

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]