Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

FrigidHelix

the purpose of directories "." and ".."

This topic is 6512 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I recently had to use the Windows FindFirstFile/FindNextFile functions, and I noticed that directories "." and ".." kept appearing. What is the point of having these show up in the search? From what I understand (and this may be misinformation), these directories are simply the ones ''beneath'' the current one. I don''t see how this would be used in practice, can anyone explain their function to me, and inform me if I am somehow making a mistake by omitting them. Thanks.

Share this post


Link to post
Share on other sites
Advertisement
. refers to the current directory. In some shells, you use it to refer to a program in the current directory (./myprogram).

.. refers to the directory underneath the current directory. This is good if you want to start a program that is in the directory beneath your current directory without having to type in the full path (../myprogram2).

Those are just two examples, I''m sure there are more...

Share this post


Link to post
Share on other sites
I also believe that a big reason for . is a holdover from UNIX. I could be wrong about this, but I BELIEVE that UNIX will look through your path before running a program from the current directory. So, if you are trying to run an executable called ''test'' but there is also an executable called ''test'' in the /etc/bin directory (or somewhere else in your path), you will end up running this other executable. If you want to run the one in the current directory, you just put ./test and you are sure that you are running the correct one.

Now, I could be wrong about this. I''m not a UNIX guru, but I believe that is how it works.

Share this post


Link to post
Share on other sites
Yeah, that''s how most UNIX shells behave. But it is of course possible to program a new shell which behaves like DOS'' command.com... Or simply put ./ before everything else in your PATH and voíla.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!