Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filename.root_dir_name? #2505

Closed
vicuna opened this issue Apr 25, 2004 · 3 comments
Closed

Filename.root_dir_name? #2505

vicuna opened this issue Apr 25, 2004 · 3 comments

Comments

@vicuna
Copy link

vicuna commented Apr 25, 2004

Original bug ID: 2505
Reporter: administrator
Status: closed (set by @xavierleroy on 2013-08-31T10:46:16Z)
Resolution: suspended
Priority: normal
Severity: feature
Category: ~DO NOT USE (was: OCaml general)

Bug description

Hi,

it seems that the function "root_dir_name" is missing in module
"Filename". The problem is that if I want to decompose a path using
successive applications of "dirname", I want to compare the current
directory to either "." or "/" on Unix-systems to detect the base
case. Unfortunately, we only have "current_dir_name" for ".", but not
"root_dir_name" for "/" (or whatever it is on other systems), which may
make it difficult to write portable code.

Regards
Markus

--
Markus Mottl http://www.oefai.at/~markus markus@oefai.at

@vicuna
Copy link
Author

vicuna commented Apr 29, 2004

Comment author: administrator

it seems that the function "root_dir_name" is missing in module
"Filename". The problem is that if I want to decompose a path using
successive applications of "dirname", I want to compare the current
directory to either "." or "/" on Unix-systems to detect the base
case. Unfortunately, we only have "current_dir_name" for ".", but not
"root_dir_name" for "/" (or whatever it is on other systems), which may
make it difficult to write portable code.

Hi Markus,

My first Unix-based reflex would be to say that the root directory is the
directory which is equal to its own dirname.

The problem I see with "root_dir_name": I don't think there is such a
thing in Windows. More precisely, each drive is a root by itself, so
there are more than one root directory. I think my dirname trick
would work under Windows (but I have not checked).

If you can tell me what it should do under Windows, I'll file this as a
feature wish.

-- Damien

@vicuna
Copy link
Author

vicuna commented Apr 29, 2004

Comment author: administrator

Hi Damien,

On Thu, 29 Apr 2004, Damien Doligez wrote:

My first Unix-based reflex would be to say that the root directory is the
directory which is equal to its own dirname.

Unfortunately not: dirname current_dir_name = current_dir_name

So it's not only the root directory "/" that has this property.

The problem I see with "root_dir_name": I don't think there is such a
thing in Windows. More precisely, each drive is a root by itself, so
there are more than one root directory. I think my dirname trick
would work under Windows (but I have not checked).

If you can tell me what it should do under Windows, I'll file this as a
feature wish.

Oh well, I can only hope that Microsoft drops this outdated concept of
having drives instead of logical directory trees...

Anyway, I had thought that e.g. "C:" denotes that root directory of
drive "C", and "C:" refers to the current directory in "C". So maybe
"" does the trick? I haven't used Windows for years so I can't tell...

Regards,
Markus

--
Markus Mottl http://www.oefai.at/~markus markus@oefai.at

@vicuna
Copy link
Author

vicuna commented Jan 27, 2012

Comment author: @damiendoligez

We still don't know what "the" root might be under windows. Moreover, when you decompose with Filename.dirname, the base case is when the result is equal to the argument. Then if Filename.is_relative is true, you are in the "." case; if it's false you are in the root case.

I don't think we can do better than that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant