CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 13 of 13
  1. #1
    Join Date
    Sep 2004
    Location
    A Planet Called Earth... :-)
    Posts
    835

    What is "." & ".." - files? folders?

    When i search for files using winapi, i usually come across 2 files/folders. (Am calling them files/folders since i get them as a result when i search for files.)

    What are these exactly?

    I tried google but...
    C++ program ran... C++ program crashed... C++ programmer quit !!

    Regards

    Shaq

  2. #2
    Join Date
    Feb 2000
    Location
    San Diego, CA
    Posts
    10,354

    Re: What is "." & ".." - files? folders?

    . stands for the current folder
    .. for the parent folder

    If you launch a command prompt and do a dir, you would see the same

  3. #3
    Join Date
    Sep 2004
    Location
    Holland (land of the dope)
    Posts
    4,123

    Re: What is "." & ".." - files? folders?

    It are folders. They represent the current folder '.' and the parent folder '..'

  4. #4
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: What is "." & ".." - files? folders?

    Did you never typed in a console:
    Code:
    cd ..
    ?
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  5. #5
    Join Date
    Sep 2004
    Location
    A Planet Called Earth... :-)
    Posts
    835

    Re: What is "." & ".." - files? folders?

    Quote Originally Posted by kirants
    . stands for the current folder
    .. for the parent folder

    If you launch a command prompt and do a dir, you would see the same
    Thanks.

    what is the use of this?

    and..I dont get something,

    what is the use of the dot for current folder, when u r in the current folder.


    Any links would be great.
    C++ program ran... C++ program crashed... C++ programmer quit !!

    Regards

    Shaq

  6. #6
    Join Date
    Sep 2004
    Location
    A Planet Called Earth... :-)
    Posts
    835

    Re: What is "." & ".." - files? folders?

    Quote Originally Posted by cilu
    Did you never typed in a console:
    Code:
    cd ..
    ?
    Never wondered why, until now.
    C++ program ran... C++ program crashed... C++ programmer quit !!

    Regards

    Shaq

  7. #7
    Join Date
    Feb 2000
    Location
    San Diego, CA
    Posts
    10,354

    Re: What is "." & ".." - files? folders?

    Quote Originally Posted by Vedam Shashank
    what is the use of the dot for current folder, when u r in the current folder.
    Good question and I don't know why
    Seems to be some kind of DOS legacy thing.

  8. #8
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: What is "." & ".." - files? folders?

    Quote Originally Posted by kirants
    Good question and I don't know why
    Seems to be some kind of DOS legacy thing.
    I think it's rather Unix related.

    http://en.wikipedia.org/wiki/Path_(computing)
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  9. #9
    Join Date
    Aug 1999
    Location
    <Classified>
    Posts
    6,882

    Re: What is "." & ".." - files? folders?

    Quote Originally Posted by Vedam Shashank
    Thanks.

    what is the use of this?

    and..I dont get something,

    what is the use of the dot for current folder, when u r in the current folder.


    Any links would be great.
    The use is obvious, you dont need to type specific name to access current or parent folder, using dot(s) make it generic.
    Regards,
    Ramkrishna Pawar

  10. #10
    Join Date
    Apr 2004
    Location
    England, Europe
    Posts
    2,492

    Re: What is "." & ".." - files? folders?

    Quote Originally Posted by Vedam Shashank
    Thanks.

    what is the use of this?

    and..I dont get something,

    what is the use of the dot for current folder, when u r in the current folder.


    Any links would be great.
    I could be useful if you want to list all the folders which can be reached form a certain location.

    If your current location is C:\MyFolder\ then you could list all the reachable folders as

    C:\MyFolder\.\
    C:\MyFolder\..\
    C:\MyFolder\FirstSubfolder\
    C:\MyFolder\SecondSubfolder\
    etc.

    But I agree it seems a bit redundant.
    My hobby projects:
    www.rclsoftware.org.uk

  11. #11
    Join Date
    Jun 2006
    Location
    Bangalore, India
    Posts
    332

    Re: What is "." & ".." - files? folders?

    "." can be used as a shorthand for many commands. for example the subst command
    Code:
    subst z: .
    will mount the current directory as a drive ( z: ). You need not type the entire path to accomplish this. Though this existed from DOS(AFAIK), they are quite handy and are kept around. Depending upon the directory/file structure the ".." may point back to the parent directory. This way file recovery softwares can identify and/or resolve conflicts in folders if some corruption occurs to the directory/ file structure.
    Last edited by kumaresh_ana; October 17th, 2006 at 03:10 AM.

  12. #12
    Join Date
    Jun 2006
    Location
    chennai
    Posts
    72

    Smile Re: What is "." & ".." - files? folders?

    Hi,
    It is certainly unix or linux related. (..) and (.) came from unix. In DOS (..) makes sense but not (.). but in unix to execute a executable(!!) you need to specify the path.Unlike DOS Even the Current directly should be explicitly mentioned.

    For example.. Many would know to execute a C program in linux or unix after compiling you need to type .\a.out.

    .\a.out ==> CURRENTDIRECTORY\a.out

    bye
    P.Somasundaram

  13. #13
    Join Date
    Jun 2002
    Location
    Stockholm, Sweden
    Posts
    1,641

    Re: What is "." & ".." - files? folders?

    The reason for this is (among other things) that some systems were compromized by changing the PATH variable. In unix PATH may have priority over the current directory.

    So, if PATH points to a directory that contains a malicious executable file with the same name as a file in the current directory, typing "myexe" would excute that malicious file while "./myexe" would execute the file in the current directory.
    Nobody cares how it works as long as it works

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured